2019-12-14 04:42:55 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2019-12-16 00:35:59 +00:00
|
|
|
|
|
2019-12-14 04:42:55 +00:00
|
|
|
|
using Harmony;
|
|
|
|
|
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>
|
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
|
|
|
|
{
|
2019-12-16 00:35:59 +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);
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|