-
-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathBootstrap.cs
More file actions
48 lines (41 loc) · 1.28 KB
/
Bootstrap.cs
File metadata and controls
48 lines (41 loc) · 1.28 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using BepInEx.Logging;
using Bloodcraft.Services;
using HarmonyLib;
using ProjectM.Gameplay.WarEvents;
namespace Bloodcraft;
[HarmonyPatch(typeof(WarEventRegistrySystem), nameof(WarEventRegistrySystem.RegisterWarEventEntities))]
internal static class Bootstrap
{
static ManualLogSource _logSource;
static bool _initialized;
internal static void Initialize(Harmony harmony, ManualLogSource logSource)
{
_logSource = logSource;
harmony.CreateClassProcessor(typeof(Bootstrap)).Patch();
}
[HarmonyPostfix]
static void Postfix()
{
if (_initialized)
return;
_initialized = true;
try
{
Core.OnInitialize();
StartupStateService.Mark(StartupState.BootstrapFired);
if (StartupStateService.IsReady())
{
_logSource.LogInfo($"Startup checks passed. {StartupStateService.BuildSummary()}");
}
else
{
_logSource.LogWarning($"Startup checks failed after bootstrap. {StartupStateService.BuildSummary()}");
}
_logSource.LogInfo($"Initialized [{MyPluginInfo.PLUGIN_VERSION}]");
}
catch (Exception ex)
{
_logSource.LogError($"{ex}");
}
}
}