Fix mod components loading
All checks were successful
Build / Compute Version (push) Successful in 5s
Build / Build Nuget package (CringeBootstrap.Abstractions) (push) Successful in 2m2s
Build / Build Nuget package (NuGet) (push) Successful in 2m50s
Build / Build Nuget package (CringePlugins) (push) Successful in 3m19s
Build / Build Nuget package (SharedCringe) (push) Successful in 2m31s
Build / Build Launcher (push) Successful in 3m24s
All checks were successful
Build / Compute Version (push) Successful in 5s
Build / Build Nuget package (CringeBootstrap.Abstractions) (push) Successful in 2m2s
Build / Build Nuget package (NuGet) (push) Successful in 2m50s
Build / Build Nuget package (CringePlugins) (push) Successful in 3m19s
Build / Build Nuget package (SharedCringe) (push) Successful in 2m31s
Build / Build Launcher (push) Successful in 3m24s
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -8,3 +8,4 @@ riderModule.iml
|
|||||||
/CringeLauncher/Bin64
|
/CringeLauncher/Bin64
|
||||||
/CringeLauncher/pub
|
/CringeLauncher/pub
|
||||||
*.user
|
*.user
|
||||||
|
pub/
|
||||||
|
@@ -3,9 +3,13 @@ using System.Reflection;
|
|||||||
using System.Runtime.Loader;
|
using System.Runtime.Loader;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
using CringeBootstrap.Abstractions;
|
using CringeBootstrap.Abstractions;
|
||||||
|
using CringeLauncher.Loader;
|
||||||
using CringePlugins.Utils;
|
using CringePlugins.Utils;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
using Sandbox.Game.GameSystems.TextSurfaceScripts;
|
||||||
|
using Sandbox.Game;
|
||||||
using Sandbox.Game.World;
|
using Sandbox.Game.World;
|
||||||
|
using SharedCringe.Loader;
|
||||||
using VRage;
|
using VRage;
|
||||||
using VRage.FileSystem;
|
using VRage.FileSystem;
|
||||||
using VRage.Game;
|
using VRage.Game;
|
||||||
@@ -13,6 +17,7 @@ using VRage.Game.Common;
|
|||||||
using VRage.Game.Components;
|
using VRage.Game.Components;
|
||||||
using VRage.Game.Definitions;
|
using VRage.Game.Definitions;
|
||||||
using VRage.Game.Entity.UseObject;
|
using VRage.Game.Entity.UseObject;
|
||||||
|
using VRage.ModAPI;
|
||||||
using VRage.ObjectBuilders;
|
using VRage.ObjectBuilders;
|
||||||
using VRage.ObjectBuilders.Private;
|
using VRage.ObjectBuilders.Private;
|
||||||
using VRage.Plugins;
|
using VRage.Plugins;
|
||||||
@@ -28,6 +33,27 @@ public static class IntrospectionPatches
|
|||||||
if (AssemblyLoadContext.GetLoadContext(__instance) is ICoreLoadContext || __instance.FullName?.StartsWith("System.") == true)
|
if (AssemblyLoadContext.GetLoadContext(__instance) is ICoreLoadContext || __instance.FullName?.StartsWith("System.") == true)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (AssemblyLoadContext.GetLoadContext(__instance) is ModAssemblyLoadContext or DerivedAssemblyLoadContext)
|
||||||
|
{
|
||||||
|
//mods need to look for specific derived types
|
||||||
|
Debug.WriteLine($"Getting special types for {__instance.FullName}");
|
||||||
|
var module = __instance.GetMainModule();
|
||||||
|
__result = IntrospectionContext.Global.CollectDerivedTypes<MyGameLogicComponent>(module)
|
||||||
|
.Concat(IntrospectionContext.Global.CollectDerivedTypes<MyObjectBuilder_Base>(module))
|
||||||
|
.Concat(IntrospectionContext.Global.CollectDerivedTypes<MyStatLogic>(module))
|
||||||
|
.Concat(IntrospectionContext.Global.CollectAttributedTypes<MyObjectBuilderDefinitionAttribute>(module))
|
||||||
|
.Concat(IntrospectionContext.Global.CollectDerivedTypes<MyComponentBase>(module))
|
||||||
|
.Concat(IntrospectionContext.Global.CollectAttributedTypes<MyComponentBuilderAttribute>(module))
|
||||||
|
.Concat(IntrospectionContext.Global.CollectDerivedTypes<IMyTextSurfaceScript>(module))
|
||||||
|
.Concat(IntrospectionContext.Global.CollectDerivedTypes<IMyUseObject>(module))
|
||||||
|
.Concat(IntrospectionContext.Global.CollectDerivedTypes<IMyHudStat>(module))
|
||||||
|
.Concat(IntrospectionContext.Global.CollectAttributedTypes<MySessionComponentDescriptor>(module))
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Debug.WriteLine($"Blocking GetTypes for {__instance.FullName}");
|
Debug.WriteLine($"Blocking GetTypes for {__instance.FullName}");
|
||||||
|
|
||||||
__result = [];
|
__result = [];
|
||||||
|
@@ -15,7 +15,7 @@ public class IntrospectionContext
|
|||||||
|
|
||||||
return moduleDef.GetTypes()
|
return moduleDef.GetTypes()
|
||||||
.Where(b => b.CustomAttributes.IsDefined(typeof(TAttribute).FullName) && (allowAbstract || !b.IsAbstract))
|
.Where(b => b.CustomAttributes.IsDefined(typeof(TAttribute).FullName) && (allowAbstract || !b.IsAbstract))
|
||||||
.Select(b => module.GetType(b.FullName, true, false)!);
|
.Select(b => module.GetType(b.FullName.Replace('/', '+'), true, false)!);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Type> CollectDerivedTypes<T>(Module module, bool allowAbstract = false)
|
public IEnumerable<Type> CollectDerivedTypes<T>(Module module, bool allowAbstract = false)
|
||||||
@@ -28,7 +28,7 @@ public class IntrospectionContext
|
|||||||
.Where(b => (typeof(T).IsInterface
|
.Where(b => (typeof(T).IsInterface
|
||||||
? b.Interfaces.Any(i => i.Interface.FullName == token.FullName)
|
? b.Interfaces.Any(i => i.Interface.FullName == token.FullName)
|
||||||
: MatchBaseType(b, token)) && (allowAbstract || !b.IsAbstract))
|
: MatchBaseType(b, token)) && (allowAbstract || !b.IsAbstract))
|
||||||
.Select(b => module.GetType(b.FullName, true, false)!);
|
.Select(b => module.GetType(b.FullName.Replace('/', '+'), true, false)!);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool MatchBaseType(ITypeDefOrRef? defOrRef, TypeSig token)
|
private static bool MatchBaseType(ITypeDefOrRef? defOrRef, TypeSig token)
|
||||||
|
Reference in New Issue
Block a user