This commit is contained in:
zznty
2022-10-28 01:58:54 +07:00
commit 0108e8679f
9 changed files with 321 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
using System.Collections.Concurrent;
using System.Collections.Immutable;
using System.Reflection;
using HarmonyLib;
using VRage.Scripting;
namespace CringeLauncher.Patches;
[HarmonyPatch]
public static class ScriptCompilerInitializationPatch
{
private static MethodInfo TargetMethod()
{
return AccessTools.Method(Type.GetType("VRage.Scripting.MyVRageScriptingInternal, VRage.Scripting", true),
"Initialize");
}
private static bool Prefix(Thread updateThread, Type[] referencedTypes, string[] symbols)
{
MyModWatchdog.Init(updateThread);
MyScriptCompiler.Static.AddImplicitIngameNamespacesFromTypes(referencedTypes);
MyScriptCompiler.Static.AddConditionalCompilationSymbols(symbols);
using var batch = MyScriptCompiler.Static.Whitelist.OpenBatch();
batch.AllowTypes(MyWhitelistTarget.ModApi, typeof(ConcurrentQueue<>));
batch.AllowNamespaceOfTypes(MyWhitelistTarget.Both, typeof(ImmutableArray));
return false;
}
}