-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWaves.cs
More file actions
158 lines (126 loc) · 3.56 KB
/
Waves.cs
File metadata and controls
158 lines (126 loc) · 3.56 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
152
153
154
155
156
157
158
using System;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Waves.Features;
#pragma warning disable CS0618
[module: UnverifiableCode]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
namespace Waves;
[BepInPlugin("waves", "Waves", "1.0.0")]
public class Waves : BaseUnityPlugin
{
new internal static ManualLogSource Logger;
private WavesOptions Options;
public static int lastRound;
public static int topRound;
public Waves()
{
try
{
Logger = base.Logger;
Options = new WavesOptions(this, Logger);
}
catch (Exception ex)
{
Logger.LogError(ex);
throw;
}
}
private void OnEnable()
{
On.RainWorld.OnModsInit += RainWorldOnOnModsInit;
}
private bool IsInit;
private void RainWorldOnOnModsInit(On.RainWorld.orig_OnModsInit orig, RainWorld self)
{
orig(self);
try
{
if (IsInit) return;
RegisterEnums();
On.RainWorldGame.ShutDownProcess += RainWorldGameOnShutDownProcess;
On.GameSession.ctor += GameSessionOnctor;
MenuHooks.Apply();
ArenaHooks.Apply();
CreatureHooks.Apply();
MachineConnector.SetRegisteredOI("waves", Options);
IsInit = true;
}
catch (Exception ex)
{
Logger.LogError(ex);
throw;
}
}
private void RegisterEnums()
{
Waves.GameTypeID.RegisterValues();
}
private void RainWorldGameOnShutDownProcess(On.RainWorldGame.orig_ShutDownProcess orig, RainWorldGame self)
{
orig(self);
ClearMemory();
}
private void GameSessionOnctor(On.GameSession.orig_ctor orig, GameSession self, RainWorldGame game)
{
orig(self, game);
ClearMemory();
}
#region Quick Injects
#endregion
#region Helper Methods
private void ClearMemory()
{
//If you have any collections (lists, dictionaries, etc.)
//Clear them here to prevent a memory leak
//YourList.Clear();
}
static bool WavesModeComparison()
{
var rw = UnityEngine.Object.FindObjectOfType<RainWorld>();
return rw.processManager.arenaSetup.currentGameType == Waves.GameTypeID.WavesMode;
}
static Func<bool> CreateWavesModeComparisonDelegate()
{
return new Func<bool>(WavesModeComparison);
}
internal static string EndOfWaveMessage(int round)
{
return ""; // TODO, implement this
}
#endregion
#region Enums
public class GameTypeID
{
public static void RegisterValues()
{
Waves.GameTypeID.WavesMode = new ArenaSetup.GameTypeID("Waves", true);
}
public static void UnregisterValues()
{
if (Waves.GameTypeID.WavesMode != null)
{
Waves.GameTypeID.WavesMode.Unregister();
}
}
public static ArenaSetup.GameTypeID WavesMode;
}
public class DenEntryRule
{
public static void RegisterValues()
{
Waves.DenEntryRule.Never = new ArenaSetup.GameTypeSetup.DenEntryRule("Waves", true);
}
public static void UnregisterValues()
{
if (Waves.DenEntryRule.Never != null)
{
Waves.DenEntryRule.Never.Unregister();
}
}
public static ArenaSetup.GameTypeSetup.DenEntryRule Never;
}
#endregion
}