-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInitializationPatch.cs
More file actions
28 lines (25 loc) · 888 Bytes
/
InitializationPatch.cs
File metadata and controls
28 lines (25 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using HarmonyLib;
using ProjectM;
namespace KinThrone;
[HarmonyPatch]
internal static class InitializationPatch
{
[HarmonyPatch(typeof(SpawnTeamSystem_OnPersistenceLoad), nameof(SpawnTeamSystem_OnPersistenceLoad.OnUpdate))]
[HarmonyPostfix]
static void OnUpdatePostfix()
{
try
{
Core.Initialize();
if (Core._initialized)
{
Core.Log.LogInfo($"{MyPluginInfo.PLUGIN_NAME}[{MyPluginInfo.PLUGIN_VERSION}] initialized!");
Plugin.Harmony.Unpatch(typeof(SpawnTeamSystem_OnPersistenceLoad).GetMethod("OnUpdate"), typeof(InitializationPatch).GetMethod("OnUpdatePostfix"));
}
}
catch (Exception ex)
{
Core.Log.LogError($"{MyPluginInfo.PLUGIN_NAME}[{MyPluginInfo.PLUGIN_VERSION}] failed to initialize, exiting on try-catch: {ex}");
}
}
}