-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
ConsolePatch.cs
52 lines (46 loc) · 1.77 KB
/
ConsolePatch.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
using HarmonyLib;
namespace ExtremeRoles.Patches.MapModule
{
[HarmonyPatch(typeof(Console), nameof(Console.CanUse))]
public static class ConsoleCanUsePatch
{
public static bool Prefix(
ref float __result, Console __instance,
[HarmonyArgument(0)] GameData.PlayerInfo pc,
[HarmonyArgument(1)] out bool canUse, [HarmonyArgument(2)] out bool couldUse)
{
canUse = couldUse = false;
__result = float.MaxValue;
if (__instance == null) { return true; }
if (__instance.AllowImpostor) { return true; }
if (Roles.ExtremeRoleManager.GameRole.Count == 0) { return true; }
if (Roles.ExtremeRoleManager.GameRole[pc.PlayerId].HasTask) { return true; }
return false;
}
}
[HarmonyPatch(typeof(Console), nameof(Console.Use))]
public static class ConsoleUsePatch
{
public static bool Prefix(Console __instance)
{
if (__instance == null) { return true; }
if (Roles.ExtremeRoleManager.GameRole.Count == 0) { return true; }
PlayerControl player = PlayerControl.LocalPlayer;
PlayerTask task = __instance.FindTask(player);
if (task == null) { return true; }
switch (task.TaskType)
{
case TaskTypes.FixLights:
case TaskTypes.FixComms:
case TaskTypes.StopCharles:
case TaskTypes.ResetSeismic:
case TaskTypes.ResetReactor:
case TaskTypes.RestoreOxy:
return Roles.ExtremeRoleManager.GameRole[
player.PlayerId].CanRepairSabotage;
default:
return true;
}
}
}
}