2021-03-18 18:51:13 +00:00
|
|
|
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();
|
2021-08-01 19:37:13 +01:00
|
|
|
public IEntitiesDB entitiesDB { get; set; }
|
|
|
|
public IEntityFactory entityFactory { get; set; }
|
2021-03-18 18:51:13 +00:00
|
|
|
public IDataDB dataDB { get; set; }
|
|
|
|
}
|
|
|
|
|
|
|
|
public abstract class ServerEnginePostBuild : ICLreEngine
|
|
|
|
{
|
|
|
|
public ServerEnginePostBuild()
|
|
|
|
{
|
|
|
|
MainGameServer_BuildDeprecatedEngines_Patch.afterBuildEngines.Add(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
public abstract void Ready();
|
2021-08-01 19:37:13 +01:00
|
|
|
public IEntitiesDB entitiesDB { get; set; }
|
|
|
|
public IEntityFactory entityFactory { get; set; }
|
2021-03-18 18:51:13 +00:00
|
|
|
public IDataDB dataDB { get; set; }
|
|
|
|
}
|
|
|
|
|
|
|
|
[HarmonyPatch(typeof(GameServer.GameFramework.MainGameServer), "BuildDeprecatedEngines")]
|
|
|
|
class MainGameServer_BuildDeprecatedEngines_Patch
|
|
|
|
{
|
2021-05-15 16:13:02 +01:00
|
|
|
internal static FasterList<ICLreEngine> beforeBuildEngines = new FasterList<ICLreEngine>();
|
2021-03-18 18:51:13 +00:00
|
|
|
|
2021-05-15 16:13:02 +01:00
|
|
|
internal static FasterList<ICLreEngine> afterBuildEngines = new FasterList<ICLreEngine>();
|
2021-03-18 18:51:13 +00:00
|
|
|
|
|
|
|
[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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|