diff --git a/Torch.API/Torch.API.csproj b/Torch.API/Torch.API.csproj
index 7c8f151..cb8b425 100644
--- a/Torch.API/Torch.API.csproj
+++ b/Torch.API/Torch.API.csproj
@@ -21,7 +21,7 @@
-
+
all
compile
diff --git a/Torch.API/packages.lock.json b/Torch.API/packages.lock.json
index 77dde96..f9f7f63 100644
--- a/Torch.API/packages.lock.json
+++ b/Torch.API/packages.lock.json
@@ -43,9 +43,9 @@
},
"SpaceEngineersDedicated.ReferenceAssemblies": {
"type": "Direct",
- "requested": "[1.201.13, )",
- "resolved": "1.201.13",
- "contentHash": "FRXuNLENsz5jGQvL0QkogAGsxEJyUQlXhvWHBWfZiHCnCrAWMD60nEis6yt0xCQpazszfMtHonbxz72XMxnFoQ==",
+ "requested": "[1.202.48, )",
+ "resolved": "1.202.48",
+ "contentHash": "iP34MZD14Z/4HTg8rcKQlzJ+azM8/9HVScMJqdYejYbSDAiZzaZS6wlbPkDOKGhbLV2+iW7N5Ix/hCUATBYGuw==",
"dependencies": {
"protobuf-net": "1.0.0"
}
diff --git a/Torch.Server/Torch.Server.csproj b/Torch.Server/Torch.Server.csproj
index cc278fb..9e44862 100644
--- a/Torch.Server/Torch.Server.csproj
+++ b/Torch.Server/Torch.Server.csproj
@@ -51,7 +51,7 @@
-
+
all
compile
diff --git a/Torch.Server/packages.lock.json b/Torch.Server/packages.lock.json
index 6e5f00a..206247c 100644
--- a/Torch.Server/packages.lock.json
+++ b/Torch.Server/packages.lock.json
@@ -122,9 +122,9 @@
},
"SpaceEngineersDedicated.ReferenceAssemblies": {
"type": "Direct",
- "requested": "[1.201.13, )",
- "resolved": "1.201.13",
- "contentHash": "FRXuNLENsz5jGQvL0QkogAGsxEJyUQlXhvWHBWfZiHCnCrAWMD60nEis6yt0xCQpazszfMtHonbxz72XMxnFoQ==",
+ "requested": "[1.202.48, )",
+ "resolved": "1.202.48",
+ "contentHash": "iP34MZD14Z/4HTg8rcKQlzJ+azM8/9HVScMJqdYejYbSDAiZzaZS6wlbPkDOKGhbLV2+iW7N5Ix/hCUATBYGuw==",
"dependencies": {
"protobuf-net": "1.0.0"
}
diff --git a/Torch/Patches/ObjectFactoryInitPatch.cs b/Torch/Patches/ObjectFactoryInitPatch.cs
deleted file mode 100644
index 2c48dd9..0000000
--- a/Torch/Patches/ObjectFactoryInitPatch.cs
+++ /dev/null
@@ -1,139 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using Sandbox;
-using Sandbox.Game.Entities;
-using Torch.Utils;
-using VRage.Game.Common;
-using VRage.Game.Components;
-using VRage.Game.Entity;
-using VRage.ObjectBuilders;
-using VRage.Plugins;
-using VRage.Utils;
-
-namespace Torch.Patches
-{
-
- ///
- /// There are places in static ctors where the registered assembly depends on the
- /// or . Here we force those registrations with the proper assemblies to ensure they work correctly.
- ///
- internal static class ObjectFactoryInitPatch
- {
-#pragma warning disable 649
- [ReflectedGetter(Name = "m_objectFactory", TypeName = "Sandbox.Game.Entities.MyEntityFactory, Sandbox.Game")]
- private static Func> EntityFactoryObjectFactory;
-#pragma warning restore 649
-
- internal static void ForceRegisterAssemblies()
- {
- var userAssemblies = MyPlugins.UserAssemblies;
- // static MyEntities() called by MySandboxGame.ForceStaticCtor
- RuntimeHelpers.RunClassConstructor(typeof(MyEntities).TypeHandle);
- {
- MyObjectFactory factory = EntityFactoryObjectFactory();
- ObjectFactory_RegisterFromAssemblySafe(factory, typeof(MySandboxGame).Assembly); // calling assembly
- ObjectFactory_RegisterFromAssemblySafe(factory, MyPlugins.GameAssembly);
- ObjectFactory_RegisterFromAssemblySafe(factory, MyPlugins.SandboxAssembly);
- //ObjectFactory_RegisterFromAssemblySafe(factory, MyPlugins.UserAssembly);
- if (userAssemblies != null)
- {
- foreach (var assembly in userAssemblies)
- {
- ObjectFactory_RegisterFromAssemblySafe(factory, assembly);
- }
- }
- }
-
- // static MyGuiManager():
- // MyGuiControlsFactory.RegisterDescriptorsFromAssembly();
-
- // static MyComponentTypeFactory() called by MyComponentContainer.Add
- RuntimeHelpers.RunClassConstructor(typeof(MyComponentTypeFactory).TypeHandle);
- {
- ComponentTypeFactory_RegisterFromAssemblySafe(typeof(MyComponentContainer).Assembly); // calling assembly
- ComponentTypeFactory_RegisterFromAssemblySafe(MyPlugins.SandboxAssembly);
- ComponentTypeFactory_RegisterFromAssemblySafe(MyPlugins.GameAssembly);
- ComponentTypeFactory_RegisterFromAssemblySafe(MyPlugins.SandboxGameAssembly);
- //ComponentTypeFactory_RegisterFromAssemblySafe(MyPlugins.UserAssembly);
- if (userAssemblies != null)
- {
- foreach (var assembly in userAssemblies)
- {
- ComponentTypeFactory_RegisterFromAssemblySafe(assembly);
- }
- }
- }
-
- MyEntities.Orchestrator = new MyParallelEntityUpdateOrchestrator();
-
- // static MyObjectPoolManager()
- // Render, so should be fine.
- }
-
- #region MyObjectFactory Adders
- private static void ObjectFactory_RegisterDescriptorSafe(
- MyObjectFactory factory, TAttribute descriptor, Type type) where TAttribute : MyFactoryTagAttribute where TCreatedObjectBase : class
- {
- if (factory.Attributes.TryGetValue(type, out _))
- return;
- if (descriptor.ObjectBuilderType != null && factory.TryGetProducedType(descriptor.ObjectBuilderType) != null)
- return;
- if (typeof(MyObjectBuilder_Base).IsAssignableFrom(descriptor.ProducedType) &&
- factory.TryGetProducedType(descriptor.ProducedType) != null)
- return;
- factory.RegisterDescriptor(descriptor, type);
- }
-
- private static void ObjectFactory_RegisterFromAssemblySafe(MyObjectFactory factory, Assembly assembly) where TAttribute : MyFactoryTagAttribute where TCreatedObjectBase : class
- {
- if (assembly == null)
- {
- return;
- }
- foreach (Type type in assembly.GetTypes())
- {
- foreach (TAttribute descriptor in type.GetCustomAttributes())
- {
- ObjectFactory_RegisterDescriptorSafe(factory, descriptor, type);
- }
- }
- }
- #endregion
- #region MyComponentTypeFactory Adders
-
- [ReflectedGetter(Name = "m_idToType", Type = typeof(MyComponentTypeFactory))]
- private static Func> ComponentTypeFactoryIdToType = null!;
- [ReflectedGetter(Name = "m_typeToId", Type = typeof(MyComponentTypeFactory))]
- private static Func> ComponentTypeFactoryTypeToId = null!;
- [ReflectedGetter(Name = "m_typeToContainerComponentType", Type = typeof(MyComponentTypeFactory))]
- private static Func> ComponentTypeFactoryContainerComponentType = null!;
-
- private static void ComponentTypeFactory_RegisterFromAssemblySafe(Assembly assembly)
- {
- if (assembly == null)
- return;
- foreach (Type type in assembly.GetTypes())
- if (typeof(MyComponentBase).IsAssignableFrom(type))
- {
- ComponentTypeFactory_AddIdSafe(type, MyStringId.GetOrCompute(type.Name));
- ComponentTypeFactory_RegisterComponentTypeAttributeSafe(type);
- }
- }
-
- private static void ComponentTypeFactory_RegisterComponentTypeAttributeSafe(Type type)
- {
- Type componentType = type.GetCustomAttribute(true)?.ComponentType;
- if (componentType != null)
- ComponentTypeFactoryContainerComponentType()[type] = componentType;
- }
-
- private static void ComponentTypeFactory_AddIdSafe(Type type, MyStringId id)
- {
- ComponentTypeFactoryIdToType()[id] = type;
- ComponentTypeFactoryTypeToId()[type] = id;
- }
- #endregion
- }
-}
diff --git a/Torch/Torch.csproj b/Torch/Torch.csproj
index 7f544ee..9112330 100644
--- a/Torch/Torch.csproj
+++ b/Torch/Torch.csproj
@@ -35,7 +35,7 @@
-
+
all
compile
diff --git a/Torch/TorchBase.cs b/Torch/TorchBase.cs
index 71ff3f9..ec1f0b4 100644
--- a/Torch/TorchBase.cs
+++ b/Torch/TorchBase.cs
@@ -132,14 +132,8 @@ namespace Torch
GameStateChanged += (game, state) =>
{
- if (state == TorchGameState.Created)
- {
- // If the attached assemblies change (MySandboxGame.ctor => MySandboxGame.ParseArgs => MyPlugins.RegisterFromArgs)
- // attach assemblies to object factories again.
- ObjectFactoryInitPatch.ForceRegisterAssemblies();
- // safe to commit here; all important static ctors have run
+ if (state == TorchGameState.Created)
PatchManager.CommitInternal();
- }
};
var harmonyLog = LogManager.GetLogger("HarmonyX");
@@ -259,7 +253,6 @@ namespace Torch
public virtual void Init()
{
Debug.Assert(!_init, "Torch instance is already initialized.");
- ObjectFactoryInitPatch.ForceRegisterAssemblies();
VRageGame.SetupVersionInfo();
Debug.Assert(MyPerGameSettings.BasicGameInfo.GameVersion != null, "MyPerGameSettings.BasicGameInfo.GameVersion != null");
diff --git a/Torch/packages.lock.json b/Torch/packages.lock.json
index eb7d87f..1e1e765 100644
--- a/Torch/packages.lock.json
+++ b/Torch/packages.lock.json
@@ -102,9 +102,9 @@
},
"SpaceEngineersDedicated.ReferenceAssemblies": {
"type": "Direct",
- "requested": "[1.201.13, )",
- "resolved": "1.201.13",
- "contentHash": "FRXuNLENsz5jGQvL0QkogAGsxEJyUQlXhvWHBWfZiHCnCrAWMD60nEis6yt0xCQpazszfMtHonbxz72XMxnFoQ==",
+ "requested": "[1.202.48, )",
+ "resolved": "1.202.48",
+ "contentHash": "iP34MZD14Z/4HTg8rcKQlzJ+azM8/9HVScMJqdYejYbSDAiZzaZS6wlbPkDOKGhbLV2+iW7N5Ix/hCUATBYGuw==",
"dependencies": {
"protobuf-net": "1.0.0"
}