[+] 接入ET8服务端

[+] 接入ET8服务端
This commit is contained in:
ALEXTANG
2023-07-13 12:23:48 +08:00
parent e0be062006
commit 336d4b2eb9
1316 changed files with 130657 additions and 626 deletions

View File

@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Runtime.Loader;
namespace ET
{
public class CodeLoader: Singleton<CodeLoader>, ISingletonAwake
{
private AssemblyLoadContext assemblyLoadContext;
private Assembly model;
public void Awake()
{
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly assembly in assemblies)
{
if (assembly.GetName().Name == "Model")
{
this.model = assembly;
break;
}
}
this.LoadHotfix();
IStaticMethod start = new StaticMethod(this.model, "ET.Entry", "Start");
start.Run();
}
public void LoadHotfix()
{
assemblyLoadContext?.Unload();
GC.Collect();
assemblyLoadContext = new AssemblyLoadContext("Hotfix", true);
byte[] dllBytes = File.ReadAllBytes("./Hotfix.dll");
byte[] pdbBytes = File.ReadAllBytes("./Hotfix.pdb");
Assembly hotfixAssembly = assemblyLoadContext.LoadFromStream(new MemoryStream(dllBytes), new MemoryStream(pdbBytes));
Dictionary<string, Type> types = AssemblyHelper.GetAssemblyTypes(Assembly.GetEntryAssembly(), typeof(Init).Assembly, typeof (Fiber).Assembly, this.model, hotfixAssembly);
World.Instance.AddSingleton<EventSystem, Dictionary<string, Type>>(types);
World.Instance.Load();
}
}
}