40 lines
1.6 KiB
C#
40 lines
1.6 KiB
C#
|
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);
|
|||
|
}
|
|||
|
// create default event objects
|
|||
|
Manager.AddEventHandler(new SimpleEventHandlerEngine(() => { Logging.Log("App Inited event!"); },
|
|||
|
EventType.ApplicationInitialized, "appinit API debug"));
|
|||
|
Manager.AddEventEmitter(new SimpleEventEmitterEngine(EventType.ApplicationInitialized, "GamecraftModdingAPIApplicationInitializedEventEmitter"));
|
|||
|
Manager.AddEventEmitter(new SimpleEventEmitterEngine(EventType.MenuActivated, "GamecraftModdingAPIMenuActivatedEventEmitter"));
|
|||
|
Logging.Log($"{currentAssembly.GetName().Name} {currentAssembly.GetName().Version} start & patch complete");
|
|||
|
}
|
|||
|
|
|||
|
public static void Shutdown()
|
|||
|
{
|
|||
|
var currentAssembly = Assembly.GetExecutingAssembly();
|
|||
|
harmony.UnpatchAll(currentAssembly.GetName().Name);
|
|||
|
Logging.Log($"{currentAssembly.GetName().Name} {currentAssembly.GetName().Version} shutdown & unpatch complete");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|