-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlugin.cs
More file actions
151 lines (131 loc) · 4.62 KB
/
Copy pathPlugin.cs
File metadata and controls
151 lines (131 loc) · 4.62 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using ZeepkistClient;
using ZeepkistNetworking;
using ZeepSDK.Storage;
namespace BrokenTracks;
[BepInPlugin(MyPluginInfo.PLUGIN_GUID, MyPluginInfo.PLUGIN_NAME, MyPluginInfo.PLUGIN_VERSION)]
[BepInDependency("ZeepSDK")]
public class Plugin : BaseUnityPlugin
{
private Harmony harmony;
public static Plugin Instance;
public static IModStorage storage;
public ConfigEntry<bool> modEnabled;
public ConfigEntry<bool> autoSkipEnabled;
public ConfigEntry<bool> autoNextEnabled;
public ConfigEntry<float> warningDuration;
public static ConfigEntry<bool> clearBrokenTracks;
public ConfigEntry<bool> debugEnabled;
private void Awake()
{
harmony = new Harmony(MyPluginInfo.PLUGIN_GUID);
harmony.PatchAll();
//Not Needed right now
//ZeepSDK.Chat.ChatApi.ChatMessageReceived += BTCore.OnChatMessageReceived;
//ZeepkistNetwork.ChatMessageReceived += BTCore.OnChatMessageReceived2;
Instance = this;
ConfigSetup();
storage = StorageApi.CreateModStorage(this);
BTCore.loadData(); // load all saved data
// Plugin startup logic
Logger.LogInfo($"Plugin {MyPluginInfo.PLUGIN_GUID} is loaded!");
}
private void OnDestroy()
{
harmony?.UnpatchSelf();
harmony = null;
}
private void ConfigSetup()
{
modEnabled = Config.Bind("1. General", "Plugin Enabled", true, "Is the plugin currently enabled?");
autoSkipEnabled = Config.Bind("1. General", "Auto-Skip after broken", true, "Auto-Skips to the next intened track if A05 is loaded due to a broken track.");
autoNextEnabled = Config.Bind("1. General", "Auto-Set next map if broken detected", true, "Auto-sets to the next working map in the playlist if the next map is broken.");
warningDuration = Config.Bind("1. General", "Broken Track warning duration", 5f, "How long the warning message shows up for.");
clearBrokenTracks = Config.Bind("9. Dev / Debug", "Delete saved broken tracks", false, "[Button] Deletes all broken track information.");
clearBrokenTracks.SettingChanged += BTCore.ClearBrokenTracks;
debugEnabled = Config.Bind("9. Dev / Debug", "Debug Logs", false, "Provides extra output in logs for troubleshooting.");
}
/*
* Level 0 - info/normal
* Level 1 - Warning
* Level 2 - Debug
* Level 3 - Error
*/
public void Log(string message, int level = 0)
{
switch (level)
{
default:
case 0:
Logger.LogInfo(message);
break;
case 1:
Logger.LogWarning(message);
break;
case 2:
if (Plugin.Instance.debugEnabled.Value)
Logger.LogDebug(message);
break;
case 3:
Logger.LogError(message);
break;
}
}
[HarmonyPatch(typeof(PlaylistListItem), "DrawListItem")]
public class SetupPlaylistDrawItem
{
public static void Postfix(PlaylistListItem __instance, OnlineZeeplevel newZeeplevel)
{
if (Plugin.Instance.modEnabled.Value)
{
BTCore.OnDrawPlaylistItem(__instance, newZeeplevel);
}
}
}
[HarmonyPatch(typeof(PlaylistMenu), "AcceptPlaylist")]
public class SetupAcceptPlaylist
{
public static void Prefix(PlaylistMenu __instance)
{
if (Plugin.Instance.modEnabled.Value)
{
BTCore.OnAcceptPlaylist(__instance);
}
}
}
[HarmonyPatch(typeof(SetupGame), "DoStart")]
public class SetupDoStart
{
public static void Postfix()
{
if (Plugin.Instance.modEnabled.Value)
{
BTCore.OnDoStart();
}
}
}
[HarmonyPatch(typeof(ZeepkistNetwork), "OnChangeLobbyPlaylistIndex")]
public class SetupChangeLobbyPlaylistIndex
{
public static void Prefix(ChangeLobbyPlaylistIndexPacket packet)
{
if (Plugin.Instance.modEnabled.Value)
{
BTCore.OnChangeLobbyPlaylistIndex(packet);
}
}
}
[HarmonyPatch(typeof(OnlineChatUI), "SendChatMessage")]
public class SetupSendChatMessage
{
public static void Prefix(string message)
{
if (Plugin.Instance.modEnabled.Value)
{
BTCore.OnSendChatMessage(message);
}
}
}
}