diff --git a/source/Patches/CrewmateRoles/DetectiveMod/PerformKill.cs b/source/Patches/CrewmateRoles/DetectiveMod/PerformKill.cs index 1cae80635..cef0fe728 100644 --- a/source/Patches/CrewmateRoles/DetectiveMod/PerformKill.cs +++ b/source/Patches/CrewmateRoles/DetectiveMod/PerformKill.cs @@ -29,23 +29,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.DetectedKillers.Contains(role.ClosestPlayer.PlayerId) || (CustomGameOptions.CanDetectLastKiller && role.LastKiller == role.ClosestPlayer)) 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 f555d1d52..983e47380 100644 --- a/source/Patches/CrewmateRoles/MedicMod/Protect.cs +++ b/source/Patches/CrewmateRoles/MedicMod/Protect.cs @@ -18,7 +18,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 87945471f..201cda3d1 100644 --- a/source/Patches/CrewmateRoles/OracleMod/PerformKill.cs +++ b/source/Patches/CrewmateRoles/OracleMod/PerformKill.cs @@ -25,7 +25,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; @@ -54,18 +54,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..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[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..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[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..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[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 da0dcfde2..9226d9b9c 100644 --- a/source/Patches/CultistRoles/WhispererMod/PerformKill.cs +++ b/source/Patches/CultistRoles/WhispererMod/PerformKill.cs @@ -30,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 = new(); 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; @@ -51,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 d7b3385a1..b23dd6846 100644 --- a/source/Patches/CultistRoles/WhispererMod/TargetColor.cs +++ b/source/Patches/CultistRoles/WhispererMod/TargetColor.cs @@ -30,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); } @@ -60,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 f6d07d67e..94e131102 100644 --- a/source/Patches/ImpostorRoles/BlackmailerMod/PerformKill.cs +++ b/source/Patches/ImpostorRoles/BlackmailerMod/PerformKill.cs @@ -23,7 +23,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 c3fb259bf..3cb0057bf 100644 --- a/source/Patches/ImpostorRoles/MinerMod/PerformKill.cs +++ b/source/Patches/ImpostorRoles/MinerMod/PerformKill.cs @@ -24,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).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 abfa08472..4cf20cd0b 100644 --- a/source/Patches/NeutralRoles/ArsonistMod/PerformKill.cs +++ b/source/Patches/NeutralRoles/ArsonistMod/PerformKill.cs @@ -29,19 +29,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; @@ -56,19 +56,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..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[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 19245e76a..d66d7c704 100644 --- a/source/Patches/NeutralRoles/JuggernautMod/PerformKill.cs +++ b/source/Patches/NeutralRoles/JuggernautMod/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.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..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[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 f748ca36a..0dea96b18 100644 --- a/source/Patches/NeutralRoles/PlaguebearerMod/PerformKill.cs +++ b/source/Patches/NeutralRoles/PlaguebearerMod/PerformKill.cs @@ -24,18 +24,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..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[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..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[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..298a62136 100644 --- a/source/Patches/Roles/Cultist/Whisperer.cs +++ b/source/Patches/Roles/Cultist/Whisperer.cs @@ -10,7 +10,7 @@ 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; @@ -48,15 +48,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 108ed1617..85728b12e 100644 --- a/source/Patches/Roles/Glitch.cs +++ b/source/Patches/Roles/Glitch.cs @@ -509,28 +509,28 @@ public static void KillButtonPress(Glitch __gInstance) { if (__gInstance.Player.inVent) return; var interact = Utils.Interact(__gInstance.Player, __gInstance.KillTarget, true); - if (interact[4]) + if (interact.AbilityUsed) { return; } - else if (interact[0]) + else if (interact.FullCooldownReset) { __gInstance.LastKill = DateTime.UtcNow; return; } - else if (interact[1]) + else if (interact.GaReset) { __gInstance.LastKill = DateTime.UtcNow; __gInstance.LastKill = __gInstance.LastKill.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.GlitchKillCooldown); return; } - else if (interact[2]) + else if (interact.SurvReset) { __gInstance.LastKill = DateTime.UtcNow; __gInstance.LastKill = __gInstance.LastKill.AddSeconds(CustomGameOptions.VestKCReset - CustomGameOptions.GlitchKillCooldown); return; } - else if (interact[3]) + else if (interact.ZeroSecReset) { return; } @@ -589,16 +589,16 @@ public static void HackButtonPress(Glitch __gInstance) if (__gInstance.HackTarget != null) { var interact = Utils.Interact(__gInstance.Player, __gInstance.HackTarget); - if (interact[4]) + if (interact.AbilityUsed) { __gInstance.RpcSetHacked(__gInstance.HackTarget); } - if (interact[0]) + if (interact.FullCooldownReset) { __gInstance.LastHack = DateTime.UtcNow; return; } - else if (interact[1]) + else if (interact.GaReset) { __gInstance.LastHack = DateTime.UtcNow; __gInstance.LastHack.AddSeconds(CustomGameOptions.ProtectKCReset - CustomGameOptions.HackCooldown); @@ -608,6 +608,7 @@ public static void HackButtonPress(Glitch __gInstance) { return; } + else if (interact.ZeroSecReset) return; return; } } diff --git a/source/Patches/RpcHandling.cs b/source/Patches/RpcHandling.cs index c74a2c663..072008e26 100644 --- a/source/Patches/RpcHandling.cs +++ b/source/Patches/RpcHandling.cs @@ -41,17 +41,17 @@ 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; @@ -74,7 +74,7 @@ private static int PickRoleCount(int min, int max) return Random.RandomRangeInt(min, max + 1); } - private static void SortRoles(this List<(Type, int, bool)> roles, int max) + private static void SortRoles(this List roles, int max) { if (max <= 0) { @@ -82,7 +82,7 @@ private static void SortRoles(this List<(Type, int, bool)> roles, int max) return; } - var chosenRoles = roles.Where(x => x.Item2 == 100).ToList(); + var chosenRoles = roles.Where(x => x.Chance == 100).ToList(); // Shuffle to ensure that the same 100% roles do not appear in // every game if there are more than the maximum. chosenRoles.Shuffle(); @@ -92,9 +92,9 @@ private static void SortRoles(this List<(Type, int, bool)> roles, int max) if (chosenRoles.Count < max) { // These roles MAY appear in this game, but they may not. - var potentialRoles = roles.Where(x => x.Item2 < 100).ToList(); + var potentialRoles = roles.Where(x => x.Chance < 100).ToList(); // Determine which roles appear in this game. - var optionalRoles = potentialRoles.Where(x => Check(x.Item2)).ToList(); + var optionalRoles = potentialRoles.Where(x => Check(x.Chance)).ToList(); potentialRoles = potentialRoles.Where(x => !optionalRoles.Contains(x)).ToList(); optionalRoles.Shuffle(); @@ -114,17 +114,17 @@ private static void SortRoles(this List<(Type, int, bool)> roles, int max) roles.AddRange(chosenRoles); } - private static void SortModifiers(this List<(Type, int)> roles, int max) + private static void SortModifiers(this List roles, int max) { - var newList = roles.Where(x => x.Item2 == 100).ToList(); + var newList = roles.Where(x => x.Chance == 100).ToList(); newList.Shuffle(); if (roles.Count < max) max = roles.Count; - var roles2 = roles.Where(x => x.Item2 < 100).ToList(); + var roles2 = roles.Where(x => x.Chance < 100).ToList(); roles2.Shuffle(); - newList.AddRange(roles2.Where(x => Check(x.Item2))); + newList.AddRange(roles2.Where(x => Check(x.Chance))); while (newList.Count > max) { @@ -214,7 +214,7 @@ private static void GenEachRole(List infected) NeutralKillingRoles.SortRoles(killing); if (NeutralKillingRoles.Contains((typeof(Vampire), CustomGameOptions.VampireOn, true)) && CustomGameOptions.VampireHunterOn > 0) - CrewmateRoles.Add((typeof(VampireHunter), CustomGameOptions.VampireHunterOn, true)); + CrewmateRoles.Add(new(typeof(VampireHunter), CustomGameOptions.VampireHunterOn, true)); CrewmateRoles.SortRoles(crewmates.Count - NeutralBenignRoles.Count - NeutralEvilRoles.Count - NeutralKillingRoles.Count); ImpostorRoles.SortRoles(impostors.Count); @@ -237,7 +237,7 @@ private static void GenEachRole(List infected) neutRoles.Shuffle(); crewRoles.Add(neutRoles[0]); // If it's unique, remove it from the list. - if (neutRoles[0].Item3 == true) neutRoles.Remove(neutRoles[0]); + if (neutRoles[0].Unique == true) neutRoles.Remove(neutRoles[0]); } // Add one crewmate role to the game, or vanilla Crewmate if none are enabled. // This guarantees at least one crewmate role's presence. @@ -245,14 +245,14 @@ private static void GenEachRole(List infected) { CrewmateRoles.Shuffle(); crewRoles.Add(CrewmateRoles[0]); - if (CrewmateRoles[0].Item3 == true) 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)); } // Now add all the roles together. - var allAnyRoles = new List<(Type, int, bool)>(); + var allAnyRoles = new List(); allAnyRoles.AddRange(CrewmateRoles); allAnyRoles.AddRange(neutRoles); allAnyRoles.Shuffle(); @@ -260,14 +260,14 @@ private static void GenEachRole(List infected) while (crewRoles.Count < crewmates.Count && allAnyRoles.Count > 0) { crewRoles.Add(allAnyRoles[0]); - if (allAnyRoles[0].Item3 == true) allAnyRoles.Remove(allAnyRoles[0]); + if (allAnyRoles[0].Unique == true) allAnyRoles.Remove(allAnyRoles[0]); } // Add impostor roles up to the impostor count, including duplicates (unless defined as unique). ImpostorRoles.Shuffle(); while (impRoles.Count < impostors.Count && ImpostorRoles.Count > 0) { impRoles.Add(ImpostorRoles[0]); - if (ImpostorRoles[0].Item3 == true) ImpostorRoles.Remove(ImpostorRoles[0]); + if (ImpostorRoles[0].Unique) ImpostorRoles.Remove(ImpostorRoles[0]); } } else @@ -327,10 +327,10 @@ private static void GenEachRole(List infected) AssassinModifiers.SortModifiers(canHaveAssassinModifier.Count); AssassinModifiers.Shuffle(); - foreach (var (type, _) in AssassinModifiers) + foreach (var mod in AssassinModifiers) { if (canHaveAssassinModifier.Count == 0) break; - Role.GenModifier(type, canHaveAssassinModifier); + Role.GenModifier(mod.Modifier, canHaveAssassinModifier); } // Hand out impostor modifiers. @@ -342,7 +342,7 @@ private static void GenEachRole(List infected) foreach (var (type, _) in ImpostorModifiers) { if (canHaveImpModifier.Count == 0) break; - Role.GenModifier(type, canHaveImpModifier); + Role.GenModifier(mod.Modifier, canHaveImpModifier); } // Hand out global modifiers. @@ -353,17 +353,17 @@ private static void GenEachRole(List infected) GlobalModifiers.SortModifiers(canHaveModifier.Count); GlobalModifiers.Shuffle(); - 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); } } @@ -371,10 +371,10 @@ private static void GenEachRole(List infected) canHaveModifier.RemoveAll(player => player.Is(RoleEnum.Glitch)); ButtonModifiers.SortModifiers(canHaveModifier.Count); - 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); } // Now hand out Crewmate Modifiers to all remaining eligible players. @@ -384,8 +384,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()); } // Set the Traitor, if there is one enabled. @@ -484,23 +484,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)); ImpostorRoles.SortRoles(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; @@ -512,13 +512,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) @@ -530,24 +530,24 @@ 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; } } - var crewAndNeutralRoles = new List<(Type, int, bool)>(); + var crewAndNeutralRoles = new List(); crewAndNeutralRoles.AddRange(CrewmateRoles); crewAndNeutralRoles.AddRange(NeutralKillingRoles); 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) @@ -557,13 +557,13 @@ 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)>(); - 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)); + var specialRoles = new List(); + var crewRoles = new List(); + var impRole = new List(); + 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) specialRoles.SortRoles(CustomGameOptions.SpecialRoleCount); if (specialRoles.Count > crewmates.Count) specialRoles.SortRoles(crewmates.Count); if (specialRoles.Count < crewmates.Count) @@ -578,61 +578,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--; } crewRoles.SortRoles(crewmates.Count - specialRoles.Count); } - impRole.Add((typeof(Necromancer), 100, true)); - impRole.Add((typeof(Whisperer), 100, true)); + impRole.Add(new(typeof(Necromancer), 100, true)); + impRole.Add(new(typeof(Whisperer), 100, true)); impRole.SortRoles(1); - foreach (var (type, _, unique) in specialRoles) + foreach (var role in specialRoles) { - Role.GenRole(type, crewmates); + Role.GenRole(role.Role, crewmates); } - 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 impRole) + foreach (var role in impRole) { - Role.GenRole(type, impostors); + Role.GenRole(role.Role, impostors); } foreach (var crewmate in crewmates) @@ -1144,12 +1144,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; @@ -1181,7 +1183,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()); @@ -1296,198 +1298,198 @@ 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.HunterOn > 0) - CrewmateRoles.Add((typeof(Hunter), CustomGameOptions.HunterOn, false)); + CrewmateRoles.Add(new(typeof(Hunter), CustomGameOptions.HunterOn, 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)) - 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 d0256baca..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[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 1fe5fca67..821ad8e20 100644 --- a/source/Patches/SubmergedCompatibility.cs +++ b/source/Patches/SubmergedCompatibility.cs @@ -195,7 +195,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)); } @@ -205,9 +205,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) @@ -219,14 +219,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) { @@ -235,17 +235,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/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 35da78fe0..dff132fc5 100644 --- a/source/Patches/Utils.cs +++ b/source/Patches/Utils.cs @@ -211,20 +211,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)) { @@ -233,28 +229,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) { @@ -263,12 +259,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)) @@ -303,10 +299,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; } } } @@ -315,17 +311,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) { @@ -361,16 +357,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; } - if (abilityUsed) + if (data.AbilityUsed) { foreach (Role role in Role.GetRoles(RoleEnum.Hunter)) { @@ -379,13 +375,8 @@ public static List Interact(PlayerControl player, PlayerControl target, bo } } - 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) @@ -1131,7 +1122,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);