|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- using Game.DataLoader;
- using HarmonyLib;
- using Svelto.DataStructures;
- using Svelto.ECS;
-
- namespace CLre_server.API.Engines
- {
- public abstract class ServerEnginePreBuild : ICLreEngine
- {
- public ServerEnginePreBuild()
- {
- MainGameServer_BuildDeprecatedEngines_Patch.beforeBuildEngines.Add(this);
- }
-
- public abstract void Ready();
- public abstract IEntitiesDB entitiesDB { get; set; }
- public abstract IEntityFactory entityFactory { get; set; }
- public IDataDB dataDB { get; set; }
- }
-
- public abstract class ServerEnginePostBuild : ICLreEngine
- {
- public ServerEnginePostBuild()
- {
- MainGameServer_BuildDeprecatedEngines_Patch.afterBuildEngines.Add(this);
- }
-
- public abstract void Ready();
- public abstract IEntitiesDB entitiesDB { get; set; }
- public abstract IEntityFactory entityFactory { get; set; }
- public IDataDB dataDB { get; set; }
- }
-
- [HarmonyPatch(typeof(GameServer.GameFramework.MainGameServer), "BuildDeprecatedEngines")]
- class MainGameServer_BuildDeprecatedEngines_Patch
- {
- internal static FasterList<ServerEnginePreBuild> beforeBuildEngines = new FasterList<ServerEnginePreBuild>();
-
- internal static FasterList<ServerEnginePostBuild> afterBuildEngines = new FasterList<ServerEnginePostBuild>();
-
- [HarmonyPrefix]
- public static void BeforeMethodCall(GameServer.GameFramework.MainGameServer __instance, IEntityFactory ____entityFactory)
- {
- foreach (ICLreEngine e in beforeBuildEngines)
- {
- e.entityFactory = ____entityFactory;
- __instance.AddEngine(e);
- }
- }
-
- [HarmonyPostfix]
- public static void AfterMethodCall(GameServer.GameFramework.MainGameServer __instance, IEntityFactory ____entityFactory)
- {
- foreach (ICLreEngine e in afterBuildEngines)
- {
- e.entityFactory = ____entityFactory;
- __instance.AddEngine(e);
- }
- }
- }
- }
|