-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPlague.cs
More file actions
362 lines (355 loc) · 14.1 KB
/
Plague.cs
File metadata and controls
362 lines (355 loc) · 14.1 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using CodeStage.AntiCheat.Storage;
using FunPlusEssentials.CustomContent;
using FunPlusEssentials.Other;
using MelonLoader;
using UnhollowerBaseLib;
using UnityEngine;
namespace FunPlusEssentials
{
public static class Plague
{
public static bool Enabled { get; set; }
}
[RegisterTypeInIl2Cpp, UsingRPC]
public class PlagueController : MonoBehaviour
{
public PlagueController(IntPtr ptr) : base(ptr) { }
public int roundDuration;
public bool restarting, roundStarted, playersListUpdated, waitingForPlayers, roundEnded;
public bool roundTimeSet, countdownTimeSet, timeIsUp, timeOver, randomPlayersInfected, allPlayersInfected, guiFirstInfected;
public float currentTime, referenceTime, countdownTime, startTime;
public string guiFirstInfectedName = "";
public float test;
public RoomMultiplayerMenu rmm;
public List<PhotonPlayer> allPlayers, survivingPlayers;
/*private void OnPhotonSerializeView(PhotonStream stream)
{
if (stream.isWriting)
{
stream.SendNext(new Il2CppSystem.Single { m_value = test }.BoxIl2CppObject());
}
else
{
test = stream.ReceiveNext().Unbox<float>();
}
}*/
public void Start()
{
}
public void Awake()
{
allPlayers = new List<PhotonPlayer>();
survivingPlayers = new List<PhotonPlayer>();
Helper.SetProperty("joined", "true");
currentTime = 1;
startTime = (float)PhotonNetwork.time;
countdownTime = 0;
timeOver = false;
timeIsUp = false;
rmm = gameObject.GetComponent<RoomMultiplayerMenu>();
roundStarted = false;
guiFirstInfected = false;
CuteLogger.Meow("1");
if (PhotonNetwork.room.customProperties["RD004'"] != null)
{
roundDuration = PhotonNetwork.room.customProperties["RD004'"].Unbox<int>();
currentTime = roundDuration;
}
if (PhotonNetwork.isMasterClient)
{
MelonCoroutines.Start(UpdatePlayersList());
waitingForPlayers = false;
referenceTime = (float)PhotonNetwork.time;
Helper.SetRoomProperty("RefTime", new Il2CppSystem.Single { m_value = referenceTime }.BoxIl2CppObject());
CuteLogger.Meow("3");
}
else
{
if (PhotonNetwork.room.customProperties["CDTime"] != null)
{
countdownTime = PhotonNetwork.room.customProperties["CDTime"].Unbox<float>();
countdownTimeSet = true;
}
if (PhotonNetwork.room.customProperties["RefTime"] != null)
{
referenceTime = PhotonNetwork.room.customProperties["RefTime"].Unbox<float>();
roundTimeSet = true;
}
}
}
[FunRPC]
public void RestartRPC()
{
CuteLogger.Meow("RestartRPC");
MelonCoroutines.Start(RestartRound());
}
public IEnumerator RestartRound()
{
if (PhotonNetwork.player.isMasterClient)
{
//base.photonView.RPC("DestroyAllCrates", PhotonTargets.AllBuffered, new object[0]);
}
restarting = true;
// Helper.SetProperty("TeamName", "Spectators");
referenceTime = (float)PhotonNetwork.time;
if (PhotonNetwork.isMasterClient)
{
PhotonNetwork.room.IsOpen = false;
}
yield return new WaitForSeconds(10f);
if (PhotonNetwork.player.isMasterClient)
{
Helper.Room.GetComponent<PhotonView>().RPC("StartRoundRPC", PhotonTargets.AllBuffered, new Il2CppReferenceArray<Il2CppSystem.Object>(0));
}
yield break;
}
[FunRPC]
public void StartRoundRPC()
{
CuteLogger.Meow("StartRoundRPC");
if (PhotonNetwork.isMasterClient)
{
PhotonNetwork.room.IsOpen = true;
}
guiFirstInfected = false;
guiFirstInfectedName = "";
restarting = false;
roundStarted = false;
//_supplyBroadcastTime = 15f;
// _midOfRound = false;
//_isSupplyCrateDropped = false;
//_gameClassSet = false;
//TeamAName = _rmm.team_1.teamName;
//TeamBName = _rmm.team_2.teamName;
countdownTimeSet = false;
roundTimeSet = false;
timeIsUp = false;
allPlayersInfected = false;
//_gameModeName = "";
//_gameModeSet = false;
Helper.SetProperty("TeamName", "Team A");
roundDuration = Convert.ToInt32(PhotonNetwork.room.customProperties["RD004'"].Unbox<int>());
//SpawnPlayer(TeamAName);
roundEnded = false;
timeOver = false;
}
public IEnumerator UpdatePlayersList()
{
playersListUpdated = true;
foreach (PhotonPlayer player in PhotonNetwork.playerList)
{
allPlayers.Clear();
survivingPlayers.Clear();
if (Helper.GetProperty(player, "joined") != null)
{
if (Helper.GetProperty(player, "joined").ToString() == "true")
{
allPlayers.Add(player);
}
}
if (Helper.GetProperty(player, "TeamName") != null)
{
if (Helper.GetProperty(player, "TeamName").ToString() == "Team A")
{
survivingPlayers.Add(player);
}
}
}
yield return new WaitForSeconds(2f);
playersListUpdated = false;
}
public void Update()
{
Cursor.visible = rmm.IOMIAHNBDOG;
if (!playersListUpdated && PhotonNetwork.isMasterClient)
{
MelonCoroutines.Start(UpdatePlayersList());
}
countdownTime = 10f - ((float)PhotonNetwork.time - startTime);
roundStarted = (!waitingForPlayers && countdownTime <= 0f);
if (PhotonNetwork.isMasterClient && !waitingForPlayers)
{
if (roundEnded)
{
Helper.Room.GetComponent<PhotonView>().RPC("RestartRPC", PhotonTargets.All, null);
}
if ((survivingPlayers.Count == 0 && !allPlayersInfected) || (timeIsUp && !timeOver))
{
if (survivingPlayers.Count == 0 && !allPlayersInfected && !restarting)
{
// Helper.Room.GetComponent<PhotonView>().RPC("PlayInfectedWinSound", PhotonTargets.All, null);
}
if (timeIsUp && !timeOver)
{
//base.photonView.RPC("PlaySurvivorsWinSound", PhotonTargets.All, new object[0]);
}
allPlayersInfected = true;
timeOver = true;
roundEnded = true;
}
else
{
roundEnded = false;
}
}
}
public void FixedUpdate()
{
if (currentTime > 0)
{
currentTime -= Time.deltaTime;
}
if (!waitingForPlayers)
{
if (!countdownTimeSet)
{
if (PhotonNetwork.player.isMasterClient)
{
startTime = (float)PhotonNetwork.time;
Helper.SetRoomProperty("CDTime", new Il2CppSystem.Single { m_value = startTime }.BoxIl2CppObject());
countdownTimeSet = true;
//_randomPlayersInfected = false;
countdownTime = 10f;
}
else
{
startTime = (float)PhotonNetwork.time;
countdownTimeSet = true;
countdownTime = 10f;
}
}
if (!roundTimeSet && countdownTime <= 0f)
{
if (PhotonNetwork.isMasterClient)
{
referenceTime = (float)PhotonNetwork.time;
Helper.SetRoomProperty("RefTime", new Il2CppSystem.Single { m_value = referenceTime }.BoxIl2CppObject());
roundTimeSet = true;
}
else
{
referenceTime = (float)PhotonNetwork.time;
roundTimeSet = true;
}
}
}
if (PhotonNetwork.isMasterClient && waitingForPlayers)
{
referenceTime = (float)PhotonNetwork.time;
Helper.SetRoomProperty("RefTime", new Il2CppSystem.Single { m_value = referenceTime }.BoxIl2CppObject());
roundTimeSet = true;
startTime = (float)PhotonNetwork.time;
randomPlayersInfected = false;
Helper.SetRoomProperty("CDTime", new Il2CppSystem.Single { m_value = startTime }.BoxIl2CppObject());
countdownTimeSet = true;
}
if (!waitingForPlayers && countdownTime <= 0f)
{
float num = (float)PhotonNetwork.time - referenceTime;
float num2 = roundDuration - num;
if (num2 >= 0f)
{
currentTime = num2;
timeIsUp = false;
}
else
{
timeIsUp = true;
}
if (num2 < 0f && waitingForPlayers)
{
currentTime = roundDuration;
}
if (PhotonNetwork.isMasterClient && !randomPlayersInfected)
{
randomPlayersInfected = true;
//InfectRandomPlayer();
}
}
}
public void OnGUI()
{
if (!restarting)
{
GUI.color = Color.white;
GUIStyle style = new GUIStyle(rmm.BIPMFIBNFBC.label)
{
fontSize = checked(75 * (Screen.width + Screen.height)) / 6000,
alignment = TextAnchor.MiddleCenter
};
float num = (Mathf.CeilToInt(currentTime) / 60);
float num2 = (Mathf.CeilToInt(currentTime) % 60);
DrawOutline(new Rect(Screen.width / 2f, Screen.height * 0.010563f, 100f, 50f), string.Format("{0:00}:{1:00}", num, num2), 1, style);
}
else
{
GUI.color = Color.white;
GUIStyle style2 = new GUIStyle(rmm.BIPMFIBNFBC.label)
{
fontSize = checked(75 * (Screen.width + Screen.height)) / 6000,
alignment = TextAnchor.MiddleCenter
};
DrawOutline(new Rect(Screen.width / 2f, Screen.height * 0.010563f, 100f, 50f), "restarting...", 1, style2);
}
if (!roundStarted && !waitingForPlayers)
{
GUI.color = Color.white;
GUIStyle style3 = new GUIStyle(rmm.BIPMFIBNFBC.label)
{
fontSize = checked(75 * (Screen.width + Screen.height)) / 6000,
alignment = TextAnchor.MiddleCenter
};
DrawOutline(new Rect(Screen.width / 2f, Screen.height * 0.138888f, 100f, 50f), string.Format(string.Concat(new object[]
{
"{0} seconds left before round starts."
}), Mathf.CeilToInt(countdownTime)), 1, style3);
DrawOutline(new Rect(Screen.width / 2f, Screen.height * 0.010563f, 100f, 50f), string.Format(string.Concat(new object[]
{
"the virus is in the air..."
}), Mathf.CeilToInt(countdownTime)), 1, style3);
}
if (guiFirstInfected && guiFirstInfectedName != "")
{
GUI.color = Color.white;
GUIStyle style4 = new GUIStyle(rmm.BIPMFIBNFBC.label)
{
fontSize = checked(75 * (Screen.width + Screen.height)) / 6000,
alignment = TextAnchor.MiddleCenter
};
DrawOutline(new Rect(Screen.width / 2f, Screen.height * 0.138888f, 100f, 50f), guiFirstInfectedName, 1, style4);
}
}
private void DrawOutline(Rect r, string t, int strength, GUIStyle style)
{
GUI.color = new Color(0f, 0f, 0f, 1f);
checked
{
for (int i = 0 - strength; i <= strength; i++)
{
unchecked
{
GUI.Label(new Rect(r.x - strength, r.y + i, r.width, r.height), t, style);
GUI.Label(new Rect(r.x + strength, r.y + i, r.width, r.height), t, style);
}
}
for (int j = 0 - strength + 1; j <= strength - 1; j++)
{
unchecked
{
GUI.Label(new Rect(r.x + j, r.y - strength, r.width, r.height), t, style);
GUI.Label(new Rect(r.x + j, r.y + strength, r.width, r.height), t, style);
}
}
GUI.color = new Color(1f, 1f, 1f, 1f);
GUI.Label(new Rect(r.x, r.y, r.width, r.height), t, style);
}
}
}
}