From 9c860e5e885cd9f8a20662799e42641d2b9ffb59 Mon Sep 17 00:00:00 2001 From: twix <91138333+whichtwix@users.noreply.github.com> Date: Fri, 11 Aug 2023 18:00:47 +0600 Subject: [PATCH 1/2] clarify tuple naming --- .../CrewmateRoles/DetectiveMod/PerformKill.cs | 8 +- .../Patches/CrewmateRoles/MedicMod/Protect.cs | 2 +- .../CrewmateRoles/OracleMod/PerformKill.cs | 8 +- .../CrewmateRoles/SeerMod/PerformKill.cs | 8 +- .../CrewmateRoles/TrackerMod/PerformKill.cs | 8 +- .../VampireHunterMod/PerformKill.cs | 14 +-- .../CultistRoles/WhispererMod/PerformKill.cs | 17 ++-- .../CultistRoles/WhispererMod/TargetColor.cs | 11 +-- .../BlackmailerMod/PerformKill.cs | 2 +- .../ImpostorRoles/MinerMod/PerformKill.cs | 2 +- .../NeutralRoles/ArsonistMod/PerformKill.cs | 16 ++-- .../NeutralRoles/DoomsayerMod/PerformKill.cs | 8 +- .../NeutralRoles/JuggernautMod/PerformKill.cs | 10 +- .../NeutralRoles/PestilenceMod/PerformKill.cs | 10 +- .../PlaguebearerMod/PerformKill.cs | 6 +- .../NeutralRoles/VampireMod/PerformKill.cs | 18 ++-- .../NeutralRoles/WerewolfMod/PerformKill.cs | 10 +- source/Patches/Roles/Cultist/Whisperer.cs | 9 +- source/Patches/Roles/Glitch.cs | 18 ++-- source/Patches/RpcHandling.cs | 93 ++++++++++--------- source/Patches/StopImpKill.cs | 10 +- source/Patches/SubmergedCompatibility.cs | 30 +++--- source/Patches/Utils.cs | 67 ++++++------- 23 files changed, 190 insertions(+), 195 deletions(-) diff --git a/source/Patches/CrewmateRoles/DetectiveMod/PerformKill.cs b/source/Patches/CrewmateRoles/DetectiveMod/PerformKill.cs index bf74291a4..9afad22fa 100644 --- a/source/Patches/CrewmateRoles/DetectiveMod/PerformKill.cs +++ b/source/Patches/CrewmateRoles/DetectiveMod/PerformKill.cs @@ -30,23 +30,23 @@ public static bool Prefix(KillButton __instance) PlayerControl.LocalPlayer.GetTruePosition()) > maxDistance) return false; if (role.ClosestPlayer == null) return false; var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer); - if (interact[4] == true) + if (interact.abilityUsed) { if (role.ClosestPlayer == role.DetectedKiller) Coroutines.Start(Utils.FlashCoroutine(Color.red)); else Coroutines.Start(Utils.FlashCoroutine(Color.green)); } - if (interact[0] == true) + if (interact.fullCooldownReset) { role.LastExamined = DateTime.UtcNow; return false; } - else if (interact[1] == true) + else if (interact.gaReset) { role.LastExamined = DateTime.UtcNow; role.LastExamined = role.LastExamined.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.ExamineCd); return false; } - else if (interact[3] == true) return false; + else if (interact.zeroSecReset) return false; return false; } else diff --git a/source/Patches/CrewmateRoles/MedicMod/Protect.cs b/source/Patches/CrewmateRoles/MedicMod/Protect.cs index 693bdc367..d47bb08f2 100644 --- a/source/Patches/CrewmateRoles/MedicMod/Protect.cs +++ b/source/Patches/CrewmateRoles/MedicMod/Protect.cs @@ -20,7 +20,7 @@ public static bool Prefix(KillButton __instance) if (role.StartTimer() > 0) return false; var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer); - if (interact[4] == true) + if (interact.abilityUsed) { Utils.Rpc(CustomRPC.Protect, PlayerControl.LocalPlayer.PlayerId, role.ClosestPlayer.PlayerId); diff --git a/source/Patches/CrewmateRoles/OracleMod/PerformKill.cs b/source/Patches/CrewmateRoles/OracleMod/PerformKill.cs index 6535bed37..9c991267f 100644 --- a/source/Patches/CrewmateRoles/OracleMod/PerformKill.cs +++ b/source/Patches/CrewmateRoles/OracleMod/PerformKill.cs @@ -26,7 +26,7 @@ public static bool Prefix(KillButton __instance) if (role.ClosestPlayer == null) return false; var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer); - if (interact[4] == true) + if (interact.abilityUsed) { role.Confessor = role.ClosestPlayer; bool showsCorrectFaction = true; @@ -55,18 +55,18 @@ public static bool Prefix(KillButton __instance) else role.RevealedFaction = Faction.Impostors; Utils.Rpc(CustomRPC.Confess, PlayerControl.LocalPlayer.PlayerId, role.Confessor.PlayerId, faction); } - if (interact[0] == true) + if (interact.fullCooldownReset) { role.LastConfessed = DateTime.UtcNow; return false; } - else if (interact[1] == true) + else if (interact.gaReset) { role.LastConfessed = DateTime.UtcNow; role.LastConfessed = role.LastConfessed.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.ConfessCd); return false; } - else if (interact[3] == true) return false; + else if (interact.zeroSecReset) return false; return false; } } diff --git a/source/Patches/CrewmateRoles/SeerMod/PerformKill.cs b/source/Patches/CrewmateRoles/SeerMod/PerformKill.cs index 23c9f7077..f10e50fba 100644 --- a/source/Patches/CrewmateRoles/SeerMod/PerformKill.cs +++ b/source/Patches/CrewmateRoles/SeerMod/PerformKill.cs @@ -25,22 +25,22 @@ public static bool Prefix(KillButton __instance) if (role.ClosestPlayer == null) return false; var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer); - if (interact[4] == true) + if (interact.abilityUsed) { role.Investigated.Add(role.ClosestPlayer.PlayerId); } - if (interact[0] == true) + if (interact.fullCooldownReset) { role.LastInvestigated = DateTime.UtcNow; return false; } - else if (interact[1] == true) + else if (interact.gaReset) { role.LastInvestigated = DateTime.UtcNow; role.LastInvestigated = role.LastInvestigated.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.SeerCd); return false; } - else if (interact[3] == true) return false; + else if (interact.zeroSecReset) return false; return false; } } diff --git a/source/Patches/CrewmateRoles/TrackerMod/PerformKill.cs b/source/Patches/CrewmateRoles/TrackerMod/PerformKill.cs index 598a3c2c1..b4fd071db 100644 --- a/source/Patches/CrewmateRoles/TrackerMod/PerformKill.cs +++ b/source/Patches/CrewmateRoles/TrackerMod/PerformKill.cs @@ -28,7 +28,7 @@ public static bool Prefix(KillButton __instance) if (!role.ButtonUsable) return false; var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer); - if (interact[4] == true) + if (interact.abilityUsed) { var gameObj = new GameObject(); var arrow = gameObj.AddComponent(); @@ -53,18 +53,18 @@ public static bool Prefix(KillButton __instance) role.TrackerArrows.Add(target.PlayerId, arrow); role.UsesLeft--; } - if (interact[0] == true) + if (interact.fullCooldownReset) { role.LastTracked = DateTime.UtcNow; return false; } - else if (interact[1] == true) + else if (interact.gaReset) { role.LastTracked = DateTime.UtcNow; role.LastTracked = role.LastTracked.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.TrackCd); return false; } - else if (interact[3] == true) return false; + else if (interact.zeroSecReset) return false; return false; } } diff --git a/source/Patches/CrewmateRoles/VampireHunterMod/PerformKill.cs b/source/Patches/CrewmateRoles/VampireHunterMod/PerformKill.cs index ace78d73b..ca1e0f3a3 100644 --- a/source/Patches/CrewmateRoles/VampireHunterMod/PerformKill.cs +++ b/source/Patches/CrewmateRoles/VampireHunterMod/PerformKill.cs @@ -27,7 +27,7 @@ public static bool Prefix(KillButton __instance) if (!role.ClosestPlayer.Is(RoleEnum.Vampire)) { var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer); - if (interact[0] == true) + if (interact.fullCooldownReset) { role.LastStaked = DateTime.UtcNow; role.UsesLeft--; @@ -35,31 +35,31 @@ public static bool Prefix(KillButton __instance) Utils.RpcMurderPlayer(PlayerControl.LocalPlayer, PlayerControl.LocalPlayer); return false; } - else if (interact[1] == true) + else if (interact.gaReset) { role.LastStaked = DateTime.UtcNow; role.LastStaked = role.LastStaked.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.StakeCd); return false; } - else if (interact[3] == true) return false; + else if (interact.zeroSecReset) return false; return false; } else { var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer, true); - if (interact[4] == true) return false; - else if (interact[0] == true) + if (interact.abilityUsed) return false; + else if (interact.fullCooldownReset) { role.LastStaked = DateTime.UtcNow; return false; } - else if (interact[1] == true) + else if (interact.gaReset) { role.LastStaked = DateTime.UtcNow; role.LastStaked = role.LastStaked.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.StakeCd); return false; } - else if (interact[3] == true) return false; + else if (interact.zeroSecReset) return false; return false; } } diff --git a/source/Patches/CultistRoles/WhispererMod/PerformKill.cs b/source/Patches/CultistRoles/WhispererMod/PerformKill.cs index 58498a35c..03286e8a8 100644 --- a/source/Patches/CultistRoles/WhispererMod/PerformKill.cs +++ b/source/Patches/CultistRoles/WhispererMod/PerformKill.cs @@ -1,5 +1,4 @@ using HarmonyLib; -using Hazel; using TownOfUs.Roles; using TownOfUs.Roles.Cultist; using UnityEngine; @@ -31,16 +30,16 @@ public static bool Prefix(KillButton __instance) var closestPlayers = Utils.GetClosestPlayers(truePosition, CustomGameOptions.WhisperRadius, false); if (role.PlayerConversion.Count == 0) role.PlayerConversion = role.GetPlayers(); var oldStats = role.PlayerConversion; - role.PlayerConversion = new List<(PlayerControl, int)>(); + role.PlayerConversion = []; foreach (var conversionRate in oldStats) { - var player = conversionRate.Item1; - var stats = conversionRate.Item2; + var player = conversionRate.Player; + var stats = conversionRate.UnconvertableChance; if (closestPlayers.Contains(player)) { stats -= role.WhisperConversion; } - if (!player.Data.IsDead) role.PlayerConversion.Add((player, stats)); + if (!player.Data.IsDead) role.PlayerConversion.Add(new(player, stats)); } role.WhisperCount += 1; role.LastWhispered = DateTime.UtcNow; @@ -52,17 +51,17 @@ public static bool Prefix(KillButton __instance) public static void CheckConversion(Whisperer role) { - var removals = new List<(PlayerControl, int)>(); + var removals = new List(); foreach (var playerConversion in role.PlayerConversion) { - if (playerConversion.Item2 <= 0) + if (playerConversion.UnconvertableChance <= 0) { - Utils.Convert(playerConversion.Item1); + Utils.Convert(playerConversion.Player); role.ConversionCount += 1; role.WhisperConversion -= CustomGameOptions.DecreasedPercentagePerConversion; if (role.WhisperConversion < 5) role.WhisperConversion = 5; - Utils.Rpc(CustomRPC.Convert, playerConversion.Item1.PlayerId); + Utils.Rpc(CustomRPC.Convert, playerConversion.Player.PlayerId); removals.Add(playerConversion); } } diff --git a/source/Patches/CultistRoles/WhispererMod/TargetColor.cs b/source/Patches/CultistRoles/WhispererMod/TargetColor.cs index ac6ddca50..b23dd6846 100644 --- a/source/Patches/CultistRoles/WhispererMod/TargetColor.cs +++ b/source/Patches/CultistRoles/WhispererMod/TargetColor.cs @@ -3,7 +3,6 @@ using TownOfUs.Roles; using TownOfUs.Roles.Cultist; using UnityEngine; -using static UnityEngine.ParticleSystem.PlaybackState; namespace TownOfUs.CultistRoles.WhispererMod { @@ -31,8 +30,8 @@ private static void UpdateMeeting(MeetingHud __instance) { foreach (var state in __instance.playerStates) { - if (stats.Item1.PlayerId != state.TargetPlayerId) continue; - float color = stats.Item2 / 100f; + if (stats.Player.PlayerId != state.TargetPlayerId) continue; + float color = stats.UnconvertableChance / 100f; if (color <= 0) state.NameText.color = Patches.Colors.Impostor; else state.NameText.color = new Color(1f, 1f, color, 1f); } @@ -61,9 +60,9 @@ private static void Postfix(HudManager __instance) foreach (var stats in role.PlayerConversion) { - float color = stats.Item2/100f; - if (color <= 0) stats.Item1.nameText().color = Patches.Colors.Impostor; - else stats.Item1.nameText().color = new Color(1f, 1f, color, 1f); + float color = stats.UnconvertableChance/100f; + if (color <= 0) stats.Player.nameText().color = Patches.Colors.Impostor; + else stats.Player.nameText().color = new Color(1f, 1f, color, 1f); } } } diff --git a/source/Patches/ImpostorRoles/BlackmailerMod/PerformKill.cs b/source/Patches/ImpostorRoles/BlackmailerMod/PerformKill.cs index e4e372805..e01daa5e7 100644 --- a/source/Patches/ImpostorRoles/BlackmailerMod/PerformKill.cs +++ b/source/Patches/ImpostorRoles/BlackmailerMod/PerformKill.cs @@ -24,7 +24,7 @@ public static bool Prefix(KillButton __instance) if (role.BlackmailTimer() != 0) return false; var interact = Utils.Interact(PlayerControl.LocalPlayer, target); - if (interact[4] == true) + if (interact.abilityUsed) { role.Blackmailed?.myRend().material.SetFloat("_Outline", 0f); if (role.Blackmailed != null && role.Blackmailed.Data.IsImpostor()) diff --git a/source/Patches/ImpostorRoles/MinerMod/PerformKill.cs b/source/Patches/ImpostorRoles/MinerMod/PerformKill.cs index 452221ba2..c1e34598f 100644 --- a/source/Patches/ImpostorRoles/MinerMod/PerformKill.cs +++ b/source/Patches/ImpostorRoles/MinerMod/PerformKill.cs @@ -26,7 +26,7 @@ public static bool Prefix(KillButton __instance) if (!__instance.isActiveAndEnabled) return false; if (!role.CanPlace) return false; if (role.MineTimer() != 0) return false; - if (SubmergedCompatibility.GetPlayerElevator(PlayerControl.LocalPlayer).Item1) return false; + if (SubmergedCompatibility.GetPlayerElevator(PlayerControl.LocalPlayer).atTopFloor) return false; var position = PlayerControl.LocalPlayer.transform.position; var id = GetAvailableId(); Utils.Rpc(CustomRPC.Mine, id, PlayerControl.LocalPlayer.PlayerId, position, position.z + 0.001f); diff --git a/source/Patches/NeutralRoles/ArsonistMod/PerformKill.cs b/source/Patches/NeutralRoles/ArsonistMod/PerformKill.cs index 4b911c2ae..28f2ebe52 100644 --- a/source/Patches/NeutralRoles/ArsonistMod/PerformKill.cs +++ b/source/Patches/NeutralRoles/ArsonistMod/PerformKill.cs @@ -30,19 +30,19 @@ public static bool Prefix(KillButton __instance) if (!role.DousedPlayers.Contains(role.ClosestPlayerIgnite.PlayerId)) return false; var interact2 = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayerIgnite); - if (interact2[4] == true) role.Ignite(); - if (interact2[0] == true) + if (interact2.abilityUsed) role.Ignite(); + if (interact2.fullCooldownReset) { role.LastDoused = DateTime.UtcNow; return false; } - else if (interact2[1] == true) + else if (interact2.gaReset) { role.LastDoused = DateTime.UtcNow; role.LastDoused.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.DouseCd); return false; } - else if (interact2[3] == true) return false; + else if (interact2.zeroSecReset) return false; return false; } else return false; @@ -57,19 +57,19 @@ public static bool Prefix(KillButton __instance) if (!flag2) return false; if (role.DousedPlayers.Contains(role.ClosestPlayerDouse.PlayerId)) return false; var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayerDouse); - if (interact[4] == true) role.DousedPlayers.Add(role.ClosestPlayerDouse.PlayerId); - if (interact[0] == true) + if (interact.abilityUsed) role.DousedPlayers.Add(role.ClosestPlayerDouse.PlayerId); + if (interact.fullCooldownReset) { role.LastDoused = DateTime.UtcNow; return false; } - else if (interact[1] == true) + else if (interact.gaReset) { role.LastDoused = DateTime.UtcNow; role.LastDoused.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.DouseCd); return false; } - else if (interact[3] == true) return false; + else if (interact.zeroSecReset) return false; return false; } } diff --git a/source/Patches/NeutralRoles/DoomsayerMod/PerformKill.cs b/source/Patches/NeutralRoles/DoomsayerMod/PerformKill.cs index eec470a5e..af61a7076 100644 --- a/source/Patches/NeutralRoles/DoomsayerMod/PerformKill.cs +++ b/source/Patches/NeutralRoles/DoomsayerMod/PerformKill.cs @@ -23,22 +23,22 @@ public static bool Prefix(KillButton __instance) GameOptionsData.KillDistances[GameOptionsManager.Instance.currentNormalGameOptions.KillDistance]; if (!flag3) return false; var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer); - if (interact[4] == true) + if (interact.abilityUsed) { role.LastObservedPlayer = role.ClosestPlayer; } - if (interact[0] == true) + if (interact.fullCooldownReset) { role.LastObserved = DateTime.UtcNow; return false; } - else if (interact[1] == true) + else if (interact.gaReset) { role.LastObserved = DateTime.UtcNow; role.LastObserved = role.LastObserved.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.ObserveCooldown); return false; } - else if (interact[3] == true) return false; + else if (interact.zeroSecReset) return false; return false; } } diff --git a/source/Patches/NeutralRoles/JuggernautMod/PerformKill.cs b/source/Patches/NeutralRoles/JuggernautMod/PerformKill.cs index 3ae922f3a..5d471eb46 100644 --- a/source/Patches/NeutralRoles/JuggernautMod/PerformKill.cs +++ b/source/Patches/NeutralRoles/JuggernautMod/PerformKill.cs @@ -26,25 +26,25 @@ public static bool Prefix(KillButton __instance) GameOptionsData.KillDistances[GameOptionsManager.Instance.currentNormalGameOptions.KillDistance]; if (!flag3) return false; var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer, true); - if (interact[4] == true) return false; - else if (interact[0] == true) + if (interact.abilityUsed) return false; + else if (interact.fullCooldownReset) { role.LastKill = DateTime.UtcNow; return false; } - else if (interact[1] == true) + else if (interact.gaReset) { role.LastKill = DateTime.UtcNow; role.LastKill = role.LastKill.AddSeconds(-(CustomGameOptions.JuggKCd - CustomGameOptions.ReducedKCdPerKill * role.JuggKills) + CustomGameOptions.ProtectKCReset); return false; } - else if (interact[2] == true) + else if (interact.survReset) { role.LastKill = DateTime.UtcNow; role.LastKill = role.LastKill.AddSeconds(-(CustomGameOptions.JuggKCd - CustomGameOptions.ReducedKCdPerKill * role.JuggKills) + CustomGameOptions.VestKCReset); return false; } - else if (interact[3] == true) return false; + else if (interact.zeroSecReset) return false; return false; } } diff --git a/source/Patches/NeutralRoles/PestilenceMod/PerformKill.cs b/source/Patches/NeutralRoles/PestilenceMod/PerformKill.cs index 69a110c2b..198793075 100644 --- a/source/Patches/NeutralRoles/PestilenceMod/PerformKill.cs +++ b/source/Patches/NeutralRoles/PestilenceMod/PerformKill.cs @@ -24,25 +24,25 @@ public static bool Prefix(KillButton __instance) GameOptionsData.KillDistances[GameOptionsManager.Instance.currentNormalGameOptions.KillDistance]; if (!flag3) return false; var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer, true); - if (interact[4] == true) return false; - else if (interact[0] == true) + if (interact.abilityUsed) return false; + else if (interact.fullCooldownReset) { role.LastKill = DateTime.UtcNow; return false; } - else if (interact[1] == true) + else if (interact.gaReset) { role.LastKill = DateTime.UtcNow; role.LastKill = role.LastKill.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.PestKillCd); return false; } - else if (interact[2] == true) + else if (interact.survReset) { role.LastKill = DateTime.UtcNow; role.LastKill = role.LastKill.AddSeconds(CustomGameOptions.VestKCReset - CustomGameOptions.PestKillCd); return false; } - else if (interact[3] == true) return false; + else if (interact.zeroSecReset) return false; return false; } } diff --git a/source/Patches/NeutralRoles/PlaguebearerMod/PerformKill.cs b/source/Patches/NeutralRoles/PlaguebearerMod/PerformKill.cs index ca8d1dbbf..47d17e50c 100644 --- a/source/Patches/NeutralRoles/PlaguebearerMod/PerformKill.cs +++ b/source/Patches/NeutralRoles/PlaguebearerMod/PerformKill.cs @@ -25,18 +25,18 @@ public static bool Prefix(KillButton __instance) GameOptionsData.KillDistances[GameOptionsManager.Instance.currentNormalGameOptions.KillDistance]; if (!flag3) return false; var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer); - if (interact[0] == true) + if (interact.fullCooldownReset) { role.LastInfected = DateTime.UtcNow; return false; } - else if (interact[1] == true) + else if (interact.gaReset) { role.LastInfected = DateTime.UtcNow; role.LastInfected.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.InfectCd); return false; } - else if (interact[3] == true) return false; + else if (interact.zeroSecReset) return false; return false; } } diff --git a/source/Patches/NeutralRoles/VampireMod/PerformKill.cs b/source/Patches/NeutralRoles/VampireMod/PerformKill.cs index e7c7a5d77..54cf51565 100644 --- a/source/Patches/NeutralRoles/VampireMod/PerformKill.cs +++ b/source/Patches/NeutralRoles/VampireMod/PerformKill.cs @@ -50,47 +50,47 @@ public static bool Prefix(KillButton __instance) aliveVamps.Count == 1 && vamps.Count < CustomGameOptions.MaxVampiresPerGame) { var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer); - if (interact[4] == true) + if (interact.abilityUsed) { Convert(role.ClosestPlayer); Utils.Rpc(CustomRPC.Bite, role.ClosestPlayer.PlayerId); } - if (interact[0] == true) + if (interact.fullCooldownReset) { role.LastBit = DateTime.UtcNow; return false; } - else if (interact[1] == true) + else if (interact.gaReset) { role.LastBit = DateTime.UtcNow; role.LastBit = role.LastBit.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.BiteCd); return false; } - else if (interact[3] == true) return false; + else if (interact.zeroSecReset) return false; return false; } else { var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer, true); - if (interact[4] == true) return false; - if (interact[0] == true) + if (interact.abilityUsed) return false; + if (interact.fullCooldownReset) { role.LastBit = DateTime.UtcNow; return false; } - else if (interact[1] == true) + else if (interact.gaReset) { role.LastBit = DateTime.UtcNow; role.LastBit = role.LastBit.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.BiteCd); return false; } - else if (interact[2] == true) + else if (interact.survReset) { role.LastBit = DateTime.UtcNow; role.LastBit = role.LastBit.AddSeconds(CustomGameOptions.VestKCReset - CustomGameOptions.BiteCd); return false; } - else if (interact[3] == true) return false; + else if (interact.zeroSecReset) return false; return false; } } diff --git a/source/Patches/NeutralRoles/WerewolfMod/PerformKill.cs b/source/Patches/NeutralRoles/WerewolfMod/PerformKill.cs index a461ab754..bf69cec27 100644 --- a/source/Patches/NeutralRoles/WerewolfMod/PerformKill.cs +++ b/source/Patches/NeutralRoles/WerewolfMod/PerformKill.cs @@ -38,25 +38,25 @@ public static bool Prefix(KillButton __instance) if (!flag3) return false; var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer, true); - if (interact[4] == true) return false; - else if (interact[0] == true) + if (interact.abilityUsed) return false; + else if (interact.fullCooldownReset) { role.LastKilled = DateTime.UtcNow; return false; } - else if (interact[1] == true) + else if (interact.gaReset) { role.LastKilled = DateTime.UtcNow; role.LastKilled = role.LastKilled.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.RampageKillCd); return false; } - else if (interact[2] == true) + else if (interact.survReset) { role.LastKilled = DateTime.UtcNow; role.LastKilled = role.LastKilled.AddSeconds(CustomGameOptions.VestKCReset - CustomGameOptions.RampageKillCd); return false; } - else if (interact[3] == true) return false; + else if (interact.zeroSecReset) return false; return false; } } diff --git a/source/Patches/Roles/Cultist/Whisperer.cs b/source/Patches/Roles/Cultist/Whisperer.cs index ceb3118cb..07b94d0cb 100644 --- a/source/Patches/Roles/Cultist/Whisperer.cs +++ b/source/Patches/Roles/Cultist/Whisperer.cs @@ -10,8 +10,9 @@ public class Whisperer : Role public DateTime LastWhispered; public int WhisperCount; public int ConversionCount; - public List<(PlayerControl, int)> PlayerConversion = new List<(PlayerControl, int)>(); + public List PlayerConversion = new(); public int WhisperConversion; + public record ConversionData(PlayerControl Player, int UnconvertableChance); public Whisperer(PlayerControl player) : base(player) @@ -48,15 +49,15 @@ public float WhisperTimer() return (num - (float) timeSpan.TotalMilliseconds) / 1000f; } - public List<(PlayerControl, int)> GetPlayers() + public List GetPlayers() { - var playerList = new List<(PlayerControl, int)>(); + var playerList = new List(); foreach (var player in PlayerControl.AllPlayerControls) { if (!(player.Is(RoleEnum.Sheriff) || player.Is(RoleEnum.CultistSeer) | player.Is(RoleEnum.Survivor) || player.Is(RoleEnum.Mayor) || player.Is(RoleEnum.Whisperer))) { - playerList.Add((player, 100)); + playerList.Add(new(player, 100)); } } return playerList; diff --git a/source/Patches/Roles/Glitch.cs b/source/Patches/Roles/Glitch.cs index 1b86e447c..334df29da 100644 --- a/source/Patches/Roles/Glitch.cs +++ b/source/Patches/Roles/Glitch.cs @@ -466,25 +466,25 @@ public static void KillButtonPress(Glitch __gInstance, KillButton __instance) { if (__gInstance.Player.inVent) return; var interact = Utils.Interact(__gInstance.Player, __gInstance.KillTarget, true); - if (interact[4] == true) return; - else if (interact[0] == true) + if (interact.abilityUsed) return; + else if (interact.fullCooldownReset) { __gInstance.LastKill = DateTime.UtcNow; return; } - else if (interact[1] == true) + else if (interact.gaReset) { __gInstance.LastKill = DateTime.UtcNow; __gInstance.LastKill = __gInstance.LastKill.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.GlitchKillCooldown); return; } - else if (interact[2] == true) + else if (interact.survReset) { __gInstance.LastKill = DateTime.UtcNow; __gInstance.LastKill = __gInstance.LastKill.AddSeconds(CustomGameOptions.VestKCReset - CustomGameOptions.GlitchKillCooldown); return; } - else if (interact[3] == true) return; + else if (interact.zeroSecReset) return; return; } } @@ -537,22 +537,22 @@ public static void HackButtonPress(Glitch __gInstance, KillButton __instance) if (__gInstance.HackTarget != null) { var interact = Utils.Interact(__gInstance.Player, __gInstance.HackTarget); - if (interact[4] == true) + if (interact.abilityUsed) { __gInstance.RpcSetHacked(__gInstance.HackTarget); } - if (interact[0] == true) + if (interact.fullCooldownReset) { __gInstance.LastHack = DateTime.UtcNow; return; } - else if (interact[1] == true) + else if (interact.gaReset) { __gInstance.LastHack = DateTime.UtcNow; __gInstance.LastHack.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.HackCooldown); return; } - else if (interact[3] == true) return; + else if (interact.zeroSecReset) return; return; } } diff --git a/source/Patches/RpcHandling.cs b/source/Patches/RpcHandling.cs index cf4fb3c0e..005e47daf 100644 --- a/source/Patches/RpcHandling.cs +++ b/source/Patches/RpcHandling.cs @@ -35,22 +35,25 @@ using TownOfUs.NeutralRoles.VampireMod; using TownOfUs.CrewmateRoles.MayorMod; using System.Reflection; +using RoleData = (System.Type role, int chance, bool unique); +using ModifierData = (System.Type modifier, int chance); +using AbilityData = (System.Type ability, TownOfUs.CustomRPC rpc, int chance); namespace TownOfUs { public static class RpcHandling { - private static readonly List<(Type, int, bool)> CrewmateRoles = new(); - private static readonly List<(Type, int, bool)> NeutralBenignRoles = new(); - private static readonly List<(Type, int, bool)> NeutralEvilRoles = new(); - private static readonly List<(Type, int, bool)> NeutralKillingRoles = new(); - private static readonly List<(Type, int, bool)> ImpostorRoles = new(); - private static readonly List<(Type, int)> CrewmateModifiers = new(); - private static readonly List<(Type, int)> GlobalModifiers = new(); - private static readonly List<(Type, int)> ImpostorModifiers = new(); - private static readonly List<(Type, int)> ButtonModifiers = new(); - private static readonly List<(Type, int)> AssassinModifiers = new(); - private static readonly List<(Type, CustomRPC, int)> AssassinAbility = new(); + private static readonly List CrewmateRoles = new(); + private static readonly List NeutralBenignRoles = new(); + private static readonly List NeutralEvilRoles = new(); + private static readonly List NeutralKillingRoles = new(); + private static readonly List ImpostorRoles = new(); + private static readonly List CrewmateModifiers = new(); + private static readonly List GlobalModifiers = new(); + private static readonly List ImpostorModifiers = new(); + private static readonly List ButtonModifiers = new(); + private static readonly List AssassinModifiers = new(); + private static readonly List AssassinAbility = new(); private static bool PhantomOn; private static bool HaunterOn; private static bool TraitorOn; @@ -73,21 +76,21 @@ private static void PickRoleCount(int roleCount, int min, int max) roleCount = Random.RandomRangeInt(min, max + 1); } - private static void SortRoles(List<(Type, int, bool)> roles, int numRoles) + private static void SortRoles(List roles, int numRoles) { roles.Shuffle(); if (roles.Count < numRoles) numRoles = roles.Count; roles.Sort((a, b) => { - var a_ = a.Item2 == 100 ? 0 : 100; - var b_ = b.Item2 == 100 ? 0 : 100; + var a_ = a.chance == 100 ? 0 : 100; + var b_ = b.chance == 100 ? 0 : 100; return a_.CompareTo(b_); }); var certainRoles = 0; var odds = 0; foreach (var role in roles) - if (role.Item2 == 100) certainRoles += 1; - else odds += role.Item2; + if (role.chance == 100) certainRoles += 1; + else odds += role.chance; while (certainRoles < numRoles) { var num = certainRoles; @@ -95,10 +98,10 @@ private static void SortRoles(List<(Type, int, bool)> roles, int numRoles) var rolePicked = false; while (num < roles.Count && rolePicked == false) { - random -= roles[num].Item2; + random -= roles[num].chance; if (random < 0) { - odds -= roles[num].Item2; + odds -= roles[num].chance; var role = roles[num]; roles.Remove(role); roles.Insert(0, role); @@ -111,13 +114,13 @@ private static void SortRoles(List<(Type, int, bool)> roles, int numRoles) while (roles.Count > numRoles) roles.RemoveAt(roles.Count - 1); } - private static void SortModifiers(List<(Type, int)> roles, int max) + private static void SortModifiers(List roles, int max) { roles.Shuffle(); roles.Sort((a, b) => { - var a_ = a.Item2 == 100 ? 0 : 100; - var b_ = b.Item2 == 100 ? 0 : 100; + var a_ = a.chance == 100 ? 0 : 100; + var b_ = b.chance == 100 ? 0 : 100; return a_.CompareTo(b_); }); while (roles.Count > max) roles.RemoveAt(roles.Count - 1); @@ -250,14 +253,14 @@ private static void GenEachRole(List infected) SortRoles(ImpostorRoles, impostors.Count); } - var crewAndNeutralRoles = new List<(Type, int, bool)>(); + var crewAndNeutralRoles = new List(); if (CustomGameOptions.GameMode == GameMode.Classic) crewAndNeutralRoles.AddRange(CrewmateRoles); crewAndNeutralRoles.AddRange(NeutralBenignRoles); crewAndNeutralRoles.AddRange(NeutralEvilRoles); crewAndNeutralRoles.AddRange(NeutralKillingRoles); - var crewRoles = new List<(Type, int, bool)>(); - var impRoles = new List<(Type, int, bool)>(); + var crewRoles = new List(); + var impRoles = new List(); if (CustomGameOptions.GameMode == GameMode.AllAny) { @@ -265,13 +268,13 @@ private static void GenEachRole(List infected) if (crewAndNeutralRoles.Count > 0) { crewRoles.Add(crewAndNeutralRoles[0]); - if (crewAndNeutralRoles[0].Item3 == true) crewAndNeutralRoles.Remove(crewAndNeutralRoles[0]); + if (crewAndNeutralRoles[0].unique) crewAndNeutralRoles.Remove(crewAndNeutralRoles[0]); } if (CrewmateRoles.Count > 0) { CrewmateRoles.Shuffle(); crewRoles.Add(CrewmateRoles[0]); - if (CrewmateRoles[0].Item3 == true) CrewmateRoles.Remove(CrewmateRoles[0]); + if (CrewmateRoles[0].unique) CrewmateRoles.Remove(CrewmateRoles[0]); } else { @@ -282,7 +285,7 @@ private static void GenEachRole(List infected) { crewAndNeutralRoles.Shuffle(); crewRoles.Add(crewAndNeutralRoles[0]); - if (crewAndNeutralRoles[0].Item3 == true) + if (crewAndNeutralRoles[0].unique) { if (CrewmateRoles.Contains(crewAndNeutralRoles[0])) CrewmateRoles.Remove(crewAndNeutralRoles[0]); crewAndNeutralRoles.Remove(crewAndNeutralRoles[0]); @@ -292,7 +295,7 @@ private static void GenEachRole(List infected) { ImpostorRoles.Shuffle(); impRoles.Add(ImpostorRoles[0]); - if (ImpostorRoles[0].Item3 == true) ImpostorRoles.Remove(ImpostorRoles[0]); + if (ImpostorRoles[0].unique) ImpostorRoles.Remove(ImpostorRoles[0]); } } crewRoles.Shuffle(); @@ -554,17 +557,17 @@ private static void GenEachRoleKilling(List infected) } } - var crewAndNeutralRoles = new List<(Type, int, bool)>(); + var crewAndNeutralRoles = new List(); crewAndNeutralRoles.AddRange(CrewmateRoles); crewAndNeutralRoles.AddRange(NeutralKillingRoles); crewAndNeutralRoles.Shuffle(); ImpostorRoles.Shuffle(); - foreach (var (type, _, unique) in crewAndNeutralRoles) + foreach (var (type, _, _) in crewAndNeutralRoles) { Role.GenRole(type, crewmates); } - foreach (var (type, _, unique) in ImpostorRoles) + foreach (var (type, _, _) in ImpostorRoles) { Role.GenRole(type, impostors); } @@ -576,9 +579,9 @@ private static void GenEachRoleCultist(List infected) crewmates.Shuffle(); impostors.Shuffle(); - var specialRoles = new List<(Type, int, bool)>(); - var crewRoles = new List<(Type, int, bool)>(); - var impRole = new List<(Type, int, bool)>(); + var specialRoles = new List(); + var crewRoles = new List(); + var impRole = new List(); if (CustomGameOptions.MayorCultistOn > 0) specialRoles.Add((typeof(Mayor), CustomGameOptions.MayorCultistOn, true)); if (CustomGameOptions.SeerCultistOn > 0) specialRoles.Add((typeof(CultistSeer), CustomGameOptions.SeerCultistOn, true)); if (CustomGameOptions.SheriffCultistOn > 0) specialRoles.Add((typeof(Sheriff), CustomGameOptions.SheriffCultistOn, true)); @@ -641,15 +644,15 @@ private static void GenEachRoleCultist(List infected) impRole.Add((typeof(Whisperer), 10, true)); SortRoles(impRole, 1); - foreach (var (type, _, unique) in specialRoles) + foreach (var (type, _, _) in specialRoles) { Role.GenRole(type, crewmates); } - foreach (var (type, _, unique) in crewRoles) + foreach (var (type, _, _) in crewRoles) { Role.GenRole(type, crewmates); } - foreach (var (type, _, unique) in impRole) + foreach (var (type, _, _) in impRole) { Role.GenRole(type, impostors); } @@ -1145,12 +1148,14 @@ public static void Postfix([HarmonyArgument(0)] byte callId, [HarmonyArgument(1) var oldRole = Role.GetRole(traitor); var killsList = (oldRole.CorrectKills, oldRole.IncorrectKills, oldRole.CorrectAssassinKills, oldRole.IncorrectAssassinKills); Role.RoleDictionary.Remove(traitor.PlayerId); - var traitorRole = new Traitor(traitor); - traitorRole.formerRole = oldRole.RoleType; - traitorRole.CorrectKills = killsList.CorrectKills; - traitorRole.IncorrectKills = killsList.IncorrectKills; - traitorRole.CorrectAssassinKills = killsList.CorrectAssassinKills; - traitorRole.IncorrectAssassinKills = killsList.IncorrectAssassinKills; + var traitorRole = new Traitor(traitor) + { + formerRole = oldRole.RoleType, + CorrectKills = killsList.CorrectKills, + IncorrectKills = killsList.IncorrectKills, + CorrectAssassinKills = killsList.CorrectAssassinKills, + IncorrectAssassinKills = killsList.IncorrectAssassinKills + }; traitorRole.RegenTask(); SetTraitor.TurnImp(traitor); break; @@ -1182,7 +1187,7 @@ public static void Postfix([HarmonyArgument(0)] byte callId, [HarmonyArgument(1) body.gameObject.Destroy(); break; case CustomRPC.SubmergedFixOxygen: - Patches.SubmergedCompatibility.RepairOxygen(); + SubmergedCompatibility.RepairOxygen(); break; case CustomRPC.SetPos: var setplayer = Utils.PlayerById(reader.ReadByte()); diff --git a/source/Patches/StopImpKill.cs b/source/Patches/StopImpKill.cs index d0256baca..83eb432d0 100644 --- a/source/Patches/StopImpKill.cs +++ b/source/Patches/StopImpKill.cs @@ -23,7 +23,7 @@ public static bool Prefix(KillButton __instance) return false; } var interact = Utils.Interact(PlayerControl.LocalPlayer, target, true); - if (interact[4] == true) return false; + if (interact.abilityUsed) return false; if (PlayerControl.LocalPlayer.Is(RoleEnum.Warlock)) { var warlock = Role.GetRole(PlayerControl.LocalPlayer); @@ -35,7 +35,7 @@ public static bool Prefix(KillButton __instance) } PlayerControl.LocalPlayer.SetKillTimer(0.01f); } - else if (interact[0] == true) + else if (interact.fullCooldownReset) { if (PlayerControl.LocalPlayer.Is(ModifierEnum.Underdog)) { @@ -47,17 +47,17 @@ public static bool Prefix(KillButton __instance) else PlayerControl.LocalPlayer.SetKillTimer(GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown); return false; } - else if (interact[1] == true) + else if (interact.gaReset) { PlayerControl.LocalPlayer.SetKillTimer(CustomGameOptions.ProtectKCReset + 0.01f); return false; } - else if (interact[2] == true) + else if (interact.survReset) { PlayerControl.LocalPlayer.SetKillTimer(CustomGameOptions.VestKCReset + 0.01f); return false; } - else if (interact[3] == true) + else if (interact.zeroSecReset == true) { PlayerControl.LocalPlayer.SetKillTimer(0.01f); return false; diff --git a/source/Patches/SubmergedCompatibility.cs b/source/Patches/SubmergedCompatibility.cs index a8d7cc277..44c3526ed 100644 --- a/source/Patches/SubmergedCompatibility.cs +++ b/source/Patches/SubmergedCompatibility.cs @@ -11,7 +11,7 @@ using UnityEngine; using Reactor.Utilities; using TownOfUs.Roles; -using Hazel; +using ElevatorData = (bool atTopFloor, object player); namespace TownOfUs.Patches { @@ -174,7 +174,7 @@ public static void Initialize() Types = AccessTools.GetTypesFromAssembly(Assembly); InjectedTypes = (Dictionary)AccessTools.PropertyGetter(Types.FirstOrDefault(t => t.Name == "ComponentExtensions"), "RegisteredTypes") - .Invoke(null, Array.Empty()); + .Invoke(null, []); SubmarineStatusType = Types.First(t => t.Name == "SubmarineStatus"); SubmergedInstance = AccessTools.Field(SubmarineStatusType, "instance"); @@ -210,7 +210,7 @@ public static void Initialize() SubmarineElevatorSystem = Types.First(t => t.Name == "SubmarineElevatorSystem"); UpperDeckIsTargetFloor = AccessTools.Field(SubmarineElevatorSystem, "upperDeckIsTargetFloor"); - Harmony _harmony = new Harmony("tou.submerged.patch"); + Harmony _harmony = new("tou.submerged.patch"); var exilerolechangePostfix = SymbolExtensions.GetMethodInfo(() => ExileRoleChangePostfix()); _harmony.Patch(SubmergedExileWrapUpMethod, null, new HarmonyMethod(exilerolechangePostfix)); } @@ -220,9 +220,9 @@ public static void CheckOutOfBoundsElevator(PlayerControl player) if (!Loaded) return; if (!isSubmerged()) return; - Tuple elevator = GetPlayerElevator(player); - if (!elevator.Item1) return; - bool CurrentFloor = (bool)UpperDeckIsTargetFloor.GetValue(getSubElevatorSystem.GetValue(elevator.Item2)); //true is top, false is bottom + ElevatorData elevator = GetPlayerElevator(player); + if (!elevator.atTopFloor) return; + bool CurrentFloor = (bool)UpperDeckIsTargetFloor.GetValue(getSubElevatorSystem.GetValue(elevator.player)); //true is top, false is bottom bool PlayerFloor = player.transform.position.y > -7f; //true is top, false is bottom if (CurrentFloor != PlayerFloor) @@ -234,14 +234,14 @@ public static void CheckOutOfBoundsElevator(PlayerControl player) public static void MoveDeadPlayerElevator(PlayerControl player) { if (!isSubmerged()) return; - Tuple elevator = GetPlayerElevator(player); - if (!elevator.Item1) return; + ElevatorData elevator = GetPlayerElevator(player); + if (!elevator.atTopFloor) return; - int MovementStage = (int)GetMovementStageFromTime.Invoke(elevator.Item2, null); + int MovementStage = (int)GetMovementStageFromTime.Invoke(elevator.player, null); if (MovementStage >= 5) { //Fade to clear - bool topfloortarget = (bool)UpperDeckIsTargetFloor.GetValue(getSubElevatorSystem.GetValue(elevator.Item2)); //true is top, false is bottom + bool topfloortarget = (bool)UpperDeckIsTargetFloor.GetValue(getSubElevatorSystem.GetValue(elevator.player)); //true is top, false is bottom bool topintendedtarget = player.transform.position.y > -7f; //true is top, false is bottom if (topfloortarget != topintendedtarget) { @@ -250,17 +250,17 @@ public static void MoveDeadPlayerElevator(PlayerControl player) } } - public static Tuple GetPlayerElevator(PlayerControl player) + public static ElevatorData GetPlayerElevator(PlayerControl player) { - if (!isSubmerged()) return Tuple.Create(false, (object)null); - IList elevatorlist = Utils.createList(SubmarineElevator); + if (!isSubmerged()) return new ElevatorData(false, null); + IList elevatorlist = Utils.CreateList(SubmarineElevator); elevatorlist = (IList)SubmergedElevators.GetValue(SubmergedInstance.GetValue(null)); foreach (object elevator in elevatorlist) { - if ((bool)GetInElevator.Invoke(elevator, new object[] { player })) return Tuple.Create(true, elevator); + if ((bool)GetInElevator.Invoke(elevator, new object[] { player })) return new ElevatorData(true, elevator); } - return Tuple.Create(false, (object)null); + return new ElevatorData(false, null); } public static void ExileRoleChangePostfix() diff --git a/source/Patches/Utils.cs b/source/Patches/Utils.cs index f6af28aee..011a86f7b 100644 --- a/source/Patches/Utils.cs +++ b/source/Patches/Utils.cs @@ -26,7 +26,7 @@ using TownOfUs.CrewmateRoles.AurialMod; using Reactor.Networking; using Reactor.Networking.Extensions; -using Unity.Services.Core.Telemetry.Internal; +using InteractionData = (bool fullCooldownReset, bool gaReset, bool survReset, bool zeroSecReset, bool abilityUsed); namespace TownOfUs { @@ -212,20 +212,16 @@ public static bool IsInfected(this PlayerControl player) }); } - public static List Interact(PlayerControl player, PlayerControl target, bool toKill = false) + public static InteractionData Interact(PlayerControl player, PlayerControl target, bool toKill = false) { - bool fullCooldownReset = false; - bool gaReset = false; - bool survReset = false; - bool zeroSecReset = false; - bool abilityUsed = false; + InteractionData data = new(false, false, false, false, false); if (target.IsInfected() || player.IsInfected()) { foreach (var pb in Role.GetRoles(RoleEnum.Plaguebearer)) ((Plaguebearer)pb).RpcSpreadInfection(target, player); } if (target == ShowRoundOneShield.FirstRoundShielded && toKill) { - zeroSecReset = true; + data.zeroSecReset = true; } else if (target.Is(RoleEnum.Pestilence)) { @@ -234,28 +230,28 @@ public static List Interact(PlayerControl player, PlayerControl target, bo var medic = player.GetMedic().Player.PlayerId; Rpc(CustomRPC.AttemptSound, medic, player.PlayerId); - if (CustomGameOptions.ShieldBreaks) fullCooldownReset = true; - else zeroSecReset = true; + if (CustomGameOptions.ShieldBreaks) data.fullCooldownReset = true; + else data.zeroSecReset = true; StopKill.BreakShield(medic, player.PlayerId, CustomGameOptions.ShieldBreaks); } - else if (player.IsProtected()) gaReset = true; + else if (player.IsProtected()) data.gaReset = true; else RpcMurderPlayer(target, player); } else if (target.IsOnAlert()) { - if (player.Is(RoleEnum.Pestilence)) zeroSecReset = true; + if (player.Is(RoleEnum.Pestilence)) data.zeroSecReset = true; else if (player.IsShielded()) { var medic = player.GetMedic().Player.PlayerId; Rpc(CustomRPC.AttemptSound, medic, player.PlayerId); - if (CustomGameOptions.ShieldBreaks) fullCooldownReset = true; - else zeroSecReset = true; + if (CustomGameOptions.ShieldBreaks) data.fullCooldownReset = true; + else data.zeroSecReset = true; StopKill.BreakShield(medic, player.PlayerId, CustomGameOptions.ShieldBreaks); } - else if (player.IsProtected()) gaReset = true; + else if (player.IsProtected()) data.gaReset = true; else RpcMurderPlayer(target, player); if (toKill && CustomGameOptions.KilledOnAlert) { @@ -264,12 +260,12 @@ public static List Interact(PlayerControl player, PlayerControl target, bo var medic = target.GetMedic().Player.PlayerId; Rpc(CustomRPC.AttemptSound, medic, target.PlayerId); - if (CustomGameOptions.ShieldBreaks) fullCooldownReset = true; - else zeroSecReset = true; + if (CustomGameOptions.ShieldBreaks) data.fullCooldownReset = true; + else data.zeroSecReset = true; StopKill.BreakShield(medic, target.PlayerId, CustomGameOptions.ShieldBreaks); } - else if (target.IsProtected()) gaReset = true; + else if (target.IsProtected()) data.gaReset = true; else { if (player.Is(RoleEnum.Glitch)) @@ -304,10 +300,10 @@ public static List Interact(PlayerControl player, PlayerControl target, bo ww.LastKilled = DateTime.UtcNow; } RpcMurderPlayer(player, target); - abilityUsed = true; - fullCooldownReset = true; - gaReset = false; - zeroSecReset = false; + data.abilityUsed = true; + data.fullCooldownReset = true; + data.gaReset = false; + data.zeroSecReset = false; } } } @@ -316,17 +312,17 @@ public static List Interact(PlayerControl player, PlayerControl target, bo Rpc(CustomRPC.AttemptSound, target.GetMedic().Player.PlayerId, target.PlayerId); System.Console.WriteLine(CustomGameOptions.ShieldBreaks + "- shield break"); - if (CustomGameOptions.ShieldBreaks) fullCooldownReset = true; - else zeroSecReset = true; + if (CustomGameOptions.ShieldBreaks) data.fullCooldownReset = true; + else data.zeroSecReset = true; StopKill.BreakShield(target.GetMedic().Player.PlayerId, target.PlayerId, CustomGameOptions.ShieldBreaks); } else if (target.IsVesting() && toKill) { - survReset = true; + data.survReset = true; } else if (target.IsProtected() && toKill) { - gaReset = true; + data.gaReset = true; } else if (toKill) { @@ -362,21 +358,16 @@ public static List Interact(PlayerControl player, PlayerControl target, bo ww.LastKilled = DateTime.UtcNow; } RpcMurderPlayer(player, target); - abilityUsed = true; - fullCooldownReset = true; + data.abilityUsed = true; + data.fullCooldownReset = true; } else { - abilityUsed = true; - fullCooldownReset = true; + data.abilityUsed = true; + data.fullCooldownReset = true; } - var reset = new List(); - reset.Add(fullCooldownReset); - reset.Add(gaReset); - reset.Add(survReset); - reset.Add(zeroSecReset); - reset.Add(abilityUsed); - return reset; + + return data; } public static Il2CppSystem.Collections.Generic.List GetClosestPlayers(Vector2 truePosition, float radius, bool includeDead) @@ -1075,7 +1066,7 @@ public static object TryCast(this Il2CppObjectBase self, Type type) { return AccessTools.Method(self.GetType(), nameof(Il2CppObjectBase.TryCast)).MakeGenericMethod(type).Invoke(self, Array.Empty()); } - public static IList createList(Type myType) + public static IList CreateList(Type myType) { Type genericListType = typeof(List<>).MakeGenericType(myType); return (IList)Activator.CreateInstance(genericListType); From 78a3d825acb3f300ebc514dac8a4720389fc2152 Mon Sep 17 00:00:00 2001 From: twix <91138333+whichtwix@users.noreply.github.com> Date: Sat, 19 Aug 2023 15:07:10 +0600 Subject: [PATCH 2/2] migrate to record & class --- .../CrewmateRoles/DetectiveMod/PerformKill.cs | 8 +- .../Patches/CrewmateRoles/MedicMod/Protect.cs | 2 +- .../CrewmateRoles/OracleMod/PerformKill.cs | 8 +- .../CrewmateRoles/SeerMod/PerformKill.cs | 8 +- .../CrewmateRoles/TrackerMod/PerformKill.cs | 8 +- .../VampireHunterMod/PerformKill.cs | 14 +- .../CultistRoles/WhispererMod/PerformKill.cs | 4 +- .../BlackmailerMod/PerformKill.cs | 2 +- .../ImpostorRoles/MinerMod/PerformKill.cs | 4 +- .../NeutralRoles/ArsonistMod/PerformKill.cs | 16 +- .../NeutralRoles/DoomsayerMod/PerformKill.cs | 8 +- .../NeutralRoles/JuggernautMod/PerformKill.cs | 10 +- .../NeutralRoles/PestilenceMod/PerformKill.cs | 10 +- .../PlaguebearerMod/PerformKill.cs | 6 +- .../NeutralRoles/VampireMod/PerformKill.cs | 18 +- .../NeutralRoles/WerewolfMod/PerformKill.cs | 10 +- source/Patches/Roles/Cultist/Whisperer.cs | 1 - source/Patches/Roles/Glitch.cs | 18 +- source/Patches/RpcHandling.cs | 280 +++++++++--------- source/Patches/StopImpKill.cs | 10 +- source/Patches/SubmergedCompatibility.cs | 13 +- source/Patches/TupleObjects.cs | 55 ++++ source/Patches/Utils.cs | 47 ++- 23 files changed, 304 insertions(+), 256 deletions(-) create mode 100644 source/Patches/TupleObjects.cs diff --git a/source/Patches/CrewmateRoles/DetectiveMod/PerformKill.cs b/source/Patches/CrewmateRoles/DetectiveMod/PerformKill.cs index 9afad22fa..c7a58e810 100644 --- a/source/Patches/CrewmateRoles/DetectiveMod/PerformKill.cs +++ b/source/Patches/CrewmateRoles/DetectiveMod/PerformKill.cs @@ -30,23 +30,23 @@ public static bool Prefix(KillButton __instance) PlayerControl.LocalPlayer.GetTruePosition()) > maxDistance) return false; if (role.ClosestPlayer == null) return false; var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer); - if (interact.abilityUsed) + if (interact.AbilityUsed) { if (role.ClosestPlayer == role.DetectedKiller) Coroutines.Start(Utils.FlashCoroutine(Color.red)); else Coroutines.Start(Utils.FlashCoroutine(Color.green)); } - if (interact.fullCooldownReset) + if (interact.FullCooldownReset) { role.LastExamined = DateTime.UtcNow; return false; } - else if (interact.gaReset) + else if (interact.GaReset) { role.LastExamined = DateTime.UtcNow; role.LastExamined = role.LastExamined.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.ExamineCd); return false; } - else if (interact.zeroSecReset) return false; + else if (interact.ZeroSecReset) return false; return false; } else diff --git a/source/Patches/CrewmateRoles/MedicMod/Protect.cs b/source/Patches/CrewmateRoles/MedicMod/Protect.cs index d47bb08f2..faac3454a 100644 --- a/source/Patches/CrewmateRoles/MedicMod/Protect.cs +++ b/source/Patches/CrewmateRoles/MedicMod/Protect.cs @@ -20,7 +20,7 @@ public static bool Prefix(KillButton __instance) if (role.StartTimer() > 0) return false; var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer); - if (interact.abilityUsed) + if (interact.AbilityUsed) { Utils.Rpc(CustomRPC.Protect, PlayerControl.LocalPlayer.PlayerId, role.ClosestPlayer.PlayerId); diff --git a/source/Patches/CrewmateRoles/OracleMod/PerformKill.cs b/source/Patches/CrewmateRoles/OracleMod/PerformKill.cs index 9c991267f..18ce9a2a0 100644 --- a/source/Patches/CrewmateRoles/OracleMod/PerformKill.cs +++ b/source/Patches/CrewmateRoles/OracleMod/PerformKill.cs @@ -26,7 +26,7 @@ public static bool Prefix(KillButton __instance) if (role.ClosestPlayer == null) return false; var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer); - if (interact.abilityUsed) + if (interact.AbilityUsed) { role.Confessor = role.ClosestPlayer; bool showsCorrectFaction = true; @@ -55,18 +55,18 @@ public static bool Prefix(KillButton __instance) else role.RevealedFaction = Faction.Impostors; Utils.Rpc(CustomRPC.Confess, PlayerControl.LocalPlayer.PlayerId, role.Confessor.PlayerId, faction); } - if (interact.fullCooldownReset) + if (interact.FullCooldownReset) { role.LastConfessed = DateTime.UtcNow; return false; } - else if (interact.gaReset) + else if (interact.GaReset) { role.LastConfessed = DateTime.UtcNow; role.LastConfessed = role.LastConfessed.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.ConfessCd); return false; } - else if (interact.zeroSecReset) return false; + else if (interact.ZeroSecReset) return false; return false; } } diff --git a/source/Patches/CrewmateRoles/SeerMod/PerformKill.cs b/source/Patches/CrewmateRoles/SeerMod/PerformKill.cs index f10e50fba..144ff0c16 100644 --- a/source/Patches/CrewmateRoles/SeerMod/PerformKill.cs +++ b/source/Patches/CrewmateRoles/SeerMod/PerformKill.cs @@ -25,22 +25,22 @@ public static bool Prefix(KillButton __instance) if (role.ClosestPlayer == null) return false; var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer); - if (interact.abilityUsed) + if (interact.AbilityUsed) { role.Investigated.Add(role.ClosestPlayer.PlayerId); } - if (interact.fullCooldownReset) + if (interact.FullCooldownReset) { role.LastInvestigated = DateTime.UtcNow; return false; } - else if (interact.gaReset) + else if (interact.GaReset) { role.LastInvestigated = DateTime.UtcNow; role.LastInvestigated = role.LastInvestigated.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.SeerCd); return false; } - else if (interact.zeroSecReset) return false; + else if (interact.ZeroSecReset) return false; return false; } } diff --git a/source/Patches/CrewmateRoles/TrackerMod/PerformKill.cs b/source/Patches/CrewmateRoles/TrackerMod/PerformKill.cs index b4fd071db..ec39f080f 100644 --- a/source/Patches/CrewmateRoles/TrackerMod/PerformKill.cs +++ b/source/Patches/CrewmateRoles/TrackerMod/PerformKill.cs @@ -28,7 +28,7 @@ public static bool Prefix(KillButton __instance) if (!role.ButtonUsable) return false; var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer); - if (interact.abilityUsed) + if (interact.AbilityUsed) { var gameObj = new GameObject(); var arrow = gameObj.AddComponent(); @@ -53,18 +53,18 @@ public static bool Prefix(KillButton __instance) role.TrackerArrows.Add(target.PlayerId, arrow); role.UsesLeft--; } - if (interact.fullCooldownReset) + if (interact.FullCooldownReset) { role.LastTracked = DateTime.UtcNow; return false; } - else if (interact.gaReset) + else if (interact.GaReset) { role.LastTracked = DateTime.UtcNow; role.LastTracked = role.LastTracked.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.TrackCd); return false; } - else if (interact.zeroSecReset) return false; + else if (interact.ZeroSecReset) return false; return false; } } diff --git a/source/Patches/CrewmateRoles/VampireHunterMod/PerformKill.cs b/source/Patches/CrewmateRoles/VampireHunterMod/PerformKill.cs index ca1e0f3a3..1dc47b683 100644 --- a/source/Patches/CrewmateRoles/VampireHunterMod/PerformKill.cs +++ b/source/Patches/CrewmateRoles/VampireHunterMod/PerformKill.cs @@ -27,7 +27,7 @@ public static bool Prefix(KillButton __instance) if (!role.ClosestPlayer.Is(RoleEnum.Vampire)) { var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer); - if (interact.fullCooldownReset) + if (interact.FullCooldownReset) { role.LastStaked = DateTime.UtcNow; role.UsesLeft--; @@ -35,31 +35,31 @@ public static bool Prefix(KillButton __instance) Utils.RpcMurderPlayer(PlayerControl.LocalPlayer, PlayerControl.LocalPlayer); return false; } - else if (interact.gaReset) + else if (interact.GaReset) { role.LastStaked = DateTime.UtcNow; role.LastStaked = role.LastStaked.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.StakeCd); return false; } - else if (interact.zeroSecReset) return false; + else if (interact.ZeroSecReset) return false; return false; } else { var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer, true); - if (interact.abilityUsed) return false; - else if (interact.fullCooldownReset) + if (interact.AbilityUsed) return false; + else if (interact.FullCooldownReset) { role.LastStaked = DateTime.UtcNow; return false; } - else if (interact.gaReset) + else if (interact.GaReset) { role.LastStaked = DateTime.UtcNow; role.LastStaked = role.LastStaked.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.StakeCd); return false; } - else if (interact.zeroSecReset) return false; + else if (interact.ZeroSecReset) return false; return false; } } diff --git a/source/Patches/CultistRoles/WhispererMod/PerformKill.cs b/source/Patches/CultistRoles/WhispererMod/PerformKill.cs index 03286e8a8..9226d9b9c 100644 --- a/source/Patches/CultistRoles/WhispererMod/PerformKill.cs +++ b/source/Patches/CultistRoles/WhispererMod/PerformKill.cs @@ -30,7 +30,7 @@ public static bool Prefix(KillButton __instance) var closestPlayers = Utils.GetClosestPlayers(truePosition, CustomGameOptions.WhisperRadius, false); if (role.PlayerConversion.Count == 0) role.PlayerConversion = role.GetPlayers(); var oldStats = role.PlayerConversion; - role.PlayerConversion = []; + role.PlayerConversion = new(); foreach (var conversionRate in oldStats) { var player = conversionRate.Player; @@ -51,7 +51,7 @@ public static bool Prefix(KillButton __instance) public static void CheckConversion(Whisperer role) { - var removals = new List(); + var removals = new List(); foreach (var playerConversion in role.PlayerConversion) { if (playerConversion.UnconvertableChance <= 0) diff --git a/source/Patches/ImpostorRoles/BlackmailerMod/PerformKill.cs b/source/Patches/ImpostorRoles/BlackmailerMod/PerformKill.cs index e01daa5e7..79e6b208d 100644 --- a/source/Patches/ImpostorRoles/BlackmailerMod/PerformKill.cs +++ b/source/Patches/ImpostorRoles/BlackmailerMod/PerformKill.cs @@ -24,7 +24,7 @@ public static bool Prefix(KillButton __instance) if (role.BlackmailTimer() != 0) return false; var interact = Utils.Interact(PlayerControl.LocalPlayer, target); - if (interact.abilityUsed) + if (interact.AbilityUsed) { role.Blackmailed?.myRend().material.SetFloat("_Outline", 0f); if (role.Blackmailed != null && role.Blackmailed.Data.IsImpostor()) diff --git a/source/Patches/ImpostorRoles/MinerMod/PerformKill.cs b/source/Patches/ImpostorRoles/MinerMod/PerformKill.cs index c1e34598f..3cb0057bf 100644 --- a/source/Patches/ImpostorRoles/MinerMod/PerformKill.cs +++ b/source/Patches/ImpostorRoles/MinerMod/PerformKill.cs @@ -1,12 +1,10 @@ using System; using System.Linq; using HarmonyLib; -using Hazel; using TownOfUs.Patches; using TownOfUs.Roles; using UnityEngine; using Object = UnityEngine.Object; -using Reactor.Networking.Extensions; namespace TownOfUs.ImpostorRoles.MinerMod { @@ -26,7 +24,7 @@ public static bool Prefix(KillButton __instance) if (!__instance.isActiveAndEnabled) return false; if (!role.CanPlace) return false; if (role.MineTimer() != 0) return false; - if (SubmergedCompatibility.GetPlayerElevator(PlayerControl.LocalPlayer).atTopFloor) return false; + if (SubmergedCompatibility.GetPlayerElevator(PlayerControl.LocalPlayer).AtTopFloor) return false; var position = PlayerControl.LocalPlayer.transform.position; var id = GetAvailableId(); Utils.Rpc(CustomRPC.Mine, id, PlayerControl.LocalPlayer.PlayerId, position, position.z + 0.001f); diff --git a/source/Patches/NeutralRoles/ArsonistMod/PerformKill.cs b/source/Patches/NeutralRoles/ArsonistMod/PerformKill.cs index 28f2ebe52..f18e6ba99 100644 --- a/source/Patches/NeutralRoles/ArsonistMod/PerformKill.cs +++ b/source/Patches/NeutralRoles/ArsonistMod/PerformKill.cs @@ -30,19 +30,19 @@ public static bool Prefix(KillButton __instance) if (!role.DousedPlayers.Contains(role.ClosestPlayerIgnite.PlayerId)) return false; var interact2 = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayerIgnite); - if (interact2.abilityUsed) role.Ignite(); - if (interact2.fullCooldownReset) + if (interact2.AbilityUsed) role.Ignite(); + if (interact2.FullCooldownReset) { role.LastDoused = DateTime.UtcNow; return false; } - else if (interact2.gaReset) + else if (interact2.GaReset) { role.LastDoused = DateTime.UtcNow; role.LastDoused.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.DouseCd); return false; } - else if (interact2.zeroSecReset) return false; + else if (interact2.ZeroSecReset) return false; return false; } else return false; @@ -57,19 +57,19 @@ public static bool Prefix(KillButton __instance) if (!flag2) return false; if (role.DousedPlayers.Contains(role.ClosestPlayerDouse.PlayerId)) return false; var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayerDouse); - if (interact.abilityUsed) role.DousedPlayers.Add(role.ClosestPlayerDouse.PlayerId); - if (interact.fullCooldownReset) + if (interact.AbilityUsed) role.DousedPlayers.Add(role.ClosestPlayerDouse.PlayerId); + if (interact.FullCooldownReset) { role.LastDoused = DateTime.UtcNow; return false; } - else if (interact.gaReset) + else if (interact.GaReset) { role.LastDoused = DateTime.UtcNow; role.LastDoused.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.DouseCd); return false; } - else if (interact.zeroSecReset) return false; + else if (interact.ZeroSecReset) return false; return false; } } diff --git a/source/Patches/NeutralRoles/DoomsayerMod/PerformKill.cs b/source/Patches/NeutralRoles/DoomsayerMod/PerformKill.cs index af61a7076..2c386c13b 100644 --- a/source/Patches/NeutralRoles/DoomsayerMod/PerformKill.cs +++ b/source/Patches/NeutralRoles/DoomsayerMod/PerformKill.cs @@ -23,22 +23,22 @@ public static bool Prefix(KillButton __instance) GameOptionsData.KillDistances[GameOptionsManager.Instance.currentNormalGameOptions.KillDistance]; if (!flag3) return false; var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer); - if (interact.abilityUsed) + if (interact.AbilityUsed) { role.LastObservedPlayer = role.ClosestPlayer; } - if (interact.fullCooldownReset) + if (interact.FullCooldownReset) { role.LastObserved = DateTime.UtcNow; return false; } - else if (interact.gaReset) + else if (interact.GaReset) { role.LastObserved = DateTime.UtcNow; role.LastObserved = role.LastObserved.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.ObserveCooldown); return false; } - else if (interact.zeroSecReset) return false; + else if (interact.ZeroSecReset) return false; return false; } } diff --git a/source/Patches/NeutralRoles/JuggernautMod/PerformKill.cs b/source/Patches/NeutralRoles/JuggernautMod/PerformKill.cs index 5d471eb46..5eee790e6 100644 --- a/source/Patches/NeutralRoles/JuggernautMod/PerformKill.cs +++ b/source/Patches/NeutralRoles/JuggernautMod/PerformKill.cs @@ -26,25 +26,25 @@ public static bool Prefix(KillButton __instance) GameOptionsData.KillDistances[GameOptionsManager.Instance.currentNormalGameOptions.KillDistance]; if (!flag3) return false; var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer, true); - if (interact.abilityUsed) return false; - else if (interact.fullCooldownReset) + if (interact.AbilityUsed) return false; + else if (interact.FullCooldownReset) { role.LastKill = DateTime.UtcNow; return false; } - else if (interact.gaReset) + else if (interact.GaReset) { role.LastKill = DateTime.UtcNow; role.LastKill = role.LastKill.AddSeconds(-(CustomGameOptions.JuggKCd - CustomGameOptions.ReducedKCdPerKill * role.JuggKills) + CustomGameOptions.ProtectKCReset); return false; } - else if (interact.survReset) + else if (interact.SurvReset) { role.LastKill = DateTime.UtcNow; role.LastKill = role.LastKill.AddSeconds(-(CustomGameOptions.JuggKCd - CustomGameOptions.ReducedKCdPerKill * role.JuggKills) + CustomGameOptions.VestKCReset); return false; } - else if (interact.zeroSecReset) return false; + else if (interact.ZeroSecReset) return false; return false; } } diff --git a/source/Patches/NeutralRoles/PestilenceMod/PerformKill.cs b/source/Patches/NeutralRoles/PestilenceMod/PerformKill.cs index 198793075..5d952f740 100644 --- a/source/Patches/NeutralRoles/PestilenceMod/PerformKill.cs +++ b/source/Patches/NeutralRoles/PestilenceMod/PerformKill.cs @@ -24,25 +24,25 @@ public static bool Prefix(KillButton __instance) GameOptionsData.KillDistances[GameOptionsManager.Instance.currentNormalGameOptions.KillDistance]; if (!flag3) return false; var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer, true); - if (interact.abilityUsed) return false; - else if (interact.fullCooldownReset) + if (interact.AbilityUsed) return false; + else if (interact.FullCooldownReset) { role.LastKill = DateTime.UtcNow; return false; } - else if (interact.gaReset) + else if (interact.GaReset) { role.LastKill = DateTime.UtcNow; role.LastKill = role.LastKill.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.PestKillCd); return false; } - else if (interact.survReset) + else if (interact.SurvReset) { role.LastKill = DateTime.UtcNow; role.LastKill = role.LastKill.AddSeconds(CustomGameOptions.VestKCReset - CustomGameOptions.PestKillCd); return false; } - else if (interact.zeroSecReset) return false; + else if (interact.ZeroSecReset) return false; return false; } } diff --git a/source/Patches/NeutralRoles/PlaguebearerMod/PerformKill.cs b/source/Patches/NeutralRoles/PlaguebearerMod/PerformKill.cs index 47d17e50c..379c8a693 100644 --- a/source/Patches/NeutralRoles/PlaguebearerMod/PerformKill.cs +++ b/source/Patches/NeutralRoles/PlaguebearerMod/PerformKill.cs @@ -25,18 +25,18 @@ public static bool Prefix(KillButton __instance) GameOptionsData.KillDistances[GameOptionsManager.Instance.currentNormalGameOptions.KillDistance]; if (!flag3) return false; var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer); - if (interact.fullCooldownReset) + if (interact.FullCooldownReset) { role.LastInfected = DateTime.UtcNow; return false; } - else if (interact.gaReset) + else if (interact.GaReset) { role.LastInfected = DateTime.UtcNow; role.LastInfected.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.InfectCd); return false; } - else if (interact.zeroSecReset) return false; + else if (interact.ZeroSecReset) return false; return false; } } diff --git a/source/Patches/NeutralRoles/VampireMod/PerformKill.cs b/source/Patches/NeutralRoles/VampireMod/PerformKill.cs index 54cf51565..f0cc42f7b 100644 --- a/source/Patches/NeutralRoles/VampireMod/PerformKill.cs +++ b/source/Patches/NeutralRoles/VampireMod/PerformKill.cs @@ -50,47 +50,47 @@ public static bool Prefix(KillButton __instance) aliveVamps.Count == 1 && vamps.Count < CustomGameOptions.MaxVampiresPerGame) { var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer); - if (interact.abilityUsed) + if (interact.AbilityUsed) { Convert(role.ClosestPlayer); Utils.Rpc(CustomRPC.Bite, role.ClosestPlayer.PlayerId); } - if (interact.fullCooldownReset) + if (interact.FullCooldownReset) { role.LastBit = DateTime.UtcNow; return false; } - else if (interact.gaReset) + else if (interact.GaReset) { role.LastBit = DateTime.UtcNow; role.LastBit = role.LastBit.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.BiteCd); return false; } - else if (interact.zeroSecReset) return false; + else if (interact.ZeroSecReset) return false; return false; } else { var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer, true); - if (interact.abilityUsed) return false; - if (interact.fullCooldownReset) + if (interact.AbilityUsed) return false; + if (interact.FullCooldownReset) { role.LastBit = DateTime.UtcNow; return false; } - else if (interact.gaReset) + else if (interact.GaReset) { role.LastBit = DateTime.UtcNow; role.LastBit = role.LastBit.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.BiteCd); return false; } - else if (interact.survReset) + else if (interact.SurvReset) { role.LastBit = DateTime.UtcNow; role.LastBit = role.LastBit.AddSeconds(CustomGameOptions.VestKCReset - CustomGameOptions.BiteCd); return false; } - else if (interact.zeroSecReset) return false; + else if (interact.ZeroSecReset) return false; return false; } } diff --git a/source/Patches/NeutralRoles/WerewolfMod/PerformKill.cs b/source/Patches/NeutralRoles/WerewolfMod/PerformKill.cs index bf69cec27..790f4b8b6 100644 --- a/source/Patches/NeutralRoles/WerewolfMod/PerformKill.cs +++ b/source/Patches/NeutralRoles/WerewolfMod/PerformKill.cs @@ -38,25 +38,25 @@ public static bool Prefix(KillButton __instance) if (!flag3) return false; var interact = Utils.Interact(PlayerControl.LocalPlayer, role.ClosestPlayer, true); - if (interact.abilityUsed) return false; - else if (interact.fullCooldownReset) + if (interact.AbilityUsed) return false; + else if (interact.FullCooldownReset) { role.LastKilled = DateTime.UtcNow; return false; } - else if (interact.gaReset) + else if (interact.GaReset) { role.LastKilled = DateTime.UtcNow; role.LastKilled = role.LastKilled.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.RampageKillCd); return false; } - else if (interact.survReset) + else if (interact.SurvReset) { role.LastKilled = DateTime.UtcNow; role.LastKilled = role.LastKilled.AddSeconds(CustomGameOptions.VestKCReset - CustomGameOptions.RampageKillCd); return false; } - else if (interact.zeroSecReset) return false; + else if (interact.ZeroSecReset) return false; return false; } } diff --git a/source/Patches/Roles/Cultist/Whisperer.cs b/source/Patches/Roles/Cultist/Whisperer.cs index 07b94d0cb..298a62136 100644 --- a/source/Patches/Roles/Cultist/Whisperer.cs +++ b/source/Patches/Roles/Cultist/Whisperer.cs @@ -12,7 +12,6 @@ public class Whisperer : Role public int ConversionCount; public List PlayerConversion = new(); public int WhisperConversion; - public record ConversionData(PlayerControl Player, int UnconvertableChance); public Whisperer(PlayerControl player) : base(player) diff --git a/source/Patches/Roles/Glitch.cs b/source/Patches/Roles/Glitch.cs index 334df29da..5de79ac1b 100644 --- a/source/Patches/Roles/Glitch.cs +++ b/source/Patches/Roles/Glitch.cs @@ -466,25 +466,25 @@ public static void KillButtonPress(Glitch __gInstance, KillButton __instance) { if (__gInstance.Player.inVent) return; var interact = Utils.Interact(__gInstance.Player, __gInstance.KillTarget, true); - if (interact.abilityUsed) return; - else if (interact.fullCooldownReset) + if (interact.AbilityUsed) return; + else if (interact.FullCooldownReset) { __gInstance.LastKill = DateTime.UtcNow; return; } - else if (interact.gaReset) + else if (interact.GaReset) { __gInstance.LastKill = DateTime.UtcNow; __gInstance.LastKill = __gInstance.LastKill.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.GlitchKillCooldown); return; } - else if (interact.survReset) + else if (interact.SurvReset) { __gInstance.LastKill = DateTime.UtcNow; __gInstance.LastKill = __gInstance.LastKill.AddSeconds(CustomGameOptions.VestKCReset - CustomGameOptions.GlitchKillCooldown); return; } - else if (interact.zeroSecReset) return; + else if (interact.ZeroSecReset) return; return; } } @@ -537,22 +537,22 @@ public static void HackButtonPress(Glitch __gInstance, KillButton __instance) if (__gInstance.HackTarget != null) { var interact = Utils.Interact(__gInstance.Player, __gInstance.HackTarget); - if (interact.abilityUsed) + if (interact.AbilityUsed) { __gInstance.RpcSetHacked(__gInstance.HackTarget); } - if (interact.fullCooldownReset) + if (interact.FullCooldownReset) { __gInstance.LastHack = DateTime.UtcNow; return; } - else if (interact.gaReset) + else if (interact.GaReset) { __gInstance.LastHack = DateTime.UtcNow; __gInstance.LastHack.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.HackCooldown); return; } - else if (interact.zeroSecReset) return; + else if (interact.ZeroSecReset) return; return; } } diff --git a/source/Patches/RpcHandling.cs b/source/Patches/RpcHandling.cs index 005e47daf..71d538096 100644 --- a/source/Patches/RpcHandling.cs +++ b/source/Patches/RpcHandling.cs @@ -35,9 +35,6 @@ using TownOfUs.NeutralRoles.VampireMod; using TownOfUs.CrewmateRoles.MayorMod; using System.Reflection; -using RoleData = (System.Type role, int chance, bool unique); -using ModifierData = (System.Type modifier, int chance); -using AbilityData = (System.Type ability, TownOfUs.CustomRPC rpc, int chance); namespace TownOfUs { @@ -82,15 +79,15 @@ private static void SortRoles(List roles, int numRoles) if (roles.Count < numRoles) numRoles = roles.Count; roles.Sort((a, b) => { - var a_ = a.chance == 100 ? 0 : 100; - var b_ = b.chance == 100 ? 0 : 100; + var a_ = a.Chance == 100 ? 0 : 100; + var b_ = b.Chance == 100 ? 0 : 100; return a_.CompareTo(b_); }); var certainRoles = 0; var odds = 0; foreach (var role in roles) - if (role.chance == 100) certainRoles += 1; - else odds += role.chance; + if (role.Chance == 100) certainRoles += 1; + else odds += role.Chance; while (certainRoles < numRoles) { var num = certainRoles; @@ -98,10 +95,10 @@ private static void SortRoles(List roles, int numRoles) var rolePicked = false; while (num < roles.Count && rolePicked == false) { - random -= roles[num].chance; + random -= roles[num].Chance; if (random < 0) { - odds -= roles[num].chance; + odds -= roles[num].Chance; var role = roles[num]; roles.Remove(role); roles.Insert(0, role); @@ -119,8 +116,8 @@ private static void SortModifiers(List roles, int max) roles.Shuffle(); roles.Sort((a, b) => { - var a_ = a.chance == 100 ? 0 : 100; - var b_ = b.chance == 100 ? 0 : 100; + var a_ = a.Chance == 100 ? 0 : 100; + var b_ = b.Chance == 100 ? 0 : 100; return a_.CompareTo(b_); }); while (roles.Count > max) roles.RemoveAt(roles.Count - 1); @@ -244,9 +241,10 @@ private static void GenEachRole(List infected) SortRoles(NeutralEvilRoles, evil); SortRoles(NeutralKillingRoles, killing); - if (NeutralKillingRoles.Contains((typeof(Vampire), CustomGameOptions.VampireOn, true)) && CustomGameOptions.VampireHunterOn > 0) + if (NeutralKillingRoles.Any(x => x.Role == typeof(Vampire) && x.Chance == CustomGameOptions.VampireOn && x.Unique == true) + && CustomGameOptions.VampireHunterOn > 0) { - CrewmateRoles.Add((typeof(VampireHunter), CustomGameOptions.VampireHunterOn, true)); + CrewmateRoles.Add(new(typeof(VampireHunter), CustomGameOptions.VampireHunterOn, true)); } SortRoles(CrewmateRoles, crewmates.Count - NeutralBenignRoles.Count - NeutralEvilRoles.Count - NeutralKillingRoles.Count); @@ -268,24 +266,24 @@ private static void GenEachRole(List infected) if (crewAndNeutralRoles.Count > 0) { crewRoles.Add(crewAndNeutralRoles[0]); - if (crewAndNeutralRoles[0].unique) crewAndNeutralRoles.Remove(crewAndNeutralRoles[0]); + if (crewAndNeutralRoles[0].Unique) crewAndNeutralRoles.Remove(crewAndNeutralRoles[0]); } if (CrewmateRoles.Count > 0) { CrewmateRoles.Shuffle(); crewRoles.Add(CrewmateRoles[0]); - if (CrewmateRoles[0].unique) CrewmateRoles.Remove(CrewmateRoles[0]); + if (CrewmateRoles[0].Unique) CrewmateRoles.Remove(CrewmateRoles[0]); } else { - crewRoles.Add((typeof(Crewmate), 100, false)); + crewRoles.Add(new(typeof(Crewmate), 100, false)); } crewAndNeutralRoles.AddRange(CrewmateRoles); while (crewRoles.Count < crewmates.Count && crewAndNeutralRoles.Count > 0) { crewAndNeutralRoles.Shuffle(); crewRoles.Add(crewAndNeutralRoles[0]); - if (crewAndNeutralRoles[0].unique) + if (crewAndNeutralRoles[0].Unique) { if (CrewmateRoles.Contains(crewAndNeutralRoles[0])) CrewmateRoles.Remove(crewAndNeutralRoles[0]); crewAndNeutralRoles.Remove(crewAndNeutralRoles[0]); @@ -295,7 +293,7 @@ private static void GenEachRole(List infected) { ImpostorRoles.Shuffle(); impRoles.Add(ImpostorRoles[0]); - if (ImpostorRoles[0].unique) ImpostorRoles.Remove(ImpostorRoles[0]); + if (ImpostorRoles[0].Unique) ImpostorRoles.Remove(ImpostorRoles[0]); } } crewRoles.Shuffle(); @@ -308,24 +306,24 @@ private static void GenEachRole(List infected) if (CustomGameOptions.GameMode == GameMode.AllAny) { - foreach (var (type, _, unique) in crewRoles) + foreach (var role in crewRoles) { - Role.GenRole(type, crewmates); + Role.GenRole(role.Role, crewmates); } - foreach (var (type, _, unique) in impRoles) + foreach (var role in impRoles) { - Role.GenRole(type, impostors); + Role.GenRole(role.Role, impostors); } } else { - foreach (var (type, _, unique) in crewAndNeutralRoles) + foreach (var role in crewAndNeutralRoles) { - Role.GenRole(type, crewmates); + Role.GenRole(role.Role, crewmates); } - foreach (var (type, _, unique) in ImpostorRoles) + foreach (var role in ImpostorRoles) { - Role.GenRole(type, impostors); + Role.GenRole(role.Role, impostors); } } @@ -350,57 +348,57 @@ private static void GenEachRole(List infected) while (canHaveAbility.Count > 0 && impAssassins > 0) { - var (type, rpc, _) = AssassinAbility.Ability(); - Role.Gen(type, canHaveAbility.TakeFirst(), rpc); + AbilityData data = AssassinAbility.Ability(); + Role.Gen(data.Ability, canHaveAbility.TakeFirst(), data.Rpc); impAssassins -= 1; } while (canHaveAbility2.Count > 0 && neutAssassins > 0) { - var (type, rpc, _) = AssassinAbility.Ability(); - Role.Gen(type, canHaveAbility2.TakeFirst(), rpc); + AbilityData data = AssassinAbility.Ability(); + Role.Gen(data.Ability, canHaveAbility2.TakeFirst(), data.Rpc); neutAssassins -= 1; } var canHaveAssassinModifier = PlayerControl.AllPlayerControls.ToArray().ToList(); canHaveAssassinModifier.RemoveAll(player => !player.Is(Faction.Impostors) || !player.Is(AbilityEnum.Assassin)); - foreach (var (type, _) in AssassinModifiers) + foreach (var mod in AssassinModifiers) { if (canHaveAssassinModifier.Count == 0) break; - Role.GenModifier(type, canHaveAssassinModifier); + Role.GenModifier(mod.Modifier, canHaveAssassinModifier); } canHaveImpModifier.RemoveAll(player => player.Is(ModifierEnum.DoubleShot)); - foreach (var (type, _) in ImpostorModifiers) + foreach (var mod in ImpostorModifiers) { if (canHaveImpModifier.Count == 0) break; - Role.GenModifier(type, canHaveImpModifier); + Role.GenModifier(mod.Modifier, canHaveImpModifier); } canHaveModifier.RemoveAll(player => player.Is(ModifierEnum.Disperser) || player.Is(ModifierEnum.DoubleShot) || player.Is(ModifierEnum.Underdog)); - foreach (var (type, id) in GlobalModifiers) + foreach (var mod in GlobalModifiers) { if (canHaveModifier.Count == 0) break; - if (type.FullName.Contains("Lover")) + if (mod.Modifier.FullName.Contains("Lover")) { if (canHaveModifier.Count == 1) continue; Lover.Gen(canHaveModifier); } else { - Role.GenModifier(type, canHaveModifier); + Role.GenModifier(mod.Modifier, canHaveModifier); } } canHaveModifier.RemoveAll(player => player.Is(RoleEnum.Glitch)); - foreach (var (type, id) in ButtonModifiers) + foreach (var mod in ButtonModifiers) { if (canHaveModifier.Count == 0) break; - Role.GenModifier(type, canHaveModifier); + Role.GenModifier(mod.Modifier, canHaveModifier); } canHaveModifier.RemoveAll(player => !player.Is(Faction.Crewmates)); @@ -408,8 +406,8 @@ private static void GenEachRole(List infected) while (canHaveModifier.Count > 0 && CrewmateModifiers.Count > 0) { - var (type, _) = CrewmateModifiers.TakeFirst(); - Role.GenModifier(type, canHaveModifier.TakeFirst()); + ModifierData data = CrewmateModifiers.TakeFirst(); + Role.GenModifier(data.Modifier, canHaveModifier.TakeFirst()); } @@ -506,23 +504,23 @@ private static void GenEachRoleKilling(List infected) crewmates.Shuffle(); impostors.Shuffle(); - ImpostorRoles.Add((typeof(Undertaker), 10, true)); - ImpostorRoles.Add((typeof(Morphling), 10, false)); - ImpostorRoles.Add((typeof(Escapist), 10, false)); - ImpostorRoles.Add((typeof(Miner), 10, true)); - ImpostorRoles.Add((typeof(Swooper), 10, false)); - ImpostorRoles.Add((typeof(Grenadier), 10, true)); + ImpostorRoles.Add(new(typeof(Undertaker), 10, true)); + ImpostorRoles.Add(new(typeof(Morphling), 10, false)); + ImpostorRoles.Add(new(typeof(Escapist), 10, false)); + ImpostorRoles.Add(new(typeof(Miner), 10, true)); + ImpostorRoles.Add(new(typeof(Swooper), 10, false)); + ImpostorRoles.Add(new(typeof(Grenadier), 10, true)); SortRoles(ImpostorRoles, impostors.Count); - NeutralKillingRoles.Add((typeof(Glitch), 10, true)); - NeutralKillingRoles.Add((typeof(Werewolf), 10, true)); + NeutralKillingRoles.Add(new(typeof(Glitch), 10, true)); + NeutralKillingRoles.Add(new(typeof(Werewolf), 10, true)); if (CustomGameOptions.HiddenRoles) - NeutralKillingRoles.Add((typeof(Juggernaut), 10, true)); + NeutralKillingRoles.Add(new(typeof(Juggernaut), 10, true)); if (CustomGameOptions.AddArsonist) - NeutralKillingRoles.Add((typeof(Arsonist), 10, true)); + NeutralKillingRoles.Add(new(typeof(Arsonist), 10, true)); if (CustomGameOptions.AddPlaguebearer) - NeutralKillingRoles.Add((typeof(Plaguebearer), 10, true)); + NeutralKillingRoles.Add(new(typeof(Plaguebearer), 10, true)); var neutrals = 0; if (NeutralKillingRoles.Count < CustomGameOptions.NeutralRoles) neutrals = NeutralKillingRoles.Count; @@ -534,13 +532,13 @@ private static void GenEachRoleKilling(List infected) var veterans = CustomGameOptions.VeteranCount; while (veterans > 0) { - CrewmateRoles.Add((typeof(Veteran), 10, false)); + CrewmateRoles.Add(new(typeof(Veteran), 10, false)); veterans -= 1; } var vigilantes = CustomGameOptions.VigilanteCount; while (vigilantes > 0) { - CrewmateRoles.Add((typeof(Vigilante), 10, false)); + CrewmateRoles.Add(new(typeof(Vigilante), 10, false)); vigilantes -= 1; } if (CrewmateRoles.Count + NeutralKillingRoles.Count > crewmates.Count) @@ -552,7 +550,7 @@ private static void GenEachRoleKilling(List infected) var sheriffs = crewmates.Count - NeutralKillingRoles.Count - CrewmateRoles.Count; while (sheriffs > 0) { - CrewmateRoles.Add((typeof(Sheriff), 10, false)); + CrewmateRoles.Add(new(typeof(Sheriff), 10, false)); sheriffs -= 1; } } @@ -563,13 +561,13 @@ private static void GenEachRoleKilling(List infected) crewAndNeutralRoles.Shuffle(); ImpostorRoles.Shuffle(); - foreach (var (type, _, _) in crewAndNeutralRoles) + foreach (var role in crewAndNeutralRoles) { - Role.GenRole(type, crewmates); + Role.GenRole(role.Role, crewmates); } - foreach (var (type, _, _) in ImpostorRoles) + foreach (var role in ImpostorRoles) { - Role.GenRole(type, impostors); + Role.GenRole(role.Role, impostors); } } private static void GenEachRoleCultist(List infected) @@ -582,10 +580,10 @@ private static void GenEachRoleCultist(List infected) var specialRoles = new List(); var crewRoles = new List(); var impRole = new List(); - if (CustomGameOptions.MayorCultistOn > 0) specialRoles.Add((typeof(Mayor), CustomGameOptions.MayorCultistOn, true)); - if (CustomGameOptions.SeerCultistOn > 0) specialRoles.Add((typeof(CultistSeer), CustomGameOptions.SeerCultistOn, true)); - if (CustomGameOptions.SheriffCultistOn > 0) specialRoles.Add((typeof(Sheriff), CustomGameOptions.SheriffCultistOn, true)); - if (CustomGameOptions.SurvivorCultistOn > 0) specialRoles.Add((typeof(Survivor), CustomGameOptions.SurvivorCultistOn, true)); + if (CustomGameOptions.MayorCultistOn > 0) specialRoles.Add(new(typeof(Mayor), CustomGameOptions.MayorCultistOn, true)); + if (CustomGameOptions.SeerCultistOn > 0) specialRoles.Add(new(typeof(CultistSeer), CustomGameOptions.SeerCultistOn, true)); + if (CustomGameOptions.SheriffCultistOn > 0) specialRoles.Add(new(typeof(Sheriff), CustomGameOptions.SheriffCultistOn, true)); + if (CustomGameOptions.SurvivorCultistOn > 0) specialRoles.Add(new(typeof(Survivor), CustomGameOptions.SurvivorCultistOn, true)); if (specialRoles.Count > CustomGameOptions.SpecialRoleCount) SortRoles(specialRoles, CustomGameOptions.SpecialRoleCount); if (specialRoles.Count > crewmates.Count) SortRoles(specialRoles, crewmates.Count); if (specialRoles.Count < crewmates.Count) @@ -600,61 +598,61 @@ private static void GenEachRoleCultist(List infected) var vigilantes = CustomGameOptions.MaxVigilantes; while (chameleons > 0) { - crewRoles.Add((typeof(Chameleon), 10, false)); + crewRoles.Add(new(typeof(Chameleon), 10, false)); chameleons--; } while (engineers > 0) { - crewRoles.Add((typeof(Engineer), 10, false)); + crewRoles.Add(new(typeof(Engineer), 10, false)); engineers--; } while (investigators > 0) { - crewRoles.Add((typeof(Investigator), 10, false)); + crewRoles.Add(new(typeof(Investigator), 10, false)); investigators--; } while (mystics > 0) { - crewRoles.Add((typeof(CultistMystic), 10, false)); + crewRoles.Add(new(typeof(CultistMystic), 10, false)); mystics--; } while (snitches > 0) { - crewRoles.Add((typeof(CultistSnitch), 10, false)); + crewRoles.Add(new(typeof(CultistSnitch), 10, false)); snitches--; } while (spies > 0) { - crewRoles.Add((typeof(Spy), 10, false)); + crewRoles.Add(new(typeof(Spy), 10, false)); spies--; } while (transporters > 0) { - crewRoles.Add((typeof(Transporter), 10, false)); + crewRoles.Add(new(typeof(Transporter), 10, false)); transporters--; } while (vigilantes > 0) { - crewRoles.Add((typeof(Vigilante), 10, false)); + crewRoles.Add(new(typeof(Vigilante), 10, false)); vigilantes--; } SortRoles(crewRoles, crewmates.Count - specialRoles.Count); } - impRole.Add((typeof(Necromancer), 10, true)); - impRole.Add((typeof(Whisperer), 10, true)); + impRole.Add(new(typeof(Necromancer), 10, true)); + impRole.Add(new(typeof(Whisperer), 10, true)); SortRoles(impRole, 1); - foreach (var (type, _, _) in specialRoles) + foreach (var role in specialRoles) { - Role.GenRole(type, crewmates); + Role.GenRole(role.Role, crewmates); } - foreach (var (type, _, _) in crewRoles) + foreach (var role in crewRoles) { - Role.GenRole(type, crewmates); + Role.GenRole(role.Role, crewmates); } - foreach (var (type, _, _) in impRole) + foreach (var role in impRole) { - Role.GenRole(type, impostors); + Role.GenRole(role.Role, impostors); } foreach (var crewmate in crewmates) @@ -1283,195 +1281,195 @@ public static void Postfix() { #region Crewmate Roles if (CustomGameOptions.MayorOn > 0) - CrewmateRoles.Add((typeof(Mayor), CustomGameOptions.MayorOn, true)); + CrewmateRoles.Add(new(typeof(Mayor), CustomGameOptions.MayorOn, true)); if (CustomGameOptions.SheriffOn > 0) - CrewmateRoles.Add((typeof(Sheriff), CustomGameOptions.SheriffOn, false)); + CrewmateRoles.Add(new(typeof(Sheriff), CustomGameOptions.SheriffOn, false)); if (CustomGameOptions.EngineerOn > 0) - CrewmateRoles.Add((typeof(Engineer), CustomGameOptions.EngineerOn, false)); + CrewmateRoles.Add(new(typeof(Engineer), CustomGameOptions.EngineerOn, false)); if (CustomGameOptions.SwapperOn > 0) - CrewmateRoles.Add((typeof(Swapper), CustomGameOptions.SwapperOn, true)); + CrewmateRoles.Add(new(typeof(Swapper), CustomGameOptions.SwapperOn, true)); if (CustomGameOptions.InvestigatorOn > 0) - CrewmateRoles.Add((typeof(Investigator), CustomGameOptions.InvestigatorOn, false)); + CrewmateRoles.Add(new(typeof(Investigator), CustomGameOptions.InvestigatorOn, false)); if (CustomGameOptions.MedicOn > 0) - CrewmateRoles.Add((typeof(Medic), CustomGameOptions.MedicOn, true)); + CrewmateRoles.Add(new(typeof(Medic), CustomGameOptions.MedicOn, true)); if (CustomGameOptions.SeerOn > 0) - CrewmateRoles.Add((typeof(Seer), CustomGameOptions.SeerOn, false)); + CrewmateRoles.Add(new(typeof(Seer), CustomGameOptions.SeerOn, false)); if (CustomGameOptions.SpyOn > 0) - CrewmateRoles.Add((typeof(Spy), CustomGameOptions.SpyOn, false)); + CrewmateRoles.Add(new(typeof(Spy), CustomGameOptions.SpyOn, false)); if (CustomGameOptions.SnitchOn > 0) - CrewmateRoles.Add((typeof(Snitch), CustomGameOptions.SnitchOn, true)); + CrewmateRoles.Add(new(typeof(Snitch), CustomGameOptions.SnitchOn, true)); if (CustomGameOptions.AltruistOn > 0) - CrewmateRoles.Add((typeof(Altruist), CustomGameOptions.AltruistOn, true)); + CrewmateRoles.Add(new(typeof(Altruist), CustomGameOptions.AltruistOn, true)); if (CustomGameOptions.VigilanteOn > 0) - CrewmateRoles.Add((typeof(Vigilante), CustomGameOptions.VigilanteOn, false)); + CrewmateRoles.Add(new(typeof(Vigilante), CustomGameOptions.VigilanteOn, false)); if (CustomGameOptions.VeteranOn > 0) - CrewmateRoles.Add((typeof(Veteran), CustomGameOptions.VeteranOn, false)); + CrewmateRoles.Add(new(typeof(Veteran), CustomGameOptions.VeteranOn, false)); if (CustomGameOptions.TrackerOn > 0) - CrewmateRoles.Add((typeof(Tracker), CustomGameOptions.TrackerOn, false)); + CrewmateRoles.Add(new(typeof(Tracker), CustomGameOptions.TrackerOn, false)); if (CustomGameOptions.TransporterOn > 0) - CrewmateRoles.Add((typeof(Transporter), CustomGameOptions.TransporterOn, false)); + CrewmateRoles.Add(new(typeof(Transporter), CustomGameOptions.TransporterOn, false)); if (CustomGameOptions.MediumOn > 0) - CrewmateRoles.Add((typeof(Medium), CustomGameOptions.MediumOn, false)); + CrewmateRoles.Add(new(typeof(Medium), CustomGameOptions.MediumOn, false)); if (CustomGameOptions.MysticOn > 0) - CrewmateRoles.Add((typeof(Mystic), CustomGameOptions.MysticOn, false)); + CrewmateRoles.Add(new(typeof(Mystic), CustomGameOptions.MysticOn, false)); if (CustomGameOptions.TrapperOn > 0) - CrewmateRoles.Add((typeof(Trapper), CustomGameOptions.TrapperOn, false)); + CrewmateRoles.Add(new(typeof(Trapper), CustomGameOptions.TrapperOn, false)); if (CustomGameOptions.DetectiveOn > 0) - CrewmateRoles.Add((typeof(Detective), CustomGameOptions.DetectiveOn, false)); + CrewmateRoles.Add(new(typeof(Detective), CustomGameOptions.DetectiveOn, false)); if (CustomGameOptions.ImitatorOn > 0) - CrewmateRoles.Add((typeof(Imitator), CustomGameOptions.ImitatorOn, true)); + CrewmateRoles.Add(new(typeof(Imitator), CustomGameOptions.ImitatorOn, true)); if (CustomGameOptions.ProsecutorOn > 0) - CrewmateRoles.Add((typeof(Prosecutor), CustomGameOptions.ProsecutorOn, true)); + CrewmateRoles.Add(new(typeof(Prosecutor), CustomGameOptions.ProsecutorOn, true)); if (CustomGameOptions.OracleOn > 0) - CrewmateRoles.Add((typeof(Oracle), CustomGameOptions.OracleOn, true)); + CrewmateRoles.Add(new(typeof(Oracle), CustomGameOptions.OracleOn, true)); if (CustomGameOptions.AurialOn > 0) - CrewmateRoles.Add((typeof(Aurial), CustomGameOptions.AurialOn, false)); + CrewmateRoles.Add(new(typeof(Aurial), CustomGameOptions.AurialOn, false)); #endregion #region Neutral Roles if (CustomGameOptions.JesterOn > 0) - NeutralEvilRoles.Add((typeof(Jester), CustomGameOptions.JesterOn, false)); + NeutralEvilRoles.Add(new(typeof(Jester), CustomGameOptions.JesterOn, false)); if (CustomGameOptions.AmnesiacOn > 0) - NeutralBenignRoles.Add((typeof(Amnesiac), CustomGameOptions.AmnesiacOn, false)); + NeutralBenignRoles.Add(new(typeof(Amnesiac), CustomGameOptions.AmnesiacOn, false)); if (CustomGameOptions.ExecutionerOn > 0) - NeutralEvilRoles.Add((typeof(Executioner), CustomGameOptions.ExecutionerOn, false)); + NeutralEvilRoles.Add(new(typeof(Executioner), CustomGameOptions.ExecutionerOn, false)); if (CustomGameOptions.DoomsayerOn > 0) - NeutralEvilRoles.Add((typeof(Doomsayer), CustomGameOptions.DoomsayerOn, false)); + NeutralEvilRoles.Add(new(typeof(Doomsayer), CustomGameOptions.DoomsayerOn, false)); if (CustomGameOptions.SurvivorOn > 0) - NeutralBenignRoles.Add((typeof(Survivor), CustomGameOptions.SurvivorOn, false)); + NeutralBenignRoles.Add(new(typeof(Survivor), CustomGameOptions.SurvivorOn, false)); if (CustomGameOptions.GuardianAngelOn > 0) - NeutralBenignRoles.Add((typeof(GuardianAngel), CustomGameOptions.GuardianAngelOn, false)); + NeutralBenignRoles.Add(new(typeof(GuardianAngel), CustomGameOptions.GuardianAngelOn, false)); if (CustomGameOptions.GlitchOn > 0) - NeutralKillingRoles.Add((typeof(Glitch), CustomGameOptions.GlitchOn, true)); + NeutralKillingRoles.Add(new(typeof(Glitch), CustomGameOptions.GlitchOn, true)); if (CustomGameOptions.ArsonistOn > 0) - NeutralKillingRoles.Add((typeof(Arsonist), CustomGameOptions.ArsonistOn, true)); + NeutralKillingRoles.Add(new(typeof(Arsonist), CustomGameOptions.ArsonistOn, true)); if (CustomGameOptions.PlaguebearerOn > 0) - NeutralKillingRoles.Add((typeof(Plaguebearer), CustomGameOptions.PlaguebearerOn, true)); + NeutralKillingRoles.Add(new(typeof(Plaguebearer), CustomGameOptions.PlaguebearerOn, true)); if (CustomGameOptions.WerewolfOn > 0) - NeutralKillingRoles.Add((typeof(Werewolf), CustomGameOptions.WerewolfOn, true)); + NeutralKillingRoles.Add(new(typeof(Werewolf), CustomGameOptions.WerewolfOn, true)); if (CustomGameOptions.GameMode == GameMode.Classic && CustomGameOptions.VampireOn > 0) - NeutralKillingRoles.Add((typeof(Vampire), CustomGameOptions.VampireOn, true)); + NeutralKillingRoles.Add(new(typeof(Vampire), CustomGameOptions.VampireOn, true)); if ((CheckJugg() || CustomGameOptions.GameMode == GameMode.AllAny) && CustomGameOptions.HiddenRoles) - NeutralKillingRoles.Add((typeof(Juggernaut), 100, true)); + NeutralKillingRoles.Add(new(typeof(Juggernaut), 100, true)); #endregion #region Impostor Roles if (CustomGameOptions.UndertakerOn > 0) - ImpostorRoles.Add((typeof(Undertaker), CustomGameOptions.UndertakerOn, true)); + ImpostorRoles.Add(new(typeof(Undertaker), CustomGameOptions.UndertakerOn, true)); if (CustomGameOptions.MorphlingOn > 0) - ImpostorRoles.Add((typeof(Morphling), CustomGameOptions.MorphlingOn, false)); + ImpostorRoles.Add(new(typeof(Morphling), CustomGameOptions.MorphlingOn, false)); if (CustomGameOptions.BlackmailerOn > 0) - ImpostorRoles.Add((typeof(Blackmailer), CustomGameOptions.BlackmailerOn, true)); + ImpostorRoles.Add(new(typeof(Blackmailer), CustomGameOptions.BlackmailerOn, true)); if (CustomGameOptions.MinerOn > 0) - ImpostorRoles.Add((typeof(Miner), CustomGameOptions.MinerOn, true)); + ImpostorRoles.Add(new(typeof(Miner), CustomGameOptions.MinerOn, true)); if (CustomGameOptions.SwooperOn > 0) - ImpostorRoles.Add((typeof(Swooper), CustomGameOptions.SwooperOn, false)); + ImpostorRoles.Add(new(typeof(Swooper), CustomGameOptions.SwooperOn, false)); if (CustomGameOptions.JanitorOn > 0) - ImpostorRoles.Add((typeof(Janitor), CustomGameOptions.JanitorOn, false)); + ImpostorRoles.Add(new(typeof(Janitor), CustomGameOptions.JanitorOn, false)); if (CustomGameOptions.GrenadierOn > 0) - ImpostorRoles.Add((typeof(Grenadier), CustomGameOptions.GrenadierOn, true)); + ImpostorRoles.Add(new(typeof(Grenadier), CustomGameOptions.GrenadierOn, true)); if (CustomGameOptions.EscapistOn > 0) - ImpostorRoles.Add((typeof(Escapist), CustomGameOptions.EscapistOn, false)); + ImpostorRoles.Add(new(typeof(Escapist), CustomGameOptions.EscapistOn, false)); if (CustomGameOptions.BomberOn > 0) - ImpostorRoles.Add((typeof(Bomber), CustomGameOptions.BomberOn, true)); + ImpostorRoles.Add(new(typeof(Bomber), CustomGameOptions.BomberOn, true)); if (CustomGameOptions.WarlockOn > 0) - ImpostorRoles.Add((typeof(Warlock), CustomGameOptions.WarlockOn, false)); + ImpostorRoles.Add(new(typeof(Warlock), CustomGameOptions.WarlockOn, false)); if (CustomGameOptions.VenererOn > 0) - ImpostorRoles.Add((typeof(Venerer), CustomGameOptions.VenererOn, true)); + ImpostorRoles.Add(new(typeof(Venerer), CustomGameOptions.VenererOn, true)); #endregion #region Crewmate Modifiers if (Check(CustomGameOptions.TorchOn)) - CrewmateModifiers.Add((typeof(Torch), CustomGameOptions.TorchOn)); + CrewmateModifiers.Add(new(typeof(Torch), CustomGameOptions.TorchOn)); if (Check(CustomGameOptions.DiseasedOn)) - CrewmateModifiers.Add((typeof(Diseased), CustomGameOptions.DiseasedOn)); + CrewmateModifiers.Add(new(typeof(Diseased), CustomGameOptions.DiseasedOn)); if (Check(CustomGameOptions.BaitOn)) - CrewmateModifiers.Add((typeof(Bait), CustomGameOptions.BaitOn)); + CrewmateModifiers.Add(new(typeof(Bait), CustomGameOptions.BaitOn)); if (Check(CustomGameOptions.AftermathOn)) - CrewmateModifiers.Add((typeof(Aftermath), CustomGameOptions.AftermathOn)); + CrewmateModifiers.Add(new(typeof(Aftermath), CustomGameOptions.AftermathOn)); if (Check(CustomGameOptions.MultitaskerOn)) - CrewmateModifiers.Add((typeof(Multitasker), CustomGameOptions.MultitaskerOn)); + CrewmateModifiers.Add(new(typeof(Multitasker), CustomGameOptions.MultitaskerOn)); if (Check(CustomGameOptions.FrostyOn)) - CrewmateModifiers.Add((typeof(Frosty), CustomGameOptions.FrostyOn)); + CrewmateModifiers.Add(new(typeof(Frosty), CustomGameOptions.FrostyOn)); #endregion #region Global Modifiers if (Check(CustomGameOptions.TiebreakerOn)) - GlobalModifiers.Add((typeof(Tiebreaker), CustomGameOptions.TiebreakerOn)); + GlobalModifiers.Add(new(typeof(Tiebreaker), CustomGameOptions.TiebreakerOn)); if (Check(CustomGameOptions.FlashOn)) - GlobalModifiers.Add((typeof(Flash), CustomGameOptions.FlashOn)); + GlobalModifiers.Add(new(typeof(Flash), CustomGameOptions.FlashOn)); if (Check(CustomGameOptions.GiantOn)) - GlobalModifiers.Add((typeof(Giant), CustomGameOptions.GiantOn)); + GlobalModifiers.Add(new(typeof(Giant), CustomGameOptions.GiantOn)); if (Check(CustomGameOptions.ButtonBarryOn)) - ButtonModifiers.Add((typeof(ButtonBarry), CustomGameOptions.ButtonBarryOn)); + ButtonModifiers.Add(new(typeof(ButtonBarry), CustomGameOptions.ButtonBarryOn)); if (Check(CustomGameOptions.LoversOn)) - GlobalModifiers.Add((typeof(Lover), CustomGameOptions.LoversOn)); + GlobalModifiers.Add(new(typeof(Lover), CustomGameOptions.LoversOn)); if (Check(CustomGameOptions.SleuthOn)) - GlobalModifiers.Add((typeof(Sleuth), CustomGameOptions.SleuthOn)); + GlobalModifiers.Add(new(typeof(Sleuth), CustomGameOptions.SleuthOn)); if (Check(CustomGameOptions.RadarOn)) - GlobalModifiers.Add((typeof(Radar), CustomGameOptions.RadarOn)); + GlobalModifiers.Add(new(typeof(Radar), CustomGameOptions.RadarOn)); #endregion #region Impostor Modifiers if (Check(CustomGameOptions.DisperserOn) && GameOptionsManager.Instance.currentNormalGameOptions.MapId != 4 && GameOptionsManager.Instance.currentNormalGameOptions.MapId != 5) - ImpostorModifiers.Add((typeof(Disperser), CustomGameOptions.DisperserOn)); + ImpostorModifiers.Add(new(typeof(Disperser), CustomGameOptions.DisperserOn)); if (Check(CustomGameOptions.DoubleShotOn)) - AssassinModifiers.Add((typeof(DoubleShot), CustomGameOptions.DoubleShotOn)); + AssassinModifiers.Add(new(typeof(DoubleShot), CustomGameOptions.DoubleShotOn)); if (CustomGameOptions.UnderdogOn > 0) - ImpostorModifiers.Add((typeof(Underdog), CustomGameOptions.UnderdogOn)); + ImpostorModifiers.Add(new(typeof(Underdog), CustomGameOptions.UnderdogOn)); #endregion #region Assassin Ability - AssassinAbility.Add((typeof(Assassin), CustomRPC.SetAssassin, 100)); + AssassinAbility.Add(new(typeof(Assassin), CustomRPC.SetAssassin, 100)); #endregion } diff --git a/source/Patches/StopImpKill.cs b/source/Patches/StopImpKill.cs index 83eb432d0..16e29d161 100644 --- a/source/Patches/StopImpKill.cs +++ b/source/Patches/StopImpKill.cs @@ -23,7 +23,7 @@ public static bool Prefix(KillButton __instance) return false; } var interact = Utils.Interact(PlayerControl.LocalPlayer, target, true); - if (interact.abilityUsed) return false; + if (interact.AbilityUsed) return false; if (PlayerControl.LocalPlayer.Is(RoleEnum.Warlock)) { var warlock = Role.GetRole(PlayerControl.LocalPlayer); @@ -35,7 +35,7 @@ public static bool Prefix(KillButton __instance) } PlayerControl.LocalPlayer.SetKillTimer(0.01f); } - else if (interact.fullCooldownReset) + else if (interact.FullCooldownReset) { if (PlayerControl.LocalPlayer.Is(ModifierEnum.Underdog)) { @@ -47,17 +47,17 @@ public static bool Prefix(KillButton __instance) else PlayerControl.LocalPlayer.SetKillTimer(GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown); return false; } - else if (interact.gaReset) + else if (interact.GaReset) { PlayerControl.LocalPlayer.SetKillTimer(CustomGameOptions.ProtectKCReset + 0.01f); return false; } - else if (interact.survReset) + else if (interact.SurvReset) { PlayerControl.LocalPlayer.SetKillTimer(CustomGameOptions.VestKCReset + 0.01f); return false; } - else if (interact.zeroSecReset == true) + else if (interact.ZeroSecReset == true) { PlayerControl.LocalPlayer.SetKillTimer(0.01f); return false; diff --git a/source/Patches/SubmergedCompatibility.cs b/source/Patches/SubmergedCompatibility.cs index 44c3526ed..4fadfd00c 100644 --- a/source/Patches/SubmergedCompatibility.cs +++ b/source/Patches/SubmergedCompatibility.cs @@ -11,7 +11,6 @@ using UnityEngine; using Reactor.Utilities; using TownOfUs.Roles; -using ElevatorData = (bool atTopFloor, object player); namespace TownOfUs.Patches { @@ -174,7 +173,7 @@ public static void Initialize() Types = AccessTools.GetTypesFromAssembly(Assembly); InjectedTypes = (Dictionary)AccessTools.PropertyGetter(Types.FirstOrDefault(t => t.Name == "ComponentExtensions"), "RegisteredTypes") - .Invoke(null, []); + .Invoke(null, Array.Empty()); SubmarineStatusType = Types.First(t => t.Name == "SubmarineStatus"); SubmergedInstance = AccessTools.Field(SubmarineStatusType, "instance"); @@ -221,8 +220,8 @@ public static void CheckOutOfBoundsElevator(PlayerControl player) if (!isSubmerged()) return; ElevatorData elevator = GetPlayerElevator(player); - if (!elevator.atTopFloor) return; - bool CurrentFloor = (bool)UpperDeckIsTargetFloor.GetValue(getSubElevatorSystem.GetValue(elevator.player)); //true is top, false is bottom + if (!elevator.AtTopFloor) return; + bool CurrentFloor = (bool)UpperDeckIsTargetFloor.GetValue(getSubElevatorSystem.GetValue(elevator.Player)); //true is top, false is bottom bool PlayerFloor = player.transform.position.y > -7f; //true is top, false is bottom if (CurrentFloor != PlayerFloor) @@ -235,13 +234,13 @@ public static void MoveDeadPlayerElevator(PlayerControl player) { if (!isSubmerged()) return; ElevatorData elevator = GetPlayerElevator(player); - if (!elevator.atTopFloor) return; + if (!elevator.AtTopFloor) return; - int MovementStage = (int)GetMovementStageFromTime.Invoke(elevator.player, null); + int MovementStage = (int)GetMovementStageFromTime.Invoke(elevator.Player, null); if (MovementStage >= 5) { //Fade to clear - bool topfloortarget = (bool)UpperDeckIsTargetFloor.GetValue(getSubElevatorSystem.GetValue(elevator.player)); //true is top, false is bottom + bool topfloortarget = (bool)UpperDeckIsTargetFloor.GetValue(getSubElevatorSystem.GetValue(elevator.Player)); //true is top, false is bottom bool topintendedtarget = player.transform.position.y > -7f; //true is top, false is bottom if (topfloortarget != topintendedtarget) { diff --git a/source/Patches/TupleObjects.cs b/source/Patches/TupleObjects.cs new file mode 100644 index 000000000..e81573f9f --- /dev/null +++ b/source/Patches/TupleObjects.cs @@ -0,0 +1,55 @@ +using System; + +namespace TownOfUs +{ + // records are a nice 1 liner that are ok if values arent modified after creation. + // if modification needed, use class. + + public record RoleData(Type Role, int Chance, bool Unique); + + + public record ModifierData(Type Modifier, int Chance); + + + public record AbilityData(Type Ability, CustomRPC Rpc, int Chance); + + + public record ElevatorData(bool AtTopFloor, object Player); + + + public class InteractionData + { + public bool FullCooldownReset { get; set; } + + public bool GaReset { get; set; } + + public bool SurvReset { get; set; } + + public bool ZeroSecReset { get; set; } + + public bool AbilityUsed { get; set; } + + public InteractionData(bool fullCooldownReset, bool gaReset, bool survReset, bool zeroSecReset, bool abilityUsed) + { + FullCooldownReset = fullCooldownReset; + GaReset = gaReset; + SurvReset = survReset; + ZeroSecReset = zeroSecReset; + AbilityUsed = abilityUsed; + } + } + + + public class ConversionData + { + public PlayerControl Player { get; set; } + + public int UnconvertableChance { get; set; } + + public ConversionData(PlayerControl player, int unconvertableChance) + { + Player = player; + UnconvertableChance = unconvertableChance; + } + } +} \ No newline at end of file diff --git a/source/Patches/Utils.cs b/source/Patches/Utils.cs index 011a86f7b..a9e23226a 100644 --- a/source/Patches/Utils.cs +++ b/source/Patches/Utils.cs @@ -26,7 +26,6 @@ using TownOfUs.CrewmateRoles.AurialMod; using Reactor.Networking; using Reactor.Networking.Extensions; -using InteractionData = (bool fullCooldownReset, bool gaReset, bool survReset, bool zeroSecReset, bool abilityUsed); namespace TownOfUs { @@ -221,7 +220,7 @@ public static InteractionData Interact(PlayerControl player, PlayerControl targe } if (target == ShowRoundOneShield.FirstRoundShielded && toKill) { - data.zeroSecReset = true; + data.ZeroSecReset = true; } else if (target.Is(RoleEnum.Pestilence)) { @@ -230,28 +229,28 @@ public static InteractionData Interact(PlayerControl player, PlayerControl targe var medic = player.GetMedic().Player.PlayerId; Rpc(CustomRPC.AttemptSound, medic, player.PlayerId); - if (CustomGameOptions.ShieldBreaks) data.fullCooldownReset = true; - else data.zeroSecReset = true; + if (CustomGameOptions.ShieldBreaks) data.FullCooldownReset = true; + else data.ZeroSecReset = true; StopKill.BreakShield(medic, player.PlayerId, CustomGameOptions.ShieldBreaks); } - else if (player.IsProtected()) data.gaReset = true; + else if (player.IsProtected()) data.GaReset = true; else RpcMurderPlayer(target, player); } else if (target.IsOnAlert()) { - if (player.Is(RoleEnum.Pestilence)) data.zeroSecReset = true; + if (player.Is(RoleEnum.Pestilence)) data.ZeroSecReset = true; else if (player.IsShielded()) { var medic = player.GetMedic().Player.PlayerId; Rpc(CustomRPC.AttemptSound, medic, player.PlayerId); - if (CustomGameOptions.ShieldBreaks) data.fullCooldownReset = true; - else data.zeroSecReset = true; + if (CustomGameOptions.ShieldBreaks) data.FullCooldownReset = true; + else data.ZeroSecReset = true; StopKill.BreakShield(medic, player.PlayerId, CustomGameOptions.ShieldBreaks); } - else if (player.IsProtected()) data.gaReset = true; + else if (player.IsProtected()) data.GaReset = true; else RpcMurderPlayer(target, player); if (toKill && CustomGameOptions.KilledOnAlert) { @@ -260,12 +259,12 @@ public static InteractionData Interact(PlayerControl player, PlayerControl targe var medic = target.GetMedic().Player.PlayerId; Rpc(CustomRPC.AttemptSound, medic, target.PlayerId); - if (CustomGameOptions.ShieldBreaks) data.fullCooldownReset = true; - else data.zeroSecReset = true; + if (CustomGameOptions.ShieldBreaks) data.FullCooldownReset = true; + else data.ZeroSecReset = true; StopKill.BreakShield(medic, target.PlayerId, CustomGameOptions.ShieldBreaks); } - else if (target.IsProtected()) data.gaReset = true; + else if (target.IsProtected()) data.GaReset = true; else { if (player.Is(RoleEnum.Glitch)) @@ -300,10 +299,10 @@ public static InteractionData Interact(PlayerControl player, PlayerControl targe ww.LastKilled = DateTime.UtcNow; } RpcMurderPlayer(player, target); - data.abilityUsed = true; - data.fullCooldownReset = true; - data.gaReset = false; - data.zeroSecReset = false; + data.AbilityUsed = true; + data.FullCooldownReset = true; + data.GaReset = false; + data.ZeroSecReset = false; } } } @@ -312,17 +311,17 @@ public static InteractionData Interact(PlayerControl player, PlayerControl targe Rpc(CustomRPC.AttemptSound, target.GetMedic().Player.PlayerId, target.PlayerId); System.Console.WriteLine(CustomGameOptions.ShieldBreaks + "- shield break"); - if (CustomGameOptions.ShieldBreaks) data.fullCooldownReset = true; - else data.zeroSecReset = true; + if (CustomGameOptions.ShieldBreaks) data.FullCooldownReset = true; + else data.ZeroSecReset = true; StopKill.BreakShield(target.GetMedic().Player.PlayerId, target.PlayerId, CustomGameOptions.ShieldBreaks); } else if (target.IsVesting() && toKill) { - data.survReset = true; + data.SurvReset = true; } else if (target.IsProtected() && toKill) { - data.gaReset = true; + data.GaReset = true; } else if (toKill) { @@ -358,13 +357,13 @@ public static InteractionData Interact(PlayerControl player, PlayerControl targe ww.LastKilled = DateTime.UtcNow; } RpcMurderPlayer(player, target); - data.abilityUsed = true; - data.fullCooldownReset = true; + data.AbilityUsed = true; + data.FullCooldownReset = true; } else { - data.abilityUsed = true; - data.fullCooldownReset = true; + data.AbilityUsed = true; + data.FullCooldownReset = true; } return data;