add bootstrap and plugins prototype

This commit is contained in:
zznty
2024-10-10 00:38:19 +07:00
parent c7757a2279
commit 0933915c64
32 changed files with 1487 additions and 76 deletions

View File

@@ -0,0 +1,32 @@
using System.Diagnostics;
using System.Reflection;
using System.Runtime.Loader;
using CringeBootstrap;
using CringeBootstrap.Abstractions;
using Velopack;
#if DEBUG
while (!Debugger.IsAttached)
Thread.Sleep(100);
#endif
VelopackApp.Build().Run();
AssemblyLoadContext.Default.Resolving += (loadContext, name) =>
{
Debug.WriteLine($"resolving {name} in {loadContext}");
return null;
};
var dir = Path.GetDirectoryName(args[0])!;
var context = new GameDirectoryAssemblyLoadContext(dir);
context.AddDependencyOverride("CringeLauncher");
context.AddDependencyOverride("PluginLoader");
var launcher = context.LoadFromAssemblyName(new AssemblyName("CringeLauncher"));
using var corePlugin = (ICorePlugin) launcher.CreateInstance("CringeLauncher.Launcher")!;
corePlugin.Initialize(args);
corePlugin.Run();