2019-12-14 04:42:55 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Harmony;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using GamecraftModdingAPI.Utility;
|
|
|
|
|
using GamecraftModdingAPI.Events;
|
|
|
|
|
|
|
|
|
|
namespace GamecraftModdingAPI
|
|
|
|
|
{
|
|
|
|
|
static class Main
|
|
|
|
|
{
|
|
|
|
|
private static HarmonyInstance harmony;
|
|
|
|
|
public static void Init()
|
|
|
|
|
{
|
|
|
|
|
var currentAssembly = Assembly.GetExecutingAssembly();
|
|
|
|
|
if (harmony == null)
|
|
|
|
|
{
|
|
|
|
|
harmony = HarmonyInstance.Create(currentAssembly.GetName().Name);
|
|
|
|
|
harmony.PatchAll(currentAssembly);
|
|
|
|
|
}
|
2019-12-14 18:52:24 +00:00
|
|
|
|
// create default event emitters
|
|
|
|
|
Manager.AddEventEmitter(new SimpleEventEmitterEngine(EventType.ApplicationInitialized, "GamecraftModdingAPIApplicationInitializedEventEmitter", false));
|
|
|
|
|
Manager.AddEventEmitter(new SimpleEventEmitterEngine(EventType.Menu, "GamecraftModdingAPIMenuActivatedEventEmitter", false));
|
|
|
|
|
Manager.AddEventEmitter(new SimpleEventEmitterEngine(EventType.MenuSwitchedTo, "GamecraftModdingAPIMenuSwitchedToEventEmitter", false)); // TODO
|
|
|
|
|
Manager.AddEventEmitter(new SimpleEventEmitterEngine(EventType.Game, "GamecraftModdingAPIGameActivatedEventEmitter", false));
|
|
|
|
|
Manager.AddEventEmitter(new SimpleEventEmitterEngine(EventType.GameReloaded, "GamecraftModdingAPIGameReloadedEventEmitter", false)); // TODO
|
|
|
|
|
Manager.AddEventEmitter(new SimpleEventEmitterEngine(EventType.GameSwitchedTo, "GamecraftModdingAPIGameSwitchedToEventEmitter", false)); // TODO
|
|
|
|
|
Logging.Log($"{currentAssembly.GetName().Name} {currentAssembly.GetName().Version} init & patch complete");
|
2019-12-14 04:42:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void Shutdown()
|
|
|
|
|
{
|
|
|
|
|
var currentAssembly = Assembly.GetExecutingAssembly();
|
|
|
|
|
harmony.UnpatchAll(currentAssembly.GetName().Name);
|
|
|
|
|
Logging.Log($"{currentAssembly.GetName().Name} {currentAssembly.GetName().Version} shutdown & unpatch complete");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|