This commit is contained in:
CortexCore
2024-03-05 15:27:29 +08:00
parent 7766082e9d
commit 2c8dfd3c86
45 changed files with 6760 additions and 138 deletions

View File

@@ -2,6 +2,7 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
#if UNITY_EDITOR
using UnityEditor;
@@ -17,6 +18,15 @@ namespace BITKit.Mod
[SerializeField] private bool loadLocalPackageOnStart;
private async void Start()
{
if (Application.isEditor is false)
{
BIT4Log.Log<UnityModService>($"UnityPlayer所在位置:{Application.dataPath}");
BIT4Log.Log<UnityModService>($"{nameof(System.Linq)}位于{typeof(Enumerable).Assembly.Location}");
}
foreach (var x in referencedAssemblies)
{
var dllName = x.Value.Contains(".dll") ? x.Value : $"{x.Value}.dll";

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using BITKit.Net.LAN;
using Cysharp.Threading.Tasks;
@@ -23,8 +24,10 @@ namespace BITKit.Mod
_broadcaster.StartListen();
}
private void OnReceive(EndPoint arg1, byte[] bytes)
private async void OnReceive(EndPoint arg1, byte[] bytes)
{
await UniTask.SwitchToMainThread();
if(destroyCancellationToken.IsCancellationRequested) return;
var command = BITBinary.ReadAsValue(bytes);
switch (command)
{
@@ -32,6 +35,17 @@ namespace BITKit.Mod
BIT4Log.Log<UnityWorkshopClient>($"收到加载命令:{loadFromFolderCommand.FolderPath}");
ModService.LoadFromPackage(loadFromFolderCommand.FolderPath).Forget();
break;
case UninstallPackageCommand uninstallPackageCommand:
BIT4Log.Log<UnityWorkshopClient>($"收到卸载命令:{uninstallPackageCommand.PackageName}");
var mod = ModService.Mods.SingleOrDefault(x=>x.PackageName == uninstallPackageCommand.PackageName);
if (mod is null)
{
BIT4Log.Warning<UnityWorkshopClient>($"未找到包:{uninstallPackageCommand.PackageName}");
return;
}
ModService.UnLoad(mod);
ModService.UnInstall(mod);
break;
default:
BIT4Log.Log<UnityWorkshopClient>($"未知命令:{command}");
break;