|
|
@@ -1,6 +1,7 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Reflection; |
|
|
|
using System.Text; |
|
|
|
using System.Threading.Tasks; |
|
|
|
|
|
|
@@ -9,24 +10,31 @@ using RobocraftX; |
|
|
|
using Svelto.ECS; |
|
|
|
|
|
|
|
using GamecraftModdingAPI.Utility; |
|
|
|
using RobocraftX.CR.MainGame; |
|
|
|
|
|
|
|
namespace GamecraftModdingAPI.Events |
|
|
|
{ |
|
|
|
/// <summary> |
|
|
|
/// Patch of RobocraftX.FullGameCompositionRoot.ActivateGame() |
|
|
|
/// </summary> |
|
|
|
[HarmonyPatch(typeof(FullGameCompositionRoot), "ActivateGame")] |
|
|
|
[HarmonyPatch] |
|
|
|
class GameActivatedPatch |
|
|
|
{ |
|
|
|
public static void Postfix(ref EnginesRoot ____mainGameEnginesRoot) |
|
|
|
public static void Postfix(ref EnginesRoot enginesRoot) |
|
|
|
{ |
|
|
|
// register custom game engines |
|
|
|
GameEngineManager.RegisterEngines(____mainGameEnginesRoot); |
|
|
|
GameEngineManager.RegisterEngines(enginesRoot); |
|
|
|
// A new EnginesRoot is always created when ActivateGame is called |
|
|
|
// so all event emitters and handlers must be re-registered. |
|
|
|
EventManager.RegisterEngines(____mainGameEnginesRoot); |
|
|
|
EventManager.RegisterEngines(enginesRoot); |
|
|
|
Logging.Log("Dispatching Game Activated event"); |
|
|
|
EventManager.GetEventEmitter("GamecraftModdingAPIGameActivatedEventEmitter").Emit(); |
|
|
|
} |
|
|
|
|
|
|
|
public static MethodBase TargetMethod() |
|
|
|
{ |
|
|
|
return typeof(MainGameCompositionRoot).GetMethods().First(m => m.Name == "Compose") |
|
|
|
.MakeGenericMethod(typeof(object)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |