-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModEntry.cs
More file actions
96 lines (76 loc) · 2.08 KB
/
ModEntry.cs
File metadata and controls
96 lines (76 loc) · 2.08 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#region global using directives
global using System;
global using System.Collections.Generic;
global using UnityEngine;
global using UnityModManagerNet;
global using HarmonyLib;
#endregion
#region global using aliases
global using Utilities = VanityCameraTweaks.Framework.Classes.Utilities;
#endregion
#region local using directives
using System.Diagnostics;
using VanityCameraTweaks.Framework.Integrations.UMM;
#endregion
namespace VanityCameraTweaks;
internal static class ModEntry
{
internal static bool ModEnabledState { get; set; } = false;
internal static Settings SettingsInstance { get; set; } = null!;
internal static UnityModManager.ModEntry.ModLogger LoggerInstance { get; set; } = null!;
internal static Harmony HarmonyInstance { get; set; } = null!;
[Conditional("DEBUG")]
internal static void DebugLog(string message)
{
LoggerInstance?.Log($"(Debug) {message}");
}
internal static void Log(string message)
{
LoggerInstance?.Log(message);
}
internal static void LogError(Exception exception)
{
LoggerInstance?.Log($"{exception} \n {exception.StackTrace}");
}
internal static bool Load(UnityModManager.ModEntry modEntry)
{
try
{
AssignEvents(modEntry);
Initialise(modEntry);
}
catch(Exception exception)
{
LogError(exception);
throw exception;
}
return true;
}
internal static void OnGUI(UnityModManager.ModEntry modEntry)
{
Builder.Build();
}
internal static void OnSaveGUI(UnityModManager.ModEntry modEntry)
{
SettingsInstance.Save(modEntry);
}
internal static void Initialise(UnityModManager.ModEntry modEntry)
{
LoggerInstance = modEntry.Logger;
SettingsInstance = Settings.Load<Settings>(modEntry);
HarmonyInstance = new Harmony(modEntry.Info.Id);
HarmonyInstance.PatchAll();
}
internal static void AssignEvents(UnityModManager.ModEntry modEntry)
{
modEntry.OnToggle = OnToggle;
modEntry.OnSaveGUI = OnSaveGUI;
modEntry.OnToggle = OnToggle;
modEntry.OnGUI = OnGUI;
}
internal static bool OnToggle(UnityModManager.ModEntry modEntry, bool toggleState)
{
ModEnabledState = toggleState;
return true;
}
};