2019-12-14 18:52:24 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2020-02-08 21:05:16 +00:00
|
|
|
|
using System.Reflection;
|
2019-12-14 18:52:24 +00:00
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2019-12-16 00:35:59 +00:00
|
|
|
|
|
2019-12-14 18:52:24 +00:00
|
|
|
|
using Harmony;
|
|
|
|
|
using RobocraftX;
|
|
|
|
|
using Svelto.ECS;
|
|
|
|
|
|
|
|
|
|
using GamecraftModdingAPI.Utility;
|
2020-02-08 21:05:16 +00:00
|
|
|
|
using RobocraftX.CR.MainGame;
|
2019-12-14 18:52:24 +00:00
|
|
|
|
|
|
|
|
|
namespace GamecraftModdingAPI.Events
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Patch of RobocraftX.FullGameCompositionRoot.ActivateGame()
|
|
|
|
|
/// </summary>
|
2020-02-08 21:05:16 +00:00
|
|
|
|
[HarmonyPatch]
|
2019-12-14 18:52:24 +00:00
|
|
|
|
class GameActivatedPatch
|
|
|
|
|
{
|
2020-02-08 21:05:16 +00:00
|
|
|
|
public static void Postfix(ref EnginesRoot enginesRoot)
|
2019-12-14 18:52:24 +00:00
|
|
|
|
{
|
2019-12-16 00:35:59 +00:00
|
|
|
|
// register custom game engines
|
2020-02-08 21:05:16 +00:00
|
|
|
|
GameEngineManager.RegisterEngines(enginesRoot);
|
2019-12-14 18:52:24 +00:00
|
|
|
|
// A new EnginesRoot is always created when ActivateGame is called
|
|
|
|
|
// so all event emitters and handlers must be re-registered.
|
2020-02-08 21:05:16 +00:00
|
|
|
|
EventManager.RegisterEngines(enginesRoot);
|
2019-12-14 18:52:24 +00:00
|
|
|
|
Logging.Log("Dispatching Game Activated event");
|
2019-12-15 07:20:20 +00:00
|
|
|
|
EventManager.GetEventEmitter("GamecraftModdingAPIGameActivatedEventEmitter").Emit();
|
2019-12-14 18:52:24 +00:00
|
|
|
|
}
|
2020-02-08 21:05:16 +00:00
|
|
|
|
|
|
|
|
|
public static MethodBase TargetMethod()
|
|
|
|
|
{
|
|
|
|
|
return typeof(MainGameCompositionRoot).GetMethods().First(m => m.Name == "Compose")
|
|
|
|
|
.MakeGenericMethod(typeof(object));
|
|
|
|
|
}
|
2019-12-14 18:52:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|