TechbloxModdingAPI/GamecraftModdingAPI/Events/MenuActivatedPatch.cs

44 lines
1.5 KiB
C#
Raw Normal View History

2019-12-14 04:42:55 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
2020-05-03 19:31:09 +00:00
using HarmonyLib;
2019-12-14 04:42:55 +00:00
using RobocraftX;
using Svelto.ECS;
using GamecraftModdingAPI.Utility;
namespace GamecraftModdingAPI.Events
{
2019-12-14 18:52:24 +00:00
/// <summary>
/// Patch of RobocraftX.FullGameCompositionRoot.ActivateMenu()
/// </summary>
2020-08-03 02:39:26 +00:00
[Obsolete]
2019-12-14 04:42:55 +00:00
[HarmonyPatch(typeof(FullGameCompositionRoot), "ActivateMenu")]
2019-12-14 18:52:24 +00:00
class MenuActivatedPatch
2019-12-14 04:42:55 +00:00
{
private static bool firstLoad = true;
2019-12-17 01:55:52 +00:00
public static void Postfix(ref EnginesRoot ____frontEndEnginesRoot, FullGameCompositionRoot __instance)
2019-12-14 04:42:55 +00:00
{
// register custom menu engines
MenuEngineManager.RegisterEngines(____frontEndEnginesRoot);
2019-12-14 04:42:55 +00:00
// A new EnginesRoot is always created when ActivateMenu is called
// so all event emitters and handlers must be re-registered.
2019-12-15 07:20:20 +00:00
EventManager.RegisterEngines(____frontEndEnginesRoot);
2019-12-14 04:42:55 +00:00
if (firstLoad)
{
firstLoad = false;
2019-12-17 01:55:52 +00:00
FullGameFields.Init(__instance);
2020-06-13 19:23:52 +00:00
//Application.Application.SetFullGameCompositionRoot(__instance);
2019-12-14 04:42:55 +00:00
Logging.Log("Dispatching App Init event");
2019-12-15 07:20:20 +00:00
EventManager.GetEventEmitter("GamecraftModdingAPIApplicationInitializedEventEmitter").Emit();
2019-12-14 04:42:55 +00:00
}
Logging.Log("Dispatching Menu Activated event");
2019-12-15 07:20:20 +00:00
EventManager.GetEventEmitter("GamecraftModdingAPIMenuActivatedEventEmitter").Emit();
2019-12-14 04:42:55 +00:00
}
}
}