-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMod.cs
112 lines (94 loc) · 3.63 KB
/
Mod.cs
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
using Kitchen;
using KitchenMods;
using PreferenceSystem;
using PreferenceSystem.Event;
// Namespace should have "Kitchen" in the beginning
namespace KitchenOverstocked
{
public class Mod : IModInitializer
{
// GUID must be unique and is recommended to be in reverse domain name notation
// Mod Name is displayed to the player and listed in the mods menu
// Mod Version must follow semver notation e.g. "1.2.3"
public const string MOD_GUID = "com.stonepaw.overstocked";
public const string MOD_NAME = "Overstocked";
public const string MOD_VERSION = "2.0.0";
public const string MOD_AUTHOR = "Stonepaw";
public const string MOD_GAMEVERSION = ">=1.2.0";
// Boolean constant whose value depends on whether you built with DEBUG or RELEASE mode, useful for testing
#if DEBUG
public const bool DEBUG_MODE = true;
#else
public const bool DEBUG_MODE = false;
#endif
public static PreferenceSystemManager PrefManager;
public static bool AutoRestock
{
get { return PrefManager.Get<bool>(AutoRestockKey); }
}
private static readonly string AutoRestockKey = "auto_restock";
public static bool DestroyCratesEnabled
{
get { return PrefManager.Get<bool>(DestroyCratesEnabledKey); }
}
private static readonly string DestroyCratesEnabledKey = "destroy_crates_enabled";
public Mod() { }
public void PostActivate(KitchenMods.Mod mod)
{
PrefManager = new PreferenceSystemManager(MOD_GUID, MOD_NAME);
// Register our custom ordering sub menu
Events.PlayerPauseView_SetupMenusEvent += (s, args) =>
{
args.addMenu.Invoke(
args.instance,
new object[]
{
typeof(OverstockedMenu<MenuAction>),
new OverstockedMenu<MenuAction>(
args.instance.ButtonContainer,
args.module_list
),
}
);
};
// Build the preferences system menu
PrefManager
.AddLabel("Auto Restock")
.AddOption(
AutoRestockKey,
true,
new bool[] { false, true },
new string[] { "Disabled", "Enabled" }
)
.AddLabel("Destroy Crates with Act")
.AddOption(
DestroyCratesEnabledKey,
false,
new bool[] { false, true },
new string[] { "Disabled", "Enabled" }
)
.AddLabel("Order Additional Crates")
.AddSelfRegisteredSubmenu<OverstockedMenu<MenuAction>>("Order")
.AddInfo(
"Ordered or destroyed crates are not saved automatically. Start a restaurant or combine crates to save the changes to the workshop."
);
PrefManager.RegisterMenu(PreferenceSystemManager.MenuType.PauseMenu);
}
public void PreInject() { }
public void PostInject() { }
#region Logging
internal static void LogInfo(string _log)
{
Debug.Log($"[{MOD_NAME}] " + _log);
}
internal static void LogWarning(string _log)
{
Debug.LogWarning($"[{MOD_NAME}] " + _log);
}
internal static void LogError(string _log)
{
Debug.LogError($"[{MOD_NAME}] " + _log);
}
#endregion
}
}