From 8a40a79c2847f374d44e1fc80aa9910f6dd90667 Mon Sep 17 00:00:00 2001 From: Gurge44 Date: Fri, 31 May 2024 21:35:37 +0200 Subject: [PATCH] fix bugs --- GameMode/MoveAndStopManager.cs | 4 +-- Modules/CustomRolesHelper.cs | 9 +++--- Modules/ErrorText.cs | 2 +- Modules/ExtendedPlayerControl.cs | 10 +++--- Modules/Extensions/HazelExtensions.cs | 46 +++++++++++++++++++++++++++ Modules/GameState.cs | 8 ++++- Modules/LocateArrow.cs | 4 +-- Modules/NameColorManager.cs | 4 +-- Modules/OptionHolder.cs | 14 ++++---- Modules/OptionItem/OptionItem.cs | 2 +- Modules/OptionSaver.cs | 4 +-- Modules/TemplateManager.cs | 2 +- Modules/Utils.cs | 27 ++++++---------- Patches/ChatCommandPatch.cs | 2 +- Patches/DeconSystemPatch.cs | 4 +-- Patches/ExilePatch.cs | 2 +- Patches/GameOptionsMenuPatch.cs | 2 +- Patches/HudPatch.cs | 2 +- Patches/IntroPatch.cs | 6 ++-- Patches/MeetingHudPatch.cs | 4 +-- Patches/OnGameStartedPatch.cs | 2 +- Patches/PlayerControlPatch.cs | 2 +- Patches/SabotageSystemPatch.cs | 2 +- Patches/ShipStatusPatch.cs | 2 +- Roles/Crewmate/CameraMan.cs | 2 +- Roles/Crewmate/CopyCat.cs | 2 +- Roles/Crewmate/Divinator.cs | 14 +++----- Roles/Crewmate/Enigma.cs | 4 +-- Roles/Crewmate/Medic.cs | 6 ++-- Roles/Crewmate/ParityCop.cs | 2 +- Roles/Crewmate/Sheriff.cs | 4 +-- Roles/Crewmate/Tornado.cs | 2 +- Roles/Impostor/EvilTracker.cs | 2 +- Roles/Impostor/Witch.cs | 2 +- Roles/Neutral/Amnesiac.cs | 2 +- Roles/Neutral/Executioner.cs | 2 +- Roles/Neutral/FFF.cs | 2 +- Roles/Neutral/Jackal.cs | 2 +- Roles/Neutral/Lawyer.cs | 4 +-- Roles/Neutral/Necromancer.cs | 2 +- Roles/Neutral/Pelican.cs | 2 +- Roles/Neutral/PlagueDoctor.cs | 2 +- Roles/Neutral/Sidekick.cs | 2 +- Roles/Neutral/Succubus.cs | 2 +- Roles/Neutral/Virus.cs | 2 +- Roles/Neutral/WeaponMaster.cs | 2 +- 46 files changed, 135 insertions(+), 97 deletions(-) create mode 100644 Modules/Extensions/HazelExtensions.cs diff --git a/GameMode/MoveAndStopManager.cs b/GameMode/MoveAndStopManager.cs index 7311a3dcc..36e01653c 100644 --- a/GameMode/MoveAndStopManager.cs +++ b/GameMode/MoveAndStopManager.cs @@ -205,7 +205,7 @@ internal class MoveAndStopManager '→' => Random.Next(MoveAndStop_RightCounterRedMin.GetInt(), MoveAndStop_RightCounterRedMax.GetInt()), '●' => Random.Next(MoveAndStop_MiddleCounterRedMin.GetInt(), MoveAndStop_MiddleCounterRedMax.GetInt()), '←' => Random.Next(MoveAndStop_LeftCounterRedMin.GetInt(), MoveAndStop_LeftCounterRedMax.GetInt()), - _ => throw new NotImplementedException(), + _ => throw new NotImplementedException() }; public static int RandomGreenTime(char direction) => ExtraGreenTime + direction switch @@ -213,7 +213,7 @@ internal class MoveAndStopManager '→' => Random.Next(MoveAndStop_RightCounterGreenMin.GetInt(), MoveAndStop_RightCounterGreenMax.GetInt()), '●' => Random.Next(MoveAndStop_MiddleCounterGreenMin.GetInt(), MoveAndStop_MiddleCounterGreenMax.GetInt()), '←' => Random.Next(MoveAndStop_LeftCounterGreenMin.GetInt(), MoveAndStop_LeftCounterGreenMax.GetInt()), - _ => throw new NotImplementedException(), + _ => throw new NotImplementedException() }; private static string CounterSettingString(string direction, bool red, bool min) => $"MoveAndStop_{direction}Counter{(red ? "Red" : "Green")}{(min ? "Min" : "Max")}"; diff --git a/Modules/CustomRolesHelper.cs b/Modules/CustomRolesHelper.cs index e15009a0e..17e4838dc 100644 --- a/Modules/CustomRolesHelper.cs +++ b/Modules/CustomRolesHelper.cs @@ -784,12 +784,11 @@ internal static class CustomRolesHelper CustomRoles.Hangman or CustomRoles.Generator; - public static bool CheckAddonConflict(CustomRoles role, PlayerControl pc) => role.IsAdditionRole() && (!Main.NeverSpawnTogetherCombos.TryGetValue(pc.GetCustomRole(), out var bannedAddonList) || !bannedAddonList.Contains(role)) && pc.GetCustomRole() is not CustomRoles.GuardianAngelEHR and not CustomRoles.God && !pc.Is(CustomRoles.Madmate) && !pc.Is(CustomRoles.Egoist) && !pc.Is(CustomRoles.GM) && role is not CustomRoles.Lovers && !pc.Is(CustomRoles.Needy) && (!pc.HasSubRole() || pc.GetCustomSubRoles().Count < Options.NoLimitAddonsNumMax.GetInt()) && (!Options.AddonCanBeSettings.TryGetValue(role, out var o) || ((o.Imp.GetBool() || !pc.GetCustomRole().IsImpostor()) && (o.Neutral.GetBool() || !pc.GetCustomRole().IsNeutral()) && (o.Crew.GetBool() || !pc.IsCrewmate()))) && role switch + public static bool CheckAddonConflict(CustomRoles role, PlayerControl pc) => role.IsAdditionRole() && (!Main.NeverSpawnTogetherCombos.TryGetValue(pc.GetCustomRole(), out var bannedAddonList) || !bannedAddonList.Contains(role)) && pc.GetCustomRole() is not CustomRoles.GuardianAngelEHR and not CustomRoles.God && !pc.Is(CustomRoles.Madmate) && !pc.Is(CustomRoles.GM) && role is not CustomRoles.Lovers && !pc.Is(CustomRoles.Needy) && (!pc.HasSubRole() || pc.GetCustomSubRoles().Count < Options.NoLimitAddonsNumMax.GetInt()) && (!Options.AddonCanBeSettings.TryGetValue(role, out var o) || ((o.Imp.GetBool() || !pc.GetCustomRole().IsImpostor()) && (o.Neutral.GetBool() || !pc.GetCustomRole().IsNeutral()) && (o.Crew.GetBool() || !pc.IsCrewmate()))) && role switch { CustomRoles.Energetic when !Options.UsePets.GetBool() => false, CustomRoles.Sidekick when pc.Is(CustomRoles.Madmate) => false, CustomRoles.Madmate when pc.Is(CustomRoles.Sidekick) => false, - CustomRoles.Egoist when pc.Is(CustomRoles.Sidekick) => false, CustomRoles.Autopsy when pc.Is(CustomRoles.Doctor) || pc.Is(CustomRoles.Tracefinder) || pc.Is(CustomRoles.Scientist) || pc.Is(CustomRoles.ScientistEHR) || pc.Is(CustomRoles.Sunnyboy) => false, CustomRoles.Necroview when pc.Is(CustomRoles.Doctor) => false, CustomRoles.Lazy when pc.Is(CustomRoles.Speedrunner) => false, @@ -909,7 +908,7 @@ internal static class CustomRolesHelper Team.Neutral => role.IsNeutralTeamV2(), Team.Crewmate => role.IsCrewmateTeamV2(), Team.None => role.GetCountTypes() is CountTypes.OutOfGame or CountTypes.None || role == CustomRoles.GM, - _ => false, + _ => false }; public static RoleTypes GetRoleTypes(this CustomRoles role) @@ -923,7 +922,7 @@ internal static class CustomRolesHelper CustomRoles.GuardianAngel => RoleTypes.GuardianAngel, CustomRoles.Shapeshifter => RoleTypes.Shapeshifter, CustomRoles.Crewmate => RoleTypes.Crewmate, - _ => role.IsImpostor() ? RoleTypes.Impostor : RoleTypes.Crewmate, + _ => role.IsImpostor() ? RoleTypes.Impostor : RoleTypes.Crewmate }; } @@ -935,7 +934,7 @@ internal static class CustomRolesHelper public static bool IsNeutralTeamV2(this CustomRoles role) => role.IsConverted() || (role.IsNeutral() && role != CustomRoles.Madmate); public static bool IsCrewmateTeamV2(this CustomRoles role) => (!role.IsImpostorTeamV2() && !role.IsNeutralTeamV2()) || (role == CustomRoles.Trickster && !role.IsConverted()); - public static bool IsConverted(this CustomRoles role) => ((role is CustomRoles.Egoist) && (ParityCop.ParityCheckEgoistInt() == 1)) || role is + public static bool IsConverted(this CustomRoles role) => (role == CustomRoles.Egoist && ParityCop.ParityCheckEgoistInt() == 1) || role is CustomRoles.Charmed or CustomRoles.Recruit or CustomRoles.Contagious or diff --git a/Modules/ErrorText.cs b/Modules/ErrorText.cs index 518973da7..dce18c90f 100644 --- a/Modules/ErrorText.cs +++ b/Modules/ErrorText.cs @@ -197,5 +197,5 @@ public enum ErrorCode TestError3 = 0009303, // 000-930-3 Test Error 3 HnsUnload = 000_804_1, // 000-804-1 Unloaded By HnS CheatDetected = 000_666_2, // 000-666-2 疑似存在作弊玩家 - SBDetected = 000_666_1, // 000-666-1 傻逼外挂司马东西 + SBDetected = 000_666_1 // 000-666-1 傻逼外挂司马东西 } \ No newline at end of file diff --git a/Modules/ExtendedPlayerControl.cs b/Modules/ExtendedPlayerControl.cs index 8acea9568..af2fffbb2 100644 --- a/Modules/ExtendedPlayerControl.cs +++ b/Modules/ExtendedPlayerControl.cs @@ -185,7 +185,7 @@ static class ExtendedPlayerControl { MapNames.Polus => SystemTypes.Laboratory, MapNames.Airship => SystemTypes.HeliSabotage, - _ => SystemTypes.Reactor, + _ => SystemTypes.Reactor }; bool ReactorCheck = IsActive(systemtypes); //Checking whether the reactor sabotage is active @@ -547,7 +547,7 @@ static class ExtendedPlayerControl { MapNames.Polus => SystemTypes.Laboratory, MapNames.Airship => SystemTypes.HeliSabotage, - _ => SystemTypes.Reactor, + _ => SystemTypes.Reactor }; LateTask.New(() => { pc.RpcDesyncRepairSystem(systemtypes, 128); }, 0f + delay, "Reactor Desync"); @@ -572,7 +572,7 @@ static class ExtendedPlayerControl { MapNames.Polus => SystemTypes.Laboratory, MapNames.Airship => SystemTypes.HeliSabotage, - _ => SystemTypes.Reactor, + _ => SystemTypes.Reactor }; float FlashDuration = Options.KillFlashDuration.GetFloat(); @@ -677,7 +677,7 @@ static class ExtendedPlayerControl // Hot Potato CustomRoles.Potato => false, - _ => Main.PlayerStates.TryGetValue(pc.PlayerId, out var state) && state.Role.CanUseImpostorVentButton(pc), + _ => Main.PlayerStates.TryGetValue(pc.PlayerId, out var state) && state.Role.CanUseImpostorVentButton(pc) }; } @@ -1025,7 +1025,7 @@ static class ExtendedPlayerControl Team.Neutral => target.GetCustomRole().IsNeutralTeamV2() || target.Is(CustomRoles.Bloodlust), Team.Crewmate => target.GetCustomRole().IsCrewmateTeamV2(), Team.None => target.Is(CustomRoles.GM) || target.Is(CountTypes.None) || target.Is(CountTypes.OutOfGame), - _ => false, + _ => false }; public static Team GetTeam(this PlayerControl target) diff --git a/Modules/Extensions/HazelExtensions.cs b/Modules/Extensions/HazelExtensions.cs new file mode 100644 index 000000000..b45193343 --- /dev/null +++ b/Modules/Extensions/HazelExtensions.cs @@ -0,0 +1,46 @@ +using Hazel; +using UnityEngine; + +namespace EHR +{ + public static class HazelExtensions + { + public static void Write(this MessageWriter writer, Vector2 vector) => NetHelpers.WriteVector2(vector, writer); + + public static void Write(this MessageWriter writer, Vector3 vector) + { + writer.Write(vector.x); + writer.Write(vector.y); + writer.Write(vector.z); + } + + public static void Write(this MessageWriter writer, Color color) + { + writer.Write(color.r); + writer.Write(color.g); + writer.Write(color.b); + writer.Write(color.a); + } + + // ------------------------------------------------------------------------------------------------------------------------- + + public static Vector2 ReadVector2(this MessageReader reader) => NetHelpers.ReadVector2(reader); + + public static Vector3 ReadVector3(this MessageReader reader) + { + float x = reader.ReadSingle(); + float y = reader.ReadSingle(); + float z = reader.ReadSingle(); + return new(x, y, z); + } + + public static Color ReadColor(this MessageReader reader) + { + float r = reader.ReadSingle(); + float g = reader.ReadSingle(); + float b = reader.ReadSingle(); + float a = reader.ReadSingle(); + return new(r, g, b, a); + } + } +} \ No newline at end of file diff --git a/Modules/GameState.cs b/Modules/GameState.cs index db73a5257..92eca0d86 100644 --- a/Modules/GameState.cs +++ b/Modules/GameState.cs @@ -87,7 +87,7 @@ public class PlayerState(byte playerId) RoleTypes.GuardianAngel => CustomRoles.GuardianAngel, RoleTypes.Impostor => CustomRoles.Impostor, RoleTypes.Shapeshifter => CustomRoles.Shapeshifter, - _ => CustomRoles.Crewmate, + _ => CustomRoles.Crewmate }; } @@ -97,6 +97,12 @@ public class PlayerState(byte playerId) { CustomRoles.DarkHide => !DarkHide.SnatchesWin.GetBool() ? CountTypes.DarkHide : CountTypes.Crew, CustomRoles.Arsonist => Options.ArsonistKeepsGameGoing.GetBool() ? CountTypes.Arsonist : CountTypes.Crew, + _ when SubRoles.Contains(CustomRoles.Recruit) => Jackal.SidekickCountMode.GetValue() switch + { + 0 => CountTypes.Jackal, + 1 => CountTypes.OutOfGame, + _ => role.GetCountTypes() + }, _ => role.GetCountTypes() }; diff --git a/Modules/LocateArrow.cs b/Modules/LocateArrow.cs index 5816ff2ad..b73ffaded 100644 --- a/Modules/LocateArrow.cs +++ b/Modules/LocateArrow.cs @@ -33,10 +33,10 @@ static class LocateArrow switch (reader.ReadPackedInt32()) { case 1: - Add(reader.ReadByte(), Utils.ReadVector3(reader)); + Add(reader.ReadByte(), reader.ReadVector3()); break; case 2: - Remove(reader.ReadByte(), Utils.ReadVector3(reader)); + Remove(reader.ReadByte(), reader.ReadVector3()); break; case 3: RemoveAllTarget(reader.ReadByte()); diff --git a/Modules/NameColorManager.cs b/Modules/NameColorManager.cs index 12968c748..d2406e7c4 100644 --- a/Modules/NameColorManager.cs +++ b/Modules/NameColorManager.cs @@ -112,7 +112,7 @@ public static class NameColorManager (CustomRoles.Necromancer, CustomRoles.Deathknight) => Main.RoleColors[CustomRoles.Deathknight], (CustomRoles.Deathknight, CustomRoles.Necromancer) => Main.RoleColors[CustomRoles.Necromancer], (CustomRoles.Deathknight, CustomRoles.Deathknight) => Main.RoleColors[CustomRoles.Deathknight], - _ => color, + _ => color }; // Check if the seer can see the target's role color @@ -145,7 +145,7 @@ public static class NameColorManager CustomRoles.SoulHunter when SoulHunter.IsSoulHunterTarget(target.PlayerId) => Main.RoleColors[CustomRoles.SoulHunter], CustomRoles.Kamikaze when ((Kamikaze)Main.PlayerStates[seer.PlayerId].Role).MarkedPlayers.Contains(target.PlayerId) => Main.RoleColors[CustomRoles.Electric], CustomRoles.QuizMaster when ((QuizMaster)Main.PlayerStates[seer.PlayerId].Role).Target == target.PlayerId => "000000", - _ => color, + _ => color }; // Check if the target can see the seer's role color diff --git a/Modules/OptionHolder.cs b/Modules/OptionHolder.cs index c1977c4b0..c24c3c884 100644 --- a/Modules/OptionHolder.cs +++ b/Modules/OptionHolder.cs @@ -72,14 +72,14 @@ public static class Options "Rate85", "Rate90", "Rate95", - "Rate100", + "Rate100" ]; public static readonly string[] RatesZeroOne = [ "RoleOff", /*"Rate10", "Rate20", "Rate30", "Rate40", "Rate50", "Rate60", "Rate70", "Rate80", "Rate90", */ - "RoleRate", + "RoleRate" ]; private static readonly string[] CheatResponsesName = @@ -591,21 +591,21 @@ public static class Options [ "MadmateSpawnMode.Assign", "MadmateSpawnMode.FirstKill", - "MadmateSpawnMode.SelfVote", + "MadmateSpawnMode.SelfVote" ]; public static readonly string[] MadmateCountModeStrings = [ "MadmateCountMode.None", "MadmateCountMode.Imp", - "MadmateCountMode.Crew", + "MadmateCountMode.Crew" ]; public static readonly string[] SidekickCountMode = [ "SidekickCountMode.Jackal", "SidekickCountMode.None", - "SidekickCountMode.Original", + "SidekickCountMode.Original" ]; public static OptionItem SyncButtonMode; @@ -730,14 +730,14 @@ public static class Options "RoleAssigningAlgorithm.NetRandom", "RoleAssigningAlgorithm.HashRandom", "RoleAssigningAlgorithm.Xorshift", - "RoleAssigningAlgorithm.MersenneTwister", + "RoleAssigningAlgorithm.MersenneTwister" ]; private static readonly string[] FormatNameModes = [ "FormatNameModes.None", "FormatNameModes.Color", - "FormatNameModes.Snacks", + "FormatNameModes.Snacks" ]; public static bool IsLoaded; diff --git a/Modules/OptionItem/OptionItem.cs b/Modules/OptionItem/OptionItem.cs index 2580c63a8..b3eb83b69 100644 --- a/Modules/OptionItem/OptionItem.cs +++ b/Modules/OptionItem/OptionItem.cs @@ -310,5 +310,5 @@ public enum OptionFormat Votes, Pieces, Health, - Level, + Level } \ No newline at end of file diff --git a/Modules/OptionSaver.cs b/Modules/OptionSaver.cs index 741afa43a..1a9f4ceaf 100644 --- a/Modules/OptionSaver.cs +++ b/Modules/OptionSaver.cs @@ -69,7 +69,7 @@ public static class OptionSaver { Version = Version, SingleOptions = singleOptions, - PresetOptions = presetOptions, + PresetOptions = presetOptions }; } @@ -105,7 +105,7 @@ public static class OptionSaver { if (AmongUsClient.Instance != null && !AmongUsClient.Instance.AmHost) return; - var jsonString = JsonSerializer.Serialize(GenerateOptionsData(), new JsonSerializerOptions { WriteIndented = true, }); + var jsonString = JsonSerializer.Serialize(GenerateOptionsData(), new JsonSerializerOptions { WriteIndented = true }); File.WriteAllText(OptionSaverFileInfo.FullName, jsonString); File.WriteAllText(DefaultPresetFileInfo.FullName, DefaultPresetNumber.ToString()); } diff --git a/Modules/TemplateManager.cs b/Modules/TemplateManager.cs index 47c3d36bd..bb117b3a2 100644 --- a/Modules/TemplateManager.cs +++ b/Modules/TemplateManager.cs @@ -38,7 +38,7 @@ public static class TemplateManager ["NumLongTasks"] = () => Main.NormalOptions.NumLongTasks.ToString(), ["NumShortTasks"] = () => Main.NormalOptions.NumShortTasks.ToString(), ["Date"] = () => DateTime.Now.ToShortDateString(), - ["Time"] = () => DateTime.Now.ToShortTimeString(), + ["Time"] = () => DateTime.Now.ToShortTimeString() }; public static void Init() diff --git a/Modules/Utils.cs b/Modules/Utils.cs index 9afabc81f..4677b0b5a 100644 --- a/Modules/Utils.cs +++ b/Modules/Utils.cs @@ -523,12 +523,10 @@ public static class Utils w.Write(l.ToString()); break; case Vector2 v: - NetHelpers.WriteVector2(v, w); + w.Write(v); break; case Vector3 v: - w.Write(v.x); - w.Write(v.y); - w.Write(v.z); + w.Write(v); break; default: try @@ -548,14 +546,6 @@ public static class Utils EndRPC(w); } - public static Vector3 ReadVector3(MessageReader reader) - { - float x = reader.ReadSingle(); - float y = reader.ReadSingle(); - float z = reader.ReadSingle(); - return new(x, y, z); - } - public static void IncreaseAbilityUseLimitOnKill(PlayerControl killer) { if (Main.PlayerStates[killer.PlayerId].Role is Mafioso { IsEnable: true } mo) mo.OnMurder(killer, null); @@ -1929,21 +1919,22 @@ public static class Utils { try { - if (seer == null || seer.Data.Disconnected || seer.IsModClient()) continue; + if (seer is null || !seer || seer.Data.Disconnected || seer.IsModClient()) continue; // During intro scene, set team name for non-modded clients and skip the rest. string SelfName; Team seerTeam = seer.GetTeam(); - if (SetUpRoleTextPatch.IsInIntro) + if (SetUpRoleTextPatch.IsInIntro && seer.GetCustomRole().IsDesyncRole() || seer.Is(CustomRoles.Bloodlust)) { - const string iconText = "|"; + const string iconTextLeft = "\u21e8"; + const string iconTextRight = "\u21e6"; const string roleNameUp = "\n \n"; - string selfTeamName = $"{iconText} {ColorString(seerTeam.GetTeamColor(), $"{seerTeam}")} {iconText}\n \n"; + string selfTeamName = $"{iconTextLeft} {ColorString(seerTeam.GetTeamColor(), $"{seerTeam}")} {iconTextRight}\n \n"; SelfName = $"{ColorString(seer.GetRoleColor(), seer.GetRealName())}"; SelfName = $"{selfTeamName}\r\n{seer.GetDisplayRoleName()}\r\n{SelfName}{roleNameUp}"; - // Privately sent name. + // Privately set name seer.RpcSetNamePrivate(SelfName, true, seer); continue; } @@ -2722,7 +2713,7 @@ public static class Utils 253 => "Skip", 254 => "None", 255 => "Dead", - _ => "invalid", + _ => "invalid" }; } diff --git a/Patches/ChatCommandPatch.cs b/Patches/ChatCommandPatch.cs index dc6a2b0b6..154861c02 100644 --- a/Patches/ChatCommandPatch.cs +++ b/Patches/ChatCommandPatch.cs @@ -890,7 +890,7 @@ internal class ChatCommands "持槍" or "持械" or "手长" => GetString("Reach"), "monarch" => GetString("Monarch"), "sch" => GetString("SchrodingersCat"), - _ => text, + _ => text }; } diff --git a/Patches/DeconSystemPatch.cs b/Patches/DeconSystemPatch.cs index 60c9416d0..e4497f293 100644 --- a/Patches/DeconSystemPatch.cs +++ b/Patches/DeconSystemPatch.cs @@ -15,7 +15,7 @@ public static class DeconSystemUpdateSystemPatch { MapNames.Mira => Options.DecontaminationTimeOnMiraHQ.GetFloat(), MapNames.Polus => Options.DecontaminationTimeOnPolus.GetFloat(), - _ => 3f, + _ => 3f }; __instance.DoorOpenTime = deconTime; @@ -27,4 +27,4 @@ public static class DeconSystemUpdateSystemPatch __instance.DeconTime = 3f; } } -} +} \ No newline at end of file diff --git a/Patches/ExilePatch.cs b/Patches/ExilePatch.cs index 0412e1c57..d7676075a 100644 --- a/Patches/ExilePatch.cs +++ b/Patches/ExilePatch.cs @@ -128,7 +128,7 @@ class ExileControllerWrapUpPatch 2 => new RandomSpawn.PolusSpawnMap(), 3 => new RandomSpawn.DleksSpawnMap(), 5 => new RandomSpawn.FungleSpawnMap(), - _ => null, + _ => null }; if (map != null) Main.AllAlivePlayerControls.Do(map.RandomTeleport); } diff --git a/Patches/GameOptionsMenuPatch.cs b/Patches/GameOptionsMenuPatch.cs index 7291ee57f..bd5458086 100644 --- a/Patches/GameOptionsMenuPatch.cs +++ b/Patches/GameOptionsMenuPatch.cs @@ -218,7 +218,7 @@ public class GameOptionsMenuUpdatePatch TabGroup.NeutralRoles => "#ffab1b", TabGroup.Addons => "#ff9ace", TabGroup.OtherRoles => "#76b8e0", - _ => "#ffffff", + _ => "#ffffff" }; if (__instance.transform.parent.parent.name != tab + "Tab") continue; __instance.transform.FindChild("../../GameGroup/Text").GetComponent().SetText($"" + GetString("TabGroup." + tab) + ""); diff --git a/Patches/HudPatch.cs b/Patches/HudPatch.cs index 3fdab64ee..f79e86415 100644 --- a/Patches/HudPatch.cs +++ b/Patches/HudPatch.cs @@ -222,7 +222,7 @@ class HudManagerPatch { } s when s.Contains(CustomRoles.Asthmatic) => Asthmatic.GetSuffixText(player.PlayerId), _ => string.Empty }, - _ => string.Empty, + _ => string.Empty }; string CD_HUDText = !Options.UsePets.GetBool() || !Main.AbilityCD.TryGetValue(player.PlayerId, out var CD) diff --git a/Patches/IntroPatch.cs b/Patches/IntroPatch.cs index ffc62742f..b5a67a182 100644 --- a/Patches/IntroPatch.cs +++ b/Patches/IntroPatch.cs @@ -417,7 +417,7 @@ class BeginCrewmatePatch CustomRoleTypes.Impostor => GetIntroSound(RoleTypes.Impostor), CustomRoleTypes.Crewmate => GetIntroSound(RoleTypes.Crewmate), CustomRoleTypes.Neutral => GetIntroSound(RoleTypes.Shapeshifter), - _ => GetIntroSound(RoleTypes.Crewmate), + _ => GetIntroSound(RoleTypes.Crewmate) } }; } @@ -428,7 +428,7 @@ class BeginCrewmatePatch CustomRoleTypes.Impostor => GetIntroSound(RoleTypes.Impostor), CustomRoleTypes.Crewmate => GetIntroSound(RoleTypes.Crewmate), CustomRoleTypes.Neutral => GetIntroSound(RoleTypes.Shapeshifter), - _ => GetIntroSound(RoleTypes.Crewmate), + _ => GetIntroSound(RoleTypes.Crewmate) }; Logger.Warn($"Could not set intro sound\n{ex}", "IntroSound"); } @@ -725,7 +725,7 @@ class IntroCutsceneDestroyPatch 2 => new RandomSpawn.PolusSpawnMap(), 3 => new RandomSpawn.DleksSpawnMap(), 5 => new RandomSpawn.FungleSpawnMap(), - _ => null, + _ => null }; if (map != null) Main.AllAlivePlayerControls.Do(map.RandomTeleport); } diff --git a/Patches/MeetingHudPatch.cs b/Patches/MeetingHudPatch.cs index 4d5a765f3..513aee406 100644 --- a/Patches/MeetingHudPatch.cs +++ b/Patches/MeetingHudPatch.cs @@ -460,7 +460,7 @@ class CheckForEndVotingPatch 1 => $"1 {GetString("RemainingText.ImpSingle")} & ", 2 => $"2 {GetString("RemainingText.ImpPlural")} & ", 3 => $"3 {GetString("RemainingText.ImpPlural")} & ", - _ => string.Empty, + _ => string.Empty }; if (neutralnum == 1) name += $"1 {GetString("RemainingText.NKSingle")} {GetString("RemainingText.EjectionSuffix.NKSingle")}"; else name += $"{neutralnum} {GetString("RemainingText.NKPlural")} {GetString("RemainingText.EjectionSuffix.NKPlural")}"; @@ -471,7 +471,7 @@ class CheckForEndVotingPatch 1 => GetString("OneImpRemain"), 2 => GetString("TwoImpRemain"), 3 => GetString("ThreeImpRemain"), - _ => string.Empty, + _ => string.Empty }; break; case (0, > 0): // Only neutrals remain diff --git a/Patches/OnGameStartedPatch.cs b/Patches/OnGameStartedPatch.cs index 4f3fd17bc..812fa2b4e 100644 --- a/Patches/OnGameStartedPatch.cs +++ b/Patches/OnGameStartedPatch.cs @@ -449,7 +449,7 @@ internal class SelectRolesPatch RoleTypes.Engineer => CustomRoles.Engineer, RoleTypes.GuardianAngel => CustomRoles.GuardianAngel, RoleTypes.Shapeshifter => CustomRoles.Shapeshifter, - _ => CustomRoles.NotAssigned, + _ => CustomRoles.NotAssigned }; if (role == CustomRoles.NotAssigned) Logger.SendInGame(string.Format(GetString("Error.InvalidRoleAssignment"), pc?.Data?.PlayerName)); Main.PlayerStates[pc.PlayerId].SetMainRole(role); diff --git a/Patches/PlayerControlPatch.cs b/Patches/PlayerControlPatch.cs index a92e42286..f0e2b18f3 100644 --- a/Patches/PlayerControlPatch.cs +++ b/Patches/PlayerControlPatch.cs @@ -2001,7 +2001,7 @@ class PlayerControlLocalSetRolePatch RoleTypes.Crewmate => CustomRoles.CrewmateEHR, RoleTypes.Engineer => CustomRoles.EngineerEHR, RoleTypes.Scientist => CustomRoles.ScientistEHR, - _ => CustomRoles.NotAssigned, + _ => CustomRoles.NotAssigned }; if (moddedRole != CustomRoles.NotAssigned) { diff --git a/Patches/SabotageSystemPatch.cs b/Patches/SabotageSystemPatch.cs index 3edab9b3a..c65d89de3 100644 --- a/Patches/SabotageSystemPatch.cs +++ b/Patches/SabotageSystemPatch.cs @@ -310,7 +310,7 @@ public static class SecurityCameraPatch MapNames.Skeld or MapNames.Dleks => Options.DisableSkeldCamera.GetBool(), MapNames.Polus => Options.DisablePolusCamera.GetBool(), MapNames.Airship => Options.DisableAirshipCamera.GetBool(), - _ => false, + _ => false }); } diff --git a/Patches/ShipStatusPatch.cs b/Patches/ShipStatusPatch.cs index 632bf0bfa..5ec5c2793 100644 --- a/Patches/ShipStatusPatch.cs +++ b/Patches/ShipStatusPatch.cs @@ -136,7 +136,7 @@ class RepairSystemPatch MapNames.Skeld => Options.DisableSkeldCamera.GetBool(), MapNames.Polus => Options.DisablePolusCamera.GetBool(), MapNames.Airship => Options.DisableAirshipCamera.GetBool(), - _ => false, + _ => false }; if (camerasDisabled) { diff --git a/Roles/Crewmate/CameraMan.cs b/Roles/Crewmate/CameraMan.cs index d86ff9e09..59eee98c4 100644 --- a/Roles/Crewmate/CameraMan.cs +++ b/Roles/Crewmate/CameraMan.cs @@ -68,7 +68,7 @@ namespace EHR.Roles.Crewmate MapNames.Dleks => new(-13.5f, -5.5f), MapNames.Airship => new(5.8f, -10.8f), MapNames.Fungle => new(9.5f, 1.2f), - _ => throw new NotImplementedException(), + _ => throw new NotImplementedException() }; LateTask.New(() => { pc.TP(pos); }, UsePets.GetBool() ? 0.1f : 2f, "CameraMan Teleport"); diff --git a/Roles/Crewmate/CopyCat.cs b/Roles/Crewmate/CopyCat.cs index eea6c073d..8a7c06b1c 100644 --- a/Roles/Crewmate/CopyCat.cs +++ b/Roles/Crewmate/CopyCat.cs @@ -128,7 +128,7 @@ public class CopyCat : RoleBase CustomRoles.Vindicator or CustomRoles.Pickpocket => CustomRoles.Mayor, CustomRoles.Councillor => CustomRoles.Judge, CustomRoles.EvilGuesser or CustomRoles.Doomsayer or CustomRoles.Ritualist => CustomRoles.NiceGuesser, - _ => role, + _ => role }; } diff --git a/Roles/Crewmate/Divinator.cs b/Roles/Crewmate/Divinator.cs index 030610c96..524d08f9f 100644 --- a/Roles/Crewmate/Divinator.cs +++ b/Roles/Crewmate/Divinator.cs @@ -22,7 +22,7 @@ public class Divinator : RoleBase public static List didVote = []; - private static Dictionary AllPlayerRoleList = []; + private static Dictionary> AllPlayerRoleList = []; public override bool IsEnable => playerIdList.Count > 0; @@ -55,18 +55,14 @@ public class Divinator : RoleBase playerId.SetAbilityUseLimit(CheckLimitOpt.GetInt()); CustomRoles[][] chunked = Enum.GetValues() - .Where(x => !x.IsVanilla() && !x.IsAdditionRole() && x is not CustomRoles.Killer and not CustomRoles.Tasker and not CustomRoles.KB_Normal and not CustomRoles.Potato and not CustomRoles.Hider and not CustomRoles.Seeker and not CustomRoles.Fox and not CustomRoles.Troll and not CustomRoles.Jumper and not CustomRoles.Detector and not CustomRoles.Jet and not CustomRoles.Dasher and not CustomRoles.Locator and not CustomRoles.Venter and not CustomRoles.Agent and not CustomRoles.Taskinator and not CustomRoles.GM and not CustomRoles.Convict) + .Where(x => !x.IsVanilla() && !x.IsAdditionRole() && x is not CustomRoles.Killer and not CustomRoles.Tasker and not CustomRoles.KB_Normal and not CustomRoles.Potato and not CustomRoles.GM and not CustomRoles.Convict && !HnSManager.AllHnSRoles.Contains(x)) .Shuffle() .Chunk(RolesPerCategory) .ToArray(); - int index = 0; - foreach (var pc in Main.AllAlivePlayerControls) - { - if (index >= chunked.Length) break; - AllPlayerRoleList[pc.PlayerId] = chunked[index]; - index++; - } + AllPlayerRoleList = Main.AllAlivePlayerControls + .Select((pc, index) => (pc.PlayerId, chunked[index].Append(pc.GetCustomRole()).Shuffle())) + .ToDictionary(x => x.PlayerId, x => x.Item2); } public static bool OnVote(PlayerControl player, PlayerControl target) diff --git a/Roles/Crewmate/Enigma.cs b/Roles/Crewmate/Enigma.cs index 04c50b9ac..3bbb02151 100644 --- a/Roles/Crewmate/Enigma.cs +++ b/Roles/Crewmate/Enigma.cs @@ -46,7 +46,7 @@ namespace EHR.Roles.Crewmate new EnigmaKillerLevelClue { ClueStage = 1, EnigmaClueType = EnigmaClueType.KillerLevelClue }, new EnigmaKillerLevelClue { ClueStage = 2, EnigmaClueType = EnigmaClueType.KillerLevelClue }, new EnigmaKillerLevelClue { ClueStage = 3, EnigmaClueType = EnigmaClueType.KillerLevelClue }, - new EnigmaFriendCodeClue { ClueStage = 3, EnigmaClueType = EnigmaClueType.FriendCodeClue }, + new EnigmaFriendCodeClue { ClueStage = 3, EnigmaClueType = EnigmaClueType.FriendCodeClue } ]; public override bool IsEnable => playerIdList.Count > 0; @@ -380,7 +380,7 @@ namespace EHR.Roles.Crewmate { 0 or 3 or 4 or 5 or 7 or 10 or 11 or 13 or 14 or 17 => GetString("EnigmaClueColor1"), 1 or 2 or 6 or 8 or 9 or 12 or 15 or 16 => GetString("EnigmaClueColor2"), - _ => null, + _ => null }; } } diff --git a/Roles/Crewmate/Medic.cs b/Roles/Crewmate/Medic.cs index 6340c0248..dd11641dd 100644 --- a/Roles/Crewmate/Medic.cs +++ b/Roles/Crewmate/Medic.cs @@ -31,14 +31,14 @@ public class Medic : RoleBase "SeeMedicAndTarget", "SeeMedic", "SeeTarget", - "SeeNoone", + "SeeNoone" ]; public static readonly string[] ShieldDeactivationIsVisibleOption = [ "DeactivationImmediately", "DeactivationAfterMeeting", - "DeactivationIsVisibleOFF", + "DeactivationIsVisibleOFF" ]; public override bool IsEnable => playerIdList.Count > 0; @@ -288,6 +288,6 @@ public class Medic : RoleBase { Immediately, AfterMeeting, - OFF, + OFF } } \ No newline at end of file diff --git a/Roles/Crewmate/ParityCop.cs b/Roles/Crewmate/ParityCop.cs index 0582c695a..299eb0e32 100644 --- a/Roles/Crewmate/ParityCop.cs +++ b/Roles/Crewmate/ParityCop.cs @@ -20,7 +20,7 @@ public class ParityCop : RoleBase public static readonly string[] PcEgoistCountMode = [ "EgoistCountMode.Original", - "EgoistCountMode.Neutral", + "EgoistCountMode.Neutral" ]; private static OptionItem TryHideMsg; diff --git a/Roles/Crewmate/Sheriff.cs b/Roles/Crewmate/Sheriff.cs index bb16d7e98..74232ddc7 100644 --- a/Roles/Crewmate/Sheriff.cs +++ b/Roles/Crewmate/Sheriff.cs @@ -151,7 +151,7 @@ public class Sheriff : RoleBase CustomRoles.Egoist => CanKillEgoists.GetBool(), CustomRoles.Contagious => CanKillContagious.GetBool(), CustomRoles.Rascal => true, - _ => false, + _ => false }; } @@ -163,7 +163,7 @@ public class Sheriff : RoleBase { CustomRoleTypes.Impostor => true, CustomRoleTypes.Neutral => CanKillNeutrals.GetBool() && (CanKillNeutralsMode.GetValue() == 0 || !KillTargetOptions.TryGetValue(cRole, out var option) || option.GetBool()), - _ => CanKill, + _ => CanKill } }; } diff --git a/Roles/Crewmate/Tornado.cs b/Roles/Crewmate/Tornado.cs index f6c4b724b..439503df6 100644 --- a/Roles/Crewmate/Tornado.cs +++ b/Roles/Crewmate/Tornado.cs @@ -62,7 +62,7 @@ namespace EHR.Roles.Crewmate MapNames.Dleks => new RandomSpawn.DleksSpawnMap(), MapNames.Airship => new RandomSpawn.AirshipSpawnMap(), MapNames.Fungle => new RandomSpawn.FungleSpawnMap(), - _ => throw new NotImplementedException(), + _ => throw new NotImplementedException() }; CanUseMap = true; } diff --git a/Roles/Impostor/EvilTracker.cs b/Roles/Impostor/EvilTracker.cs index 438a27ff8..3e92a74bb 100644 --- a/Roles/Impostor/EvilTracker.cs +++ b/Roles/Impostor/EvilTracker.cs @@ -31,7 +31,7 @@ public class EvilTracker : RoleBase "EvilTrackerTargetMode.Never", "EvilTrackerTargetMode.OnceInGame", "EvilTrackerTargetMode.EveryMeeting", - "EvilTrackerTargetMode.Always", + "EvilTrackerTargetMode.Always" ]; public bool CanSetTarget; diff --git a/Roles/Impostor/Witch.cs b/Roles/Impostor/Witch.cs index 2d8e0ec96..a85df2b83 100644 --- a/Roles/Impostor/Witch.cs +++ b/Roles/Impostor/Witch.cs @@ -16,7 +16,7 @@ public class Witch : RoleBase { Kill, Vent, - DoubleTrigger, + DoubleTrigger } private const int Id = 2000; diff --git a/Roles/Neutral/Amnesiac.cs b/Roles/Neutral/Amnesiac.cs index 865ec7da5..c1dc548ba 100644 --- a/Roles/Neutral/Amnesiac.cs +++ b/Roles/Neutral/Amnesiac.cs @@ -22,7 +22,7 @@ public class Amnesiac : RoleBase "Role.Amnesiac", // 0 "Role.Pursuer", // 1 "Role.Follower", // 2 - "Role.Maverick", // 3 + "Role.Maverick" // 3 ]; private static readonly string[] RememberModes = diff --git a/Roles/Neutral/Executioner.cs b/Roles/Neutral/Executioner.cs index 507409c71..83b724573 100644 --- a/Roles/Neutral/Executioner.cs +++ b/Roles/Neutral/Executioner.cs @@ -33,7 +33,7 @@ public class Executioner : RoleBase CustomRoles.CyberStar, CustomRoles.Bodyguard, CustomRoles.Dictator, - CustomRoles.Doctor, + CustomRoles.Doctor ]; public override bool IsEnable => playerIdList.Count > 0; diff --git a/Roles/Neutral/FFF.cs b/Roles/Neutral/FFF.cs index 5bf6a7c99..008c09329 100644 --- a/Roles/Neutral/FFF.cs +++ b/Roles/Neutral/FFF.cs @@ -135,7 +135,7 @@ namespace EHR.Roles.Neutral CustomRoles.Virus => true, - _ => false, + _ => false }; } diff --git a/Roles/Neutral/Jackal.cs b/Roles/Neutral/Jackal.cs index 7285dca6b..c50f88530 100644 --- a/Roles/Neutral/Jackal.cs +++ b/Roles/Neutral/Jackal.cs @@ -28,7 +28,7 @@ public class Jackal : RoleBase [ "SidekickAssignMode.SidekickAndRecruit", "SidekickAssignMode.Sidekick", - "SidekickAssignMode.Recruit", + "SidekickAssignMode.Recruit" ]; public static bool On; diff --git a/Roles/Neutral/Lawyer.cs b/Roles/Neutral/Lawyer.cs index 4a95088c0..a1ac8a37b 100644 --- a/Roles/Neutral/Lawyer.cs +++ b/Roles/Neutral/Lawyer.cs @@ -32,7 +32,7 @@ public class Lawyer : RoleBase "Role.Bodyguard", "Role.Dictator", "Role.Mayor", - "Role.Doctor", + "Role.Doctor" ]; public static readonly CustomRoles[] CRoleChangeRoles = @@ -45,7 +45,7 @@ public class Lawyer : RoleBase CustomRoles.Bodyguard, CustomRoles.Dictator, CustomRoles.Mayor, - CustomRoles.Doctor, + CustomRoles.Doctor ]; public override bool IsEnable => playerIdList.Count > 0; diff --git a/Roles/Neutral/Necromancer.cs b/Roles/Neutral/Necromancer.cs index c7d8e31aa..4a33a892e 100644 --- a/Roles/Neutral/Necromancer.cs +++ b/Roles/Neutral/Necromancer.cs @@ -19,7 +19,7 @@ namespace EHR.Roles.Neutral [ "UndeadCountMode.None", "UndeadCountMode.Necromancer", - "UndeadCountMode.Original", + "UndeadCountMode.Original" ]; public static readonly List PartiallyRecruitedIds = []; diff --git a/Roles/Neutral/Pelican.cs b/Roles/Neutral/Pelican.cs index a22a62093..293830886 100644 --- a/Roles/Neutral/Pelican.cs +++ b/Roles/Neutral/Pelican.cs @@ -121,7 +121,7 @@ public class Pelican : RoleBase 3 => new(27f, 3.3f), // dlekS ehT 4 => new(-16.8f, -6.2f), // Airship 5 => new(9.6f, 23.2f), // The Fungle - _ => throw new NotImplementedException(), + _ => throw new NotImplementedException() }; } diff --git a/Roles/Neutral/PlagueDoctor.cs b/Roles/Neutral/PlagueDoctor.cs index c7656585f..d32f32d5e 100644 --- a/Roles/Neutral/PlagueDoctor.cs +++ b/Roles/Neutral/PlagueDoctor.cs @@ -272,7 +272,7 @@ namespace EHR.Roles.Neutral < 50 => "\u2581", >= 50 and < 100 => "\u2584", >= 100 => "\u2588", - _ => string.Empty, + _ => string.Empty }; } diff --git a/Roles/Neutral/Sidekick.cs b/Roles/Neutral/Sidekick.cs index fd8333d5c..3566a7fd0 100644 --- a/Roles/Neutral/Sidekick.cs +++ b/Roles/Neutral/Sidekick.cs @@ -23,7 +23,7 @@ public class Sidekick : RoleBase Main.ResetCamPlayerList.Add(playerId); } - public override bool CanUseImpostorVentButton(PlayerControl pc) => Jackal.CanVent.GetBool(); + public override bool CanUseImpostorVentButton(PlayerControl pc) => Jackal.CanVentSK.GetBool(); public override void SetKillCooldown(byte id) => Main.AllPlayerKillCooldown[id] = Jackal.KillCooldownSK.GetFloat(); public override void ApplyGameOptions(IGameOptions opt, byte id) => opt.SetVision(Jackal.HasImpostorVision.GetBool()); public override bool CanUseSabotage(PlayerControl pc) => Jackal.CanSabotageSK.GetBool() && pc.IsAlive(); diff --git a/Roles/Neutral/Succubus.cs b/Roles/Neutral/Succubus.cs index d14b6cb6f..78679e884 100644 --- a/Roles/Neutral/Succubus.cs +++ b/Roles/Neutral/Succubus.cs @@ -24,7 +24,7 @@ public class Succubus : RoleBase [ "CharmedCountMode.None", "CharmedCountMode.Succubus", - "CharmedCountMode.Original", + "CharmedCountMode.Original" ]; public override bool IsEnable => playerIdList.Count > 0; diff --git a/Roles/Neutral/Virus.cs b/Roles/Neutral/Virus.cs index a239652e9..6bbcaef80 100644 --- a/Roles/Neutral/Virus.cs +++ b/Roles/Neutral/Virus.cs @@ -29,7 +29,7 @@ namespace EHR.Roles.Neutral [ "ContagiousCountMode.None", "ContagiousCountMode.Virus", - "ContagiousCountMode.Original", + "ContagiousCountMode.Original" ]; public override bool IsEnable => playerIdList.Count > 0; diff --git a/Roles/Neutral/WeaponMaster.cs b/Roles/Neutral/WeaponMaster.cs index 77e5fb519..4d96ed9f1 100644 --- a/Roles/Neutral/WeaponMaster.cs +++ b/Roles/Neutral/WeaponMaster.cs @@ -219,7 +219,7 @@ public class WeaponMaster : RoleBase 1 => GetString("Axe"), 2 => GetString("Lance"), 3 => GetString("Shield"), - _ => string.Empty, + _ => string.Empty }; } } \ No newline at end of file