-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMain.cs
More file actions
70 lines (65 loc) · 1.83 KB
/
Main.cs
File metadata and controls
70 lines (65 loc) · 1.83 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
using ModMaker;
using ModMaker.Utility;
using System;
using System.Reflection;
using UnityEngine;
using UnityModManagerNet;
namespace WrathRandomEquipment
{
#if (DEBUG)
[EnableReloading]
#endif
static class Main
{
public static LocalizationManager<DefaultLanguage> Local;
public static ModManager<Core, Settings> Mod;
public static MenuManager Menu;
public static UnityModManager.ModEntry ModEntry;
static bool Load(UnityModManager.ModEntry modEntry)
{
Local = new LocalizationManager<DefaultLanguage>();
Mod = new ModManager<Core, Settings>();
Menu = new MenuManager();
ModEntry = modEntry;
modEntry.OnToggle = OnToggle;
#if (DEBUG)
modEntry.OnUnload = Unload;
return true;
}
static bool Unload(UnityModManager.ModEntry modEntry)
{
Mod.Disable(modEntry, true);
Menu = null;
Mod = null;
Local = null;
return true;
}
#else
return true;
}
#endif
static bool OnToggle(UnityModManager.ModEntry modEntry, bool value)
{
if (value)
{
Assembly assembly = Assembly.GetExecutingAssembly();
Local.Enable(modEntry);
Mod.Enable(modEntry, assembly);
Menu.Enable(modEntry, assembly);
}
else
{
Menu.Disable(modEntry);
Mod.Disable(modEntry, false);
Local.Disable(modEntry);
ReflectionCache.Clear();
}
return true;
}
internal static Exception Error(String message)
{
Mod.Error(message);
return new InvalidOperationException(message);
}
}
}