|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Threading.Tasks;
-
- using HarmonyLib;
- using RobocraftX.CR.MainGame;
- using Svelto.ECS;
- using Unity.Entities;
-
- using GamecraftModdingAPI.Utility;
-
- namespace GamecraftModdingAPI.Events
- {
- /// <summary>
- /// Patch of RobocraftX.FullGameCompositionRoot.ActivateGame()
- /// </summary>
- [Obsolete]
- [HarmonyPatch]
- class GameActivatedComposePatch
- {
- public static bool IsGameSwitching = false;
-
- public static bool IsGameReloading = false;
-
- public static void Postfix(ref object contextHolder, ref EnginesRoot enginesRoot, World physicsWorld)
- {
- // register custom game engines
- GameEngineManager.RegisterEngines(enginesRoot);
- // initialize AsyncUtils
- AsyncUtils.Setup(enginesRoot);
- // A new EnginesRoot is always created when ActivateGame is called
- // so all event emitters and handlers must be re-registered.
- EventManager.RegisterEngines(enginesRoot);
- Logging.Log("Dispatching Game Activated event");
- EventManager.GetEventEmitter("GamecraftModdingAPIGameActivatedEventEmitter").Emit();
- if (IsGameSwitching)
- {
- IsGameSwitching = false;
- Logging.Log("Dispatching Game Switched To event");
- EventManager.GetEventEmitter("GamecraftModdingAPIGameSwitchedToEventEmitter").Emit();
- }
- if (IsGameReloading)
- {
- IsGameReloading = false;
- Logging.Log("Dispatching Game Reloaded event");
- EventManager.GetEventEmitter("GamecraftModdingAPIGameReloadedEventEmitter").Emit();
- }
- }
-
- public static MethodBase TargetMethod()
- {
- return typeof(MainGameCompositionRoot).GetMethods().First(m => m.Name == "Compose")
- .MakeGenericMethod(typeof(object));
- }
- }
- }
|