TechbloxModdingAPI/GamecraftModdingAPI/Events/GameActivatedPatch.cs

33 lines
1 KiB
C#
Raw Normal View History

2019-12-14 18:52:24 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
2019-12-14 18:52:24 +00:00
using Harmony;
using RobocraftX;
using Svelto.ECS;
using GamecraftModdingAPI.Utility;
namespace GamecraftModdingAPI.Events
{
/// <summary>
/// Patch of RobocraftX.FullGameCompositionRoot.ActivateGame()
/// </summary>
[HarmonyPatch(typeof(FullGameCompositionRoot), "ActivateGame")]
class GameActivatedPatch
{
public static void Postfix(ref EnginesRoot ____mainGameEnginesRoot)
{
// register custom game engines
GameEngineManager.RegisterEngines(____mainGameEnginesRoot);
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.
2019-12-15 07:20:20 +00:00
EventManager.RegisterEngines(____mainGameEnginesRoot);
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
}
}
}