-
Notifications
You must be signed in to change notification settings - Fork 5
/
LogicGameFlowNormalPatch.cs
80 lines (74 loc) · 3.03 KB
/
LogicGameFlowNormalPatch.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
using HarmonyLib;
namespace DillyzRoleApi_Rewritten
{
class LogicGameFlowNormalPatch
{
[HarmonyPatch(typeof(LogicGameFlowNormal), nameof(LogicGameFlowNormal.IsGameOverDueToDeath))]
public class LogicGameFlowNormalPatch_IsGameOverDueToDeath
{
public static bool Prefix(LogicGameFlowNormal __instance, ref bool __result)
{
foreach (CustomRole role in CustomRole.allRoles)
if (role.returnWinConditionState != null)
{
switch (role.returnWinConditionState())
{
case WinConditionState.None:
break;
case WinConditionState.GameOver:
__result = true;
role.WinGame(role.rwcsPlayer());
return false;
case WinConditionState.Hold:
__result = false;
return false;
}
}
return true;
}
}
[HarmonyPatch(typeof(LogicGameFlowNormal), nameof(LogicGameFlowNormal.CheckEndCriteria))]
public class LogicGameFlowNormalPatch_CheckEndCriteria
{
public static bool Prefix(LogicGameFlowNormal __instance)
{
if (!GameData.Instance)
return false;
// SABOTAGE WINS (no force check needed
if (SabotageBehaviour.oxygen != null && !SabotageBehaviour.oxygen.WasCollected)
{
if (SabotageBehaviour.oxygen.Countdown < 0f)
{
__instance.EndGameForSabotage();
SabotageBehaviour.oxygen.Countdown = 10000f;
return false;
}
}
if (SabotageBehaviour.reactor != null && !SabotageBehaviour.reactor.WasCollected)
{
if (SabotageBehaviour.reactor.Countdown < 0f)
{
__instance.EndGameForSabotage();
SabotageBehaviour.reactor.ClearSabotage();
return false;
}
}
foreach (CustomRole role in CustomRole.allRoles)
if (role.returnWinConditionState != null)
{
switch (role.returnWinConditionState())
{
case WinConditionState.None:
break;
case WinConditionState.GameOver:
role.WinGame(role.rwcsPlayer());
break;
case WinConditionState.Hold:
return false;
}
}
return true;
}
}
}
}