From 1c79f497310793f6be4aba0579b7decf5a72003d Mon Sep 17 00:00:00 2001 From: Gurge44 Date: Sun, 5 May 2024 21:37:46 +0200 Subject: [PATCH] Even more fixes --- GameMode/CustomHideAndSeekManager.cs | 34 +++++++++---- Modules/CustomRoleSelector.cs | 9 ++-- Modules/EnumHelper.cs | 19 ------- Modules/GhostRolesManager.cs | 2 +- Modules/GuessManager.cs | 2 +- Modules/OptionHolder.cs | 6 ++- Modules/Translator.cs | 6 +-- Modules/Utils.cs | 35 +++++++------ Patches/ChatCommandPatch.cs | 4 +- Patches/CheckGameEndPatch.cs | 3 +- Patches/MeetingHudPatch.cs | 2 +- Patches/OutroPatch.cs | 6 ++- Resources/Lang/en_US.json | 1 + Roles/AddOns/Common/Antidote.cs | 13 ++--- Roles/AddOns/Common/Diseased.cs | 13 ++--- Roles/AddOns/Common/Dynamo.cs | 6 +++ Roles/Crewmate/Adventurer.cs | 9 ++-- Roles/Crewmate/Bloodhound.cs | 76 +++++++++++++++------------- Roles/Crewmate/Divinator.cs | 3 +- Roles/Crewmate/Farseer.cs | 18 +++---- Roles/Crewmate/NiceSwapper.cs | 53 +++---------------- Roles/Crewmate/Randomizer.cs | 4 +- Roles/Impostor/Changeling.cs | 2 +- Roles/Impostor/Generator.cs | 20 ++++---- Roles/Impostor/Godfather.cs | 4 +- Roles/Neutral/Bargainer.cs | 8 +-- Roles/Neutral/Chemist.cs | 8 +-- Roles/Neutral/Doppelganger.cs | 2 +- Roles/Neutral/Eclipse.cs | 2 +- Roles/Neutral/Predator.cs | 5 +- Roles/Neutral/Pyromaniac.cs | 2 +- Roles/Neutral/QuizMaster.cs | 12 ++--- 32 files changed, 185 insertions(+), 204 deletions(-) delete mode 100644 Modules/EnumHelper.cs diff --git a/GameMode/CustomHideAndSeekManager.cs b/GameMode/CustomHideAndSeekManager.cs index fe84cc9e2..458b4aacc 100644 --- a/GameMode/CustomHideAndSeekManager.cs +++ b/GameMode/CustomHideAndSeekManager.cs @@ -26,6 +26,8 @@ namespace EHR public static Dictionary ClosestImpostor = []; public static Dictionary Danger = []; + public static List AllHnSRoles = []; + public static void SetupCustomOption() { const int id = 69_211_001; @@ -53,21 +55,14 @@ namespace EHR TimeLeft = MaxGameLength.GetInt() + 8; LastUpdate = Utils.TimeStamp; - Type[] types = Assembly - .GetExecutingAssembly() - .GetTypes() - .Where(t => (typeof(IHideAndSeekRole)).IsAssignableFrom(t) && !t.IsInterface) - .ToArray(); + Type[] types = GetAllHnsRoleTypes(); - CustomRoles[] roleEnums = types - .Select(x => ((CustomRoles)Enum.Parse(typeof(CustomRoles), ignoreCase: true, value: x.Name))) - .Where(role => role is CustomRoles.Seeker or CustomRoles.Hider || role.GetMode() != 0) - .ToArray(); + AllHnSRoles = GetAllHnsRoles(types); HideAndSeekRoles = types .Select(x => (IHideAndSeekRole)Activator.CreateInstance(x)) .Where(x => x != null) - .Join(roleEnums, x => x.GetType().Name.ToLower(), x => x.ToString().ToLower(), (Interface, Enum) => (Enum, Interface)) + .Join(AllHnSRoles, x => x.GetType().Name.ToLower(), x => x.ToString().ToLower(), (Interface, Enum) => (Enum, Interface)) .Where(x => (!x.Enum.OnlySpawnsWithPets() || Options.UsePets.GetBool()) && (x.Enum != CustomRoles.Agent || Main.RealOptionsData.GetInt(Int32OptionNames.NumImpostors) >= 2) && x.Interface.Count > 0 && x.Interface.Chance > IRandom.Instance.Next(100)) .OrderBy(x => x.Enum is CustomRoles.Seeker or CustomRoles.Hider ? 100 : IRandom.Instance.Next(100)) .GroupBy(x => x.Interface.Team) @@ -92,6 +87,23 @@ namespace EHR AssignRoles(); } + public static List GetAllHnsRoles(IEnumerable types) + { + return types + .Select(x => ((CustomRoles)Enum.Parse(typeof(CustomRoles), ignoreCase: true, value: x.Name))) + .Where(role => role is CustomRoles.Seeker or CustomRoles.Hider || role.GetMode() != 0) + .ToList(); + } + + public static Type[] GetAllHnsRoleTypes() + { + return Assembly + .GetExecutingAssembly() + .GetTypes() + .Where(t => (typeof(IHideAndSeekRole)).IsAssignableFrom(t) && !t.IsInterface) + .ToArray(); + } + private static void AssignRoles() { Dictionary result = []; @@ -120,7 +132,7 @@ namespace EHR Logger.Warn($"Pre-Set Role Assigned: {pc.GetRealName()} => {item.Value}", "CustomRoleSelector"); } - var playerTeams = EnumHelper.GetAllValues()[1..] + var playerTeams = Enum.GetValues()[1..] .SelectMany(x => Enumerable.Repeat(x, memberNum[x])) .Shuffle(IRandom.Instance) .Zip(allPlayers) diff --git a/Modules/CustomRoleSelector.cs b/Modules/CustomRoleSelector.cs index e0635a334..a7a9c0830 100644 --- a/Modules/CustomRoleSelector.cs +++ b/Modules/CustomRoleSelector.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using AmongUs.GameOptions; using EHR.Roles.Impostor; @@ -105,10 +106,10 @@ internal static class CustomRoleSelector foreach (var id in Main.SetRoles.Keys.Where(id => Utils.GetPlayerById(id) == null).ToArray()) Main.SetRoles.Remove(id); - foreach (var role in EnumHelper.GetAllValues()) + foreach (var role in Enum.GetValues()) { int chance = role.GetMode(); - if (role.IsVanilla() || chance == 0 || role.IsAdditionRole() || (role.OnlySpawnsWithPets() && !Options.UsePets.GetBool()) || (role != CustomRoles.Randomizer && role.IsCrewmate() && Options.AprilFoolsMode.GetBool()) || CustomHideAndSeekManager.HideAndSeekRoles.Any(x => x.Value.ContainsKey(role))) continue; + if (role.IsVanilla() || chance == 0 || role.IsAdditionRole() || (role.OnlySpawnsWithPets() && !Options.UsePets.GetBool()) || (role != CustomRoles.Randomizer && role.IsCrewmate() && Options.AprilFoolsMode.GetBool()) || CustomHideAndSeekManager.AllHnSRoles.Contains(role)) continue; switch (role) { case CustomRoles.Commander when optImpNum <= 1 && Commander.CannotSpawnAsSoloImp.GetBool(): @@ -615,7 +616,7 @@ internal static class CustomRoleSelector foreach (var id in Main.SetAddOns.Keys.Where(id => Utils.GetPlayerById(id) == null).ToArray()) Main.SetAddOns.Remove(id); AddonRolesList = []; - foreach (var role in EnumHelper.GetAllValues()) + foreach (var role in Enum.GetValues()) { if (!role.IsAdditionRole() || role.IsGhostRole()) continue; switch (role) diff --git a/Modules/EnumHelper.cs b/Modules/EnumHelper.cs deleted file mode 100644 index 83e53344f..000000000 --- a/Modules/EnumHelper.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; - -namespace EHR; - -public static class EnumHelper -{ - /// - /// Get all values of enum - /// - /// Type of enum to be obtained - /// All values of T - public static T[] GetAllValues() where T : Enum => Enum.GetValues(typeof(T)) as T[]; - /// - /// Get all names of enum - /// - /// Type of enum to be obtained - /// All values of T - public static string[] GetAllNames() where T : Enum => Enum.GetNames(typeof(T)); -} diff --git a/Modules/GhostRolesManager.cs b/Modules/GhostRolesManager.cs index 2e9db24fc..9ff9317ab 100644 --- a/Modules/GhostRolesManager.cs +++ b/Modules/GhostRolesManager.cs @@ -17,7 +17,7 @@ namespace EHR.Modules public static void Initialize() { AssignedGhostRoles = []; - GhostRoles = EnumHelper.GetAllValues().Where(x => x != CustomRoles.EvilSpirit && x.IsGhostRole() && x.IsEnable()).ToList(); + GhostRoles = Enum.GetValues().Where(x => x != CustomRoles.EvilSpirit && x.IsGhostRole() && x.IsEnable()).ToList(); Logger.Msg($"Ghost roles: {GhostRoles.Join()}", "GhostRoles"); Haunter.AllHauntedPlayers = []; diff --git a/Modules/GuessManager.cs b/Modules/GuessManager.cs index 79aff152c..151952e62 100644 --- a/Modules/GuessManager.cs +++ b/Modules/GuessManager.cs @@ -959,7 +959,7 @@ public static class GuessManager CreatePage(true, __instance, container); } - var sortedRoles = EnumHelper.GetAllValues().OrderBy(x => GetString($"{x}")).ToArray(); + var sortedRoles = Enum.GetValues().OrderBy(x => GetString($"{x}")).ToArray(); foreach (var role in sortedRoles) { if (role is CustomRoles.GM diff --git a/Modules/OptionHolder.cs b/Modules/OptionHolder.cs index c47df9ef8..990e47d7e 100644 --- a/Modules/OptionHolder.cs +++ b/Modules/OptionHolder.cs @@ -893,6 +893,8 @@ public static class Options .GroupBy(x => x.Tab) .OrderBy(x => (int)x.Key) .ToDictionary(x => x.Key, x => x.ToArray()); + + CustomHideAndSeekManager.AllHnSRoles = CustomHideAndSeekManager.GetAllHnsRoles(CustomHideAndSeekManager.GetAllHnsRoleTypes()); } public static VoteMode GetWhenSkipVote() => (VoteMode)WhenSkipVote.GetValue(); @@ -905,7 +907,7 @@ public static class Options roleCounts = []; roleSpawnChances = []; - foreach (var role in EnumHelper.GetAllValues()) + foreach (var role in Enum.GetValues()) { roleCounts.Add(role, 0); roleSpawnChances.Add(role, 0); @@ -1411,7 +1413,7 @@ public static class Options .SetGameMode(CustomGameMode.Standard) .SetColor(new Color32(19, 188, 233, byte.MaxValue)); // Reset Doors Mode - DoorsResetMode = StringOptionItem.Create(22122, "DoorsResetMode", EnumHelper.GetAllNames(), 2, TabGroup.GameSettings) + DoorsResetMode = StringOptionItem.Create(22122, "DoorsResetMode", Enum.GetNames(), 2, TabGroup.GameSettings) .SetColor(new Color32(19, 188, 233, byte.MaxValue)) .SetGameMode(CustomGameMode.Standard) .SetParent(ResetDoorsEveryTurns); diff --git a/Modules/Translator.cs b/Modules/Translator.cs index f590b842f..7a1e77da1 100644 --- a/Modules/Translator.cs +++ b/Modules/Translator.cs @@ -15,8 +15,8 @@ namespace EHR; public static class Translator { - public static Dictionary> translateMaps; public const string LANGUAGE_FOLDER_NAME = "Language"; + public static Dictionary> translateMaps; public static void Init() { @@ -86,7 +86,7 @@ public static class Translator // Creating a translation template CreateTemplateFile(); - foreach (var lang in EnumHelper.GetAllValues()) + foreach (var lang in Enum.GetValues()) { if (File.Exists(@$"./{LANGUAGE_FOLDER_NAME}/{lang}.dat")) { @@ -149,7 +149,7 @@ public static class Translator if (!translateMaps.ContainsKey(str)) //translateMapsにない場合、StringNamesにあれば取得する { - var stringNames = EnumHelper.GetAllValues().Where(x => x.ToString() == str).ToArray(); + var stringNames = Enum.GetValues().Where(x => x.ToString() == str).ToArray(); if (stringNames.Length > 0) res = GetString(stringNames.FirstOrDefault()); } diff --git a/Modules/Utils.cs b/Modules/Utils.cs index 17b79af2b..268e7c63e 100644 --- a/Modules/Utils.cs +++ b/Modules/Utils.cs @@ -469,16 +469,7 @@ public static class Utils w.Write(b); break; case Vector2 v: - w.Write(v.x); - w.Write(v.y); - break; - case Vector3 v2: - w.Write(v2.x); - w.Write(v2.y); - w.Write(v2.z); - break; - case byte[] b: - w.WriteBytesAndSize(b); + NetHelpers.WriteVector2(v, w); break; } } @@ -1078,7 +1069,7 @@ public static class Utils var crewsb = new StringBuilder(); var addonsb = new StringBuilder(); - foreach (var role in EnumHelper.GetAllValues()) + foreach (var role in Enum.GetValues().Except(CustomHideAndSeekManager.AllHnSRoles)) { string mode; try @@ -1123,7 +1114,6 @@ public static class Utils switch (opt.Value.Name) { - case "Maximum": case "DisableSkeldDevices" when Main.CurrentMap is not MapNames.Skeld and not MapNames.Dleks: case "DisableMiraHQDevices" when Main.CurrentMap != MapNames.Mira: case "DisablePolusDevices" when Main.CurrentMap != MapNames.Polus: @@ -1629,13 +1619,28 @@ public static class Utils if (title == "") title = "" + GetString("DefaultSystemMessageTitle") + ""; text = text.Replace("color=", string.Empty); - if (text.Length > 1200 && !sendTo.IsPlayerModClient()) + if (text.Length >= 1200) { - text.Chunk(1200).Do(x => SendMessage(new(x), sendTo, title)); + var lines = text.Split('\n'); + var shortenedText = string.Empty; + foreach (string line in lines) + { + if (shortenedText.Length + line.Length < 1200) + { + shortenedText += line + "\n"; + continue; + } + + if (shortenedText.Length >= 1200) shortenedText.Chunk(1200).Do(x => SendMessage(new(x), sendTo, title)); + else SendMessage(shortenedText, sendTo, title); + shortenedText = line + "\n"; + } + + if (shortenedText.Length > 0) SendMessage(shortenedText, sendTo, title); return; } - if (text.Length < 300) Logger.Info($" Message: {text} - To: {(sendTo == byte.MaxValue ? "Everyone" : $"{Utils.GetPlayerById(sendTo).GetRealName()}")} - Title: {title}", "SendMessage"); + if (text.RemoveHtmlTags().Length < 300) Logger.Info($" Message: {text.RemoveHtmlTags()} - To: {(sendTo == byte.MaxValue ? "Everyone" : $"{GetPlayerById(sendTo).GetRealName()}")} - Title: {title}", "SendMessage"); Main.MessagesToSend.Add((text.RemoveHtmlTagsTemplate(), sendTo, title)); } diff --git a/Patches/ChatCommandPatch.cs b/Patches/ChatCommandPatch.cs index 4c66293a4..f50df0257 100644 --- a/Patches/ChatCommandPatch.cs +++ b/Patches/ChatCommandPatch.cs @@ -902,7 +902,7 @@ internal class ChatCommands } else name = name.Trim().ToLower(); - foreach (var rl in EnumHelper.GetAllValues()) + foreach (var rl in Enum.GetValues()) { if (rl.IsVanilla()) continue; var roleName = GetString(rl.ToString()).ToLower().Trim().Replace(" ", string.Empty); @@ -939,7 +939,7 @@ internal class ChatCommands role = FixRoleNameInput(role).ToLower().Trim().Replace(" ", string.Empty); - foreach (var rl in EnumHelper.GetAllValues()) + foreach (var rl in Enum.GetValues()) { if (rl.IsVanilla()) continue; var roleName = GetString(rl.ToString()); diff --git a/Patches/CheckGameEndPatch.cs b/Patches/CheckGameEndPatch.cs index dd64d6015..c91426f04 100644 --- a/Patches/CheckGameEndPatch.cs +++ b/Patches/CheckGameEndPatch.cs @@ -1,3 +1,4 @@ +using System; using System.Collections; using System.Collections.Generic; using System.Linq; @@ -379,7 +380,7 @@ class GameEndChecker Dictionary<(CustomRoles? ROLE, CustomWinner WINNER), int> roleCounts = []; - foreach (var role in EnumHelper.GetAllValues()) + foreach (var role in Enum.GetValues()) { if ((!role.IsNK() && role != CustomRoles.Bloodlust) || role.IsMadmate() || role is CustomRoles.Sidekick) continue; diff --git a/Patches/MeetingHudPatch.cs b/Patches/MeetingHudPatch.cs index 83c6782b6..1d46cbc9d 100644 --- a/Patches/MeetingHudPatch.cs +++ b/Patches/MeetingHudPatch.cs @@ -551,7 +551,7 @@ class CheckForEndVotingPatch Logger.Info($"{player.GetNameWithRole().RemoveHtmlTags()}の道連れ先:{target.GetNameWithRole().RemoveHtmlTags()}", "RevengeOnExile"); } - private static PlayerControl PickRevengeTarget(PlayerControl exiledplayer /*, PlayerState.DeathReason deathReason*/) //道連れ先選定 + private static PlayerControl PickRevengeTarget(PlayerControl exiledplayer /*, PlayerState.DeathReason deathReason*/) { List TargetList = []; TargetList.AddRange(Main.AllAlivePlayerControls.Where(candidate => candidate != exiledplayer && !Main.AfterMeetingDeathPlayers.ContainsKey(candidate.PlayerId))); diff --git a/Patches/OutroPatch.cs b/Patches/OutroPatch.cs index 41770121d..4a6f66148 100644 --- a/Patches/OutroPatch.cs +++ b/Patches/OutroPatch.cs @@ -62,9 +62,11 @@ class EndGamePatch var date = value.RealKiller.TIMESTAMP; if (date == DateTime.MinValue) continue; var killerId = value.GetRealKiller(); - sb.Append($"\n{date:T} {Main.AllPlayerNames[key]} ({(Options.CurrentGameMode is CustomGameMode.FFA or CustomGameMode.MoveAndStop or CustomGameMode.HotPotato or CustomGameMode.HideAndSeek ? string.Empty : Utils.GetDisplayRoleName(key, true))}{(Options.CurrentGameMode is CustomGameMode.FFA or CustomGameMode.MoveAndStop ? string.Empty : Utils.GetSubRolesText(key, summary: true))}) [{Utils.GetVitalText(key)}]"); + var gmIsFM = Options.CurrentGameMode is CustomGameMode.FFA or CustomGameMode.MoveAndStop; + var gmIsFMHH = gmIsFM || Options.CurrentGameMode is CustomGameMode.HotPotato or CustomGameMode.HideAndSeek; + sb.Append($"\n{date:T} {Main.AllPlayerNames[key]} ({(gmIsFMHH ? string.Empty : Utils.GetDisplayRoleName(key, true))}{(gmIsFM ? string.Empty : Utils.GetSubRolesText(key, summary: true))}) [{Utils.GetVitalText(key)}]"); if (killerId != byte.MaxValue && killerId != key) - sb.Append($"\n\t⇐ {Main.AllPlayerNames[killerId]} ({(Options.CurrentGameMode is CustomGameMode.FFA or CustomGameMode.MoveAndStop or CustomGameMode.HotPotato or CustomGameMode.HideAndSeek ? string.Empty : Utils.GetDisplayRoleName(killerId, true))}{(Options.CurrentGameMode is CustomGameMode.FFA or CustomGameMode.MoveAndStop ? string.Empty : Utils.GetSubRolesText(killerId, summary: true))})"); + sb.Append($"\n\t⇐ {Main.AllPlayerNames[killerId]} ({(gmIsFMHH ? string.Empty : Utils.GetDisplayRoleName(killerId, true))}{(gmIsFM ? string.Empty : Utils.GetSubRolesText(killerId, summary: true))})"); } KillLog = sb.ToString(); diff --git a/Resources/Lang/en_US.json b/Resources/Lang/en_US.json index fa597eebb..fc91e7f7d 100644 --- a/Resources/Lang/en_US.json +++ b/Resources/Lang/en_US.json @@ -2653,6 +2653,7 @@ "Prefix.Dynamo": "Dynamo", "Dynamo.IncreaseSpeedBy": "Increase Speed by", "Dynamo.IncreaseSpeedFrequency": "Speed Increase Frequency", + "Dynamo.MaxSpeed": "Max Speed", "Samurai": "Samurai", "SamuraiInfo": "Kill Players in Unique Ways", "SamuraiInfoLong": "(Neutrals):\\nAs the Samurai, you can do delayed kills and normal kills. What decides? Well, if you click your kill button on someone (the kill won't occur immediately) and you stay near them for a few seconds (like an arsonist douse), you get a lower kill cooldown and the kill will be delayed. If you fail to stay near them, you do a normal kill, lunge included.", diff --git a/Roles/AddOns/Common/Antidote.cs b/Roles/AddOns/Common/Antidote.cs index 14800056e..0ac096b3c 100644 --- a/Roles/AddOns/Common/Antidote.cs +++ b/Roles/AddOns/Common/Antidote.cs @@ -8,17 +8,18 @@ namespace EHR.Roles.AddOns.Common public void SetupCustomOption() { - SetupAdtRoleOptions(222420, CustomRoles.Antidote, canSetNum: true); - ImpCanBeAntidote = BooleanOptionItem.Create(222426, "ImpCanBeAntidote", true, TabGroup.Addons) + const int id = 648500; + SetupAdtRoleOptions(id, CustomRoles.Antidote, canSetNum: true); + ImpCanBeAntidote = BooleanOptionItem.Create(id + 3, "ImpCanBeAntidote", true, TabGroup.Addons) .SetParent(CustomRoleSpawnChances[CustomRoles.Antidote]); - CrewCanBeAntidote = BooleanOptionItem.Create(222427, "CrewCanBeAntidote", true, TabGroup.Addons) + CrewCanBeAntidote = BooleanOptionItem.Create(id + 4, "CrewCanBeAntidote", true, TabGroup.Addons) .SetParent(CustomRoleSpawnChances[CustomRoles.Antidote]); - NeutralCanBeAntidote = BooleanOptionItem.Create(222423, "NeutralCanBeAntidote", true, TabGroup.Addons) + NeutralCanBeAntidote = BooleanOptionItem.Create(id + 5, "NeutralCanBeAntidote", true, TabGroup.Addons) .SetParent(CustomRoleSpawnChances[CustomRoles.Antidote]); - AntidoteCDOpt = FloatOptionItem.Create(222424, "AntidoteCDOpt", new(0f, 180f, 1f), 5f, TabGroup.Addons) + AntidoteCDOpt = FloatOptionItem.Create(id + 6, "AntidoteCDOpt", new(0f, 180f, 1f), 5f, TabGroup.Addons) .SetParent(CustomRoleSpawnChances[CustomRoles.Antidote]) .SetValueFormat(OptionFormat.Seconds); - AntidoteCDReset = BooleanOptionItem.Create(222425, "AntidoteCDReset", true, TabGroup.Addons) + AntidoteCDReset = BooleanOptionItem.Create(id + 7, "AntidoteCDReset", true, TabGroup.Addons) .SetParent(CustomRoleSpawnChances[CustomRoles.Antidote]); } } diff --git a/Roles/AddOns/Common/Diseased.cs b/Roles/AddOns/Common/Diseased.cs index 20762a69c..de2d22ca1 100644 --- a/Roles/AddOns/Common/Diseased.cs +++ b/Roles/AddOns/Common/Diseased.cs @@ -8,18 +8,19 @@ namespace EHR.Roles.AddOns.Common public void SetupCustomOption() { + const int id = 648600; SetupAdtRoleOptions(111420, CustomRoles.Diseased, canSetNum: true); - ImpCanBeDiseased = BooleanOptionItem.Create(111426, "ImpCanBeDiseased", true, TabGroup.Addons) + ImpCanBeDiseased = BooleanOptionItem.Create(id + 3, "ImpCanBeDiseased", true, TabGroup.Addons) .SetParent(CustomRoleSpawnChances[CustomRoles.Diseased]); - CrewCanBeDiseased = BooleanOptionItem.Create(111427, "CrewCanBeDiseased", true, TabGroup.Addons) + CrewCanBeDiseased = BooleanOptionItem.Create(id + 4, "CrewCanBeDiseased", true, TabGroup.Addons) .SetParent(CustomRoleSpawnChances[CustomRoles.Diseased]); - NeutralCanBeDiseased = BooleanOptionItem.Create(111423, "NeutralCanBeDiseased", true, TabGroup.Addons) + NeutralCanBeDiseased = BooleanOptionItem.Create(id + 5, "NeutralCanBeDiseased", true, TabGroup.Addons) .SetParent(CustomRoleSpawnChances[CustomRoles.Diseased]); - DiseasedCDOpt = FloatOptionItem.Create(111424, "DiseasedCDOpt", new(0f, 180f, 1f), 25f, TabGroup.Addons) + DiseasedCDOpt = FloatOptionItem.Create(id + 6, "DiseasedCDOpt", new(0f, 180f, 1f), 25f, TabGroup.Addons) .SetParent(CustomRoleSpawnChances[CustomRoles.Diseased]) .SetValueFormat(OptionFormat.Seconds); - DiseasedCDReset = BooleanOptionItem.Create(111425, "DiseasedCDReset", true, TabGroup.Addons) + DiseasedCDReset = BooleanOptionItem.Create(id + 7, "DiseasedCDReset", true, TabGroup.Addons) .SetParent(CustomRoleSpawnChances[CustomRoles.Diseased]); } } -} +} \ No newline at end of file diff --git a/Roles/AddOns/Common/Dynamo.cs b/Roles/AddOns/Common/Dynamo.cs index 272a23021..495683435 100644 --- a/Roles/AddOns/Common/Dynamo.cs +++ b/Roles/AddOns/Common/Dynamo.cs @@ -9,6 +9,7 @@ namespace EHR.Roles.AddOns.Common { private static OptionItem IncreaseSpeedBy; private static OptionItem IncreaseSpeedFrequency; + private static OptionItem MaxSpeed; private static readonly Dictionary LastPosition = []; private static readonly Dictionary StartingSpeed = []; @@ -25,6 +26,9 @@ namespace EHR.Roles.AddOns.Common IncreaseSpeedFrequency = FloatOptionItem.Create(id + 7, "Dynamo.IncreaseSpeedFrequency", new(0.5f, 30f, 0.5f), 5f, TabGroup.Addons) .SetParent(Options.CustomRoleSpawnChances[CustomRoles.Dynamo]) .SetValueFormat(OptionFormat.Seconds); + MaxSpeed = FloatOptionItem.Create(id + 8, "Dynamo.MaxSpeed", new(0.1f, 3f, 0.1f), 3f, TabGroup.Addons) + .SetParent(Options.CustomRoleSpawnChances[CustomRoles.Dynamo]) + .SetValueFormat(OptionFormat.Multiplier); } public static void Add() @@ -64,6 +68,8 @@ namespace EHR.Roles.AddOns.Common SpeedIncreaseTimer[pc.PlayerId] = 0f; Main.AllPlayerSpeed[pc.PlayerId] += IncreaseSpeedBy.GetFloat(); + float maxSpeed = MaxSpeed.GetFloat(); + if (Main.AllPlayerSpeed[pc.PlayerId] > maxSpeed) Main.AllPlayerSpeed[pc.PlayerId] = maxSpeed; pc.MarkDirtySettings(); } } diff --git a/Roles/Crewmate/Adventurer.cs b/Roles/Crewmate/Adventurer.cs index 44634ded5..a8f36b1af 100644 --- a/Roles/Crewmate/Adventurer.cs +++ b/Roles/Crewmate/Adventurer.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using EHR.Patches; using UnityEngine; @@ -74,7 +75,7 @@ namespace EHR.Roles.Crewmate .SetParent(Options.CustomRoleSpawnChances[CustomRoles.Adventurer]) .SetValueFormat(OptionFormat.Seconds); - foreach (var weapon in EnumHelper.GetAllValues()) + foreach (var weapon in Enum.GetValues()) { WeaponEnabledSettings[weapon] = CreateWeaponEnabledSetting(11333 + (int)weapon, weapon); } @@ -97,7 +98,7 @@ namespace EHR.Roles.Crewmate LastGroupingResourceTimeStamp = Utils.TimeStamp + 20; ResourceLocations = []; - foreach (var resource in EnumHelper.GetAllValues()) + foreach (var resource in Enum.GetValues()) { ResourceCounts[resource] = 0; } @@ -329,7 +330,7 @@ namespace EHR.Roles.Crewmate if (pc.PlayerId != tar.PlayerId) return string.Empty; IEnumerable resources = - from resource in EnumHelper.GetAllValues() + from resource in Enum.GetValues() let displayData = ResourceDisplayData[resource] select $"{Utils.ColorString(displayData.Color, $"{displayData.Icon}")}{av.ResourceCounts[resource]}"; diff --git a/Roles/Crewmate/Bloodhound.cs b/Roles/Crewmate/Bloodhound.cs index 46c4fad94..5584279a6 100644 --- a/Roles/Crewmate/Bloodhound.cs +++ b/Roles/Crewmate/Bloodhound.cs @@ -12,7 +12,7 @@ namespace EHR.Roles.Crewmate public class Bloodhound : RoleBase { private const int Id = 6400; - private static List playerIdList = []; + private static List PlayerIdList = []; public static List UnreportablePlayers = []; @@ -22,9 +22,10 @@ namespace EHR.Roles.Crewmate public static OptionItem NotifyKiller; public static OptionItem BloodhoundAbilityUseGainWithEachTaskCompleted; public static OptionItem AbilityChargesWhenFinishedTasks; - public List BloodhoundTargets = []; - public override bool IsEnable => playerIdList.Count > 0; + private List BloodhoundTargets = []; + + public override bool IsEnable => PlayerIdList.Count > 0; public static void SetupCustomOption() { @@ -44,50 +45,50 @@ namespace EHR.Roles.Crewmate public override void Init() { - playerIdList = []; + PlayerIdList = []; UnreportablePlayers = []; BloodhoundTargets = []; } public override void Add(byte playerId) { - playerIdList.Add(playerId); + PlayerIdList.Add(playerId); playerId.SetAbilityUseLimit(UseLimitOpt.GetInt()); BloodhoundTargets = []; } - static void SendRPC(byte playerId, bool add, Vector3 loc = new()) - { - if (!Utils.DoRPC) return; - MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.SetBloodhoundArrow, SendOption.Reliable); - writer.Write(playerId); - writer.Write(add); - if (add) - { - writer.Write(loc.x); - writer.Write(loc.y); - writer.Write(loc.z); - } - - AmongUsClient.Instance.FinishRpcImmediately(writer); - } - public static void ReceiveRPC(MessageReader reader) { byte playerId = reader.ReadByte(); - if (Main.PlayerStates[playerId].Role is not Bloodhound) return; + if (Main.PlayerStates[playerId].Role is not Bloodhound bh) return; - bool add = reader.ReadBoolean(); - if (add) LocateArrow.Add(playerId, new(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle())); - else LocateArrow.RemoveAllTarget(playerId); + switch (reader.ReadPackedInt32()) + { + case 1: + TargetArrow.RemoveAllTarget(playerId); + LocateArrow.RemoveAllTarget(playerId); + bh.BloodhoundTargets.Clear(); + break; + case 2: + LocateArrow.Add(playerId, NetHelpers.ReadVector2(reader)); + break; + case 3: + LocateArrow.Remove(playerId, NetHelpers.ReadVector2(reader)); + break; + case 4: + bh.BloodhoundTargets.Add(reader.ReadByte()); + TargetArrow.Add(playerId, bh.BloodhoundTargets.Last()); + break; + } } public override void OnReportDeadBody() { - foreach (byte apc in playerIdList) + foreach (byte id in PlayerIdList) { - LocateArrow.RemoveAllTarget(apc); - SendRPC(apc, false); + TargetArrow.RemoveAllTarget(id); + LocateArrow.RemoveAllTarget(id); + Utils.SendRPC(CustomRPC.SetBloodhoundArrow, id, 1); } BloodhoundTargets.Clear(); @@ -97,13 +98,14 @@ namespace EHR.Roles.Crewmate { if (!ArrowsPointingToDeadBody.GetBool()) return; - foreach (byte pc in playerIdList) + foreach (byte id in PlayerIdList) { - var player = Utils.GetPlayerById(pc); - if (player == null || !player.IsAlive()) - continue; - LocateArrow.Add(pc, target.transform.position); - SendRPC(pc, true, target.transform.position); + var player = Utils.GetPlayerById(id); + if (player == null || !player.IsAlive()) continue; + + var pos = target.Pos(); + LocateArrow.Add(id, pos); + Utils.SendRPC(CustomRPC.SetBloodhoundArrow, id, 2, pos); } } @@ -116,13 +118,15 @@ namespace EHR.Roles.Crewmate return false; } - LocateArrow.Remove(pc.PlayerId, target.Object.transform.position); - SendRPC(pc.PlayerId, false); + var pos = target.Object.Pos(); + LocateArrow.Remove(pc.PlayerId, pos); + Utils.SendRPC(CustomRPC.SetBloodhoundArrow, pc.PlayerId, 3, pos); if (pc.GetAbilityUseLimit() >= 1) { BloodhoundTargets.Add(killer.PlayerId); TargetArrow.Add(pc.PlayerId, killer.PlayerId); + Utils.SendRPC(CustomRPC.SetBloodhoundArrow, pc.PlayerId, 4, killer.PlayerId); pc.Notify(GetString("BloodhoundTrackRecorded")); pc.RpcRemoveAbilityUse(); diff --git a/Roles/Crewmate/Divinator.cs b/Roles/Crewmate/Divinator.cs index 0b2e2205e..11af06378 100644 --- a/Roles/Crewmate/Divinator.cs +++ b/Roles/Crewmate/Divinator.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using EHR.Modules; @@ -55,7 +56,7 @@ public class Divinator : RoleBase playerId.SetAbilityUseLimit(CheckLimitOpt.GetInt()); var r = IRandom.Instance; - CustomRoles[][] chunked = EnumHelper.GetAllValues() + 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) .Shuffle(r) .Chunk(RolesPerCategory) diff --git a/Roles/Crewmate/Farseer.cs b/Roles/Crewmate/Farseer.cs index 78d573835..2506dd1fa 100644 --- a/Roles/Crewmate/Farseer.cs +++ b/Roles/Crewmate/Farseer.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using AmongUs.GameOptions; using EHR.Modules; @@ -13,21 +14,23 @@ namespace EHR.Roles.Crewmate { public class Farseer : RoleBase { - public static Dictionary FarseerTimer = []; - public static Dictionary<(byte, byte), bool> IsRevealed = []; - private const int Id = 9700; private const string FontSize = "1.6"; + public static Dictionary FarseerTimer = []; + public static Dictionary<(byte, byte), bool> IsRevealed = []; public static OptionItem FarseerCooldown; public static OptionItem FarseerRevealTime; public static OptionItem Vision; public static OptionItem UsePet; - private static CustomRoles[] RandomRolesForTrickster => EnumHelper.GetAllValues().Where(x => x.IsCrewmate()).ToArray(); + public static readonly Dictionary RandomRole = []; - public static Dictionary RandomRole = []; + public static bool On; + + private static CustomRoles[] RandomRolesForTrickster => Enum.GetValues().Where(x => x.IsCrewmate()).ToArray(); + public override bool IsEnable => On; public static void SetupCustomOption() { @@ -65,9 +68,6 @@ namespace EHR.Roles.Crewmate Main.ResetCamPlayerList.Add(playerId); } - public static bool On; - public override bool IsEnable => On; - public override void ApplyGameOptions(IGameOptions opt, byte playerId) { opt.SetVision(false); diff --git a/Roles/Crewmate/NiceSwapper.cs b/Roles/Crewmate/NiceSwapper.cs index df5e95b72..a511b8842 100644 --- a/Roles/Crewmate/NiceSwapper.cs +++ b/Roles/Crewmate/NiceSwapper.cs @@ -1,6 +1,5 @@ using System; using System.Linq; -using System.Text.RegularExpressions; using EHR.Modules; using HarmonyLib; using Hazel; @@ -60,7 +59,7 @@ public class NiceSwapper : RoleBase if (!AmongUsClient.Instance.AmHost || !GameStates.IsInGame || pc == null || pc.GetCustomRole() != CustomRoles.NiceSwapper) return false; - Logger.Info($"{pc.GetNameWithRole()} : {msg} (UI: {isUI})", "NiceSwapper"); + Logger.Info($"{pc.GetNameWithRole()} : {msg} (UI: {isUI})", "Swapper"); int operate; msg = msg.ToLower().TrimStart().TrimEnd(); @@ -92,9 +91,9 @@ public class NiceSwapper : RoleBase if (HideMsg.GetBool() && !isUI) ChatManager.SendPreviousMessagesToAll(); else if (pc.AmOwner && !isUI) Utils.SendMessage(originMsg, 255, pc.GetRealName()); - if (!MsgToPlayerAndRole(msg, out byte targetId, out string error)) + if (!byte.TryParse(msg.Replace(" ", string.Empty), out byte targetId)) { - Utils.SendMessage(error, pc.PlayerId); + Utils.SendMessage(GetString("SwapHelp"), pc.PlayerId); return true; } @@ -105,21 +104,20 @@ public class NiceSwapper : RoleBase bool Vote1Empty = (SwapTargets.Item1 == byte.MaxValue) && targetIsntSelected; // Whether the first swapping slot is suitable to swap this target bool Vote2Available = (SwapTargets.Item1 != byte.MaxValue) && (SwapTargets.Item2 == byte.MaxValue) && targetIsntSelected; // Whether the second swapping slot is suitable to swap this target + bool selfCheck = CanSwapSelf.GetBool() || target.PlayerId != pc.PlayerId; - if (Vote1Empty && (CanSwapSelf.GetBool() || target.PlayerId != pc.PlayerId)) // Take first slot + if (Vote1Empty && selfCheck) // Take first slot { SwapTargets.Item1 = target.PlayerId; - if (HideMsg.GetBool() && !isUI) ChatManager.SendPreviousMessagesToAll(); if (!isUI) Utils.SendMessage(GetString("Swap1"), pc.PlayerId); Logger.Info($"{pc.GetNameWithRole().RemoveHtmlTags()} chose to swap {target.GetNameWithRole()} (first target)", "Swapper"); } - else if (Vote2Available && (CanSwapSelf.GetBool() || target.PlayerId != pc.PlayerId)) // Take second slot + else if (Vote2Available && selfCheck) // Take second slot { SwapTargets.Item2 = target.PlayerId; - if (HideMsg.GetBool() && !isUI) ChatManager.SendPreviousMessagesToAll(); if (!isUI) Utils.SendMessage(GetString("Swap2"), pc.PlayerId); Logger.Info($"{pc.GetNameWithRole().RemoveHtmlTags()} chose to swap {target.GetNameWithRole()} (second target)", "Swapper"); } @@ -128,7 +126,6 @@ public class NiceSwapper : RoleBase { SwapTargets.Item1 = byte.MaxValue; - if (HideMsg.GetBool() && !isUI) ChatManager.SendPreviousMessagesToAll(); if (!isUI) Utils.SendMessage(GetString("CancelSwap1"), pc.PlayerId); Logger.Info($"{pc.GetNameWithRole().RemoveHtmlTags()} canceled swapping on {target.GetNameWithRole()} (first target)", "Swapper"); } @@ -137,14 +134,12 @@ public class NiceSwapper : RoleBase { SwapTargets.Item2 = byte.MaxValue; - if (HideMsg.GetBool() && !isUI) ChatManager.SendPreviousMessagesToAll(); if (!isUI) Utils.SendMessage(GetString("CancelSwap2"), pc.PlayerId); Logger.Info($"{pc.GetNameWithRole().RemoveHtmlTags()} canceled swapping on {target.GetNameWithRole()} (second target)", "Swapper"); } - else if (pc.PlayerId == target.PlayerId && !CanSwapSelf.GetBool()) // When the Swapper tries to swap themselves, but they aren't allowed to + else if (!selfCheck) // When the Swapper tries to swap themselves, but they aren't allowed to { - if (HideMsg.GetBool() && !isUI) ChatManager.SendPreviousMessagesToAll(); if (!isUI) Utils.SendMessage(GetString("CantSwapSelf"), pc.PlayerId); else pc.ShowPopUp(GetString("CantSwapSelf")); } @@ -196,40 +191,6 @@ public class NiceSwapper : RoleBase Utils.SendMessage(string.Format(GetString("SwapVote"), Target1.GetRealName(), Target2.GetRealName()), 255, Utils.ColorString(Utils.GetRoleColor(CustomRoles.NiceSwapper), GetString("SwapTitle"))); } - private static bool MsgToPlayerAndRole(string msg, out byte id, out string error) - { - if (msg.StartsWith("/")) msg = msg.Replace("/", string.Empty); - - Regex r = new("\\d+"); - MatchCollection mc = r.Matches(msg); - string result = string.Empty; - for (int i = 0; i < mc.Count; i++) - { - result += mc[i]; - } - - if (int.TryParse(result, out int num)) - { - id = Convert.ToByte(num); - } - else - { - id = byte.MaxValue; - error = GetString("SwapHelp"); - return false; - } - - PlayerControl target = Utils.GetPlayerById(id); - if (target == null || target.Data.IsDead) - { - error = GetString("SwapNull"); - return false; - } - - error = string.Empty; - return true; - } - private static bool CheckCommand(ref string msg, string command, bool exact = true) { var comList = command.Split('|'); diff --git a/Roles/Crewmate/Randomizer.cs b/Roles/Crewmate/Randomizer.cs index 675895c73..cd8c49256 100644 --- a/Roles/Crewmate/Randomizer.cs +++ b/Roles/Crewmate/Randomizer.cs @@ -247,7 +247,7 @@ namespace EHR.Roles.Crewmate break; case Effect.AddonAssign: { - var addons = EnumHelper.GetAllValues().Where(x => x.IsAdditionRole() && x != CustomRoles.NotAssigned).ToArray(); + var addons = Enum.GetValues().Where(x => x.IsAdditionRole() && x != CustomRoles.NotAssigned).ToArray(); var pc = PickRandomPlayer(); var addon = addons[IRandom.Instance.Next(0, addons.Length)]; if (Main.PlayerStates[pc.PlayerId].SubRoles.Contains(addon)) break; @@ -539,7 +539,7 @@ namespace EHR.Roles.Crewmate LastEffectPick[id] = now; - var allEffects = EnumHelper.GetAllValues(); + var allEffects = Enum.GetValues(); var effect = allEffects[IRandom.Instance.Next(0, allEffects.Length)]; if (effect == Effect.GhostPlayer) diff --git a/Roles/Impostor/Changeling.cs b/Roles/Impostor/Changeling.cs index 2785a35f2..a861b6baa 100644 --- a/Roles/Impostor/Changeling.cs +++ b/Roles/Impostor/Changeling.cs @@ -42,7 +42,7 @@ namespace EHR.Roles.Impostor public static List GetAvailableRoles(bool check = false) { - CustomRoles[] allRoles = EnumHelper.GetAllValues(); + CustomRoles[] allRoles = Enum.GetValues(); IEnumerable result = AvailableRoles.GetValue() switch { diff --git a/Roles/Impostor/Generator.cs b/Roles/Impostor/Generator.cs index 87dab904b..666b33e25 100644 --- a/Roles/Impostor/Generator.cs +++ b/Roles/Impostor/Generator.cs @@ -7,14 +7,6 @@ namespace EHR.Roles.Impostor { internal static class GeneratorStatic { - enum Action - { - Kill, - Shapeshift, - Vent, - Sabotage - } - private static int GetDefaultCost(this Action action) => action switch { Action.Kill => 5, @@ -25,10 +17,17 @@ namespace EHR.Roles.Impostor _ => 15 }; + enum Action + { + Kill, + Shapeshift, + Vent, + Sabotage + } + internal class Generator : RoleBase { public static bool On; - public override bool IsEnable => On; private static OptionItem ChargesGainedPerSecond; private static OptionItem StartingCharges; @@ -42,6 +41,7 @@ namespace EHR.Roles.Impostor private int Charges; private long LastUpdate; + public override bool IsEnable => On; public static void SetupCustomOption() { @@ -56,7 +56,7 @@ namespace EHR.Roles.Impostor MaxChargesStored = IntegerOptionItem.Create(id + 5, "Generator.MaxChargesStored", new(0, 200, 1), 100, TabGroup.ImpostorRoles) .SetParent(Options.CustomRoleSpawnChances[CustomRoles.Generator]); - foreach (var action in EnumHelper.GetAllValues()) + foreach (var action in Enum.GetValues()) { var option = IntegerOptionItem.Create(id + 6 + (int)action, $"Generator.{action}.Cost", new(0, 100, 1), action.GetDefaultCost(), TabGroup.ImpostorRoles) .SetParent(Options.CustomRoleSpawnChances[CustomRoles.Generator]); diff --git a/Roles/Impostor/Godfather.cs b/Roles/Impostor/Godfather.cs index cb9a11312..694b0336a 100644 --- a/Roles/Impostor/Godfather.cs +++ b/Roles/Impostor/Godfather.cs @@ -8,8 +8,8 @@ public static void SetupCustomOption() { - Options.SetupRoleOptions(555420, TabGroup.ImpostorRoles, CustomRoles.Godfather); - Options.GodfatherCancelVote = Options.CreateVoteCancellingUseSetting(555422, CustomRoles.Godfather, TabGroup.ImpostorRoles); + Options.SetupRoleOptions(648400, TabGroup.ImpostorRoles, CustomRoles.Godfather); + Options.GodfatherCancelVote = Options.CreateVoteCancellingUseSetting(648402, CustomRoles.Godfather, TabGroup.ImpostorRoles); } public override void Add(byte playerId) diff --git a/Roles/Neutral/Bargainer.cs b/Roles/Neutral/Bargainer.cs index 5a97879f8..88b7fe88e 100644 --- a/Roles/Neutral/Bargainer.cs +++ b/Roles/Neutral/Bargainer.cs @@ -98,7 +98,7 @@ namespace EHR.Roles.Neutral StartingMoney = IntegerOptionItem.Create(++id, "Bargainer.StartingMoney", new(0, 100, 5), 0, tab) .SetParent(CustomRoleSpawnChances[CustomRoles.Bargainer]); - foreach (var action in EnumHelper.GetAllValues()) + foreach (var action in Enum.GetValues()) { var boolOpt = BooleanOptionItem.Create(++id, $"Bargainer.{action}.Enabled", true, tab) .SetParent(CustomRoleSpawnChances[CustomRoles.Bargainer]); @@ -118,7 +118,7 @@ namespace EHR.Roles.Neutral }; } - foreach (var item in EnumHelper.GetAllValues()) + foreach (var item in Enum.GetValues()) { if (item == Item.None) continue; @@ -145,7 +145,7 @@ namespace EHR.Roles.Neutral switch (item) { case Item.BandAid: - ShieldDuration = StringOptionItem.Create(++id, $"Bargainer.{item}.DurationSwitch", EnumHelper.GetAllNames(), 0, tab) + ShieldDuration = StringOptionItem.Create(++id, $"Bargainer.{item}.DurationSwitch", Enum.GetNames(), 0, tab) .SetParent(boolOpt); ShieldTime = IntegerOptionItem.Create(++id, $"Bargainer.{item}.Duration", new(0, 60, 1), 20, tab) .SetParent(ShieldDuration) @@ -157,7 +157,7 @@ namespace EHR.Roles.Neutral .SetValueFormat(OptionFormat.Seconds); break; case Item.LensOfTruth: - AlignmentVisible = StringOptionItem.Create(++id, $"Bargainer.{item}.DurationSwitch", EnumHelper.GetAllNames(), (int)AlignmentVisibleOptions.UntilNextReveal, tab) + AlignmentVisible = StringOptionItem.Create(++id, $"Bargainer.{item}.DurationSwitch", Enum.GetNames(), (int)AlignmentVisibleOptions.UntilNextReveal, tab) .SetParent(boolOpt); AlignmentVisibleDuration = IntegerOptionItem.Create(++id, $"Bargainer.{item}.Duration", new(1, 30, 1), 10, tab) .SetParent(AlignmentVisible) diff --git a/Roles/Neutral/Chemist.cs b/Roles/Neutral/Chemist.cs index a48f60c41..404f4d886 100644 --- a/Roles/Neutral/Chemist.cs +++ b/Roles/Neutral/Chemist.cs @@ -134,13 +134,13 @@ namespace EHR.Roles.Neutral .SetParent(CustomRoleSpawnChances[CustomRoles.Chemist]) .SetValueFormat(OptionFormat.Times); - FinalProductUsageAmounts = EnumHelper.GetAllValues() + FinalProductUsageAmounts = Enum.GetValues() .Where(x => GetItemType(x) == ItemType.FinalProduct) .ToDictionary(x => x, x => IntegerOptionItem.Create(++id, $"Chemist.Item.{x}.Usage", new(1, 100, 1), GetDefaultValue(x), tab) .SetParent(CustomRoleSpawnChances[CustomRoles.Chemist]) .SetValueFormat(OptionFormat.Times)); - AcidPlayersDie = StringOptionItem.Create(++id, "Chemist.AcidPlayersDie", EnumHelper.GetAllNames(), 0, tab) + AcidPlayersDie = StringOptionItem.Create(++id, "Chemist.AcidPlayersDie", Enum.GetNames(), 0, tab) .SetParent(CustomRoleSpawnChances[CustomRoles.Chemist]); AcidPlayersDieAfterTime = IntegerOptionItem.Create(++id, "Chemist.AcidPlayersDieAfterTime", new(1, 60, 1), 15, tab) .SetParent(AcidPlayersDie) @@ -178,7 +178,7 @@ namespace EHR.Roles.Neutral FactoryLocations = ShipStatus.Instance.AllRooms .Select(x => Translator.GetString($"{x.RoomId}")) .Distinct() - .Zip(EnumHelper.GetAllValues()[1..]) + .Zip(Enum.GetValues()[1..]) .ToDictionary(x => x.First, x => x.Second); }, 10f, log: false); } @@ -200,7 +200,7 @@ namespace EHR.Roles.Neutral BombedBodies = []; Grenades = []; - ItemCounts = EnumHelper.GetAllValues().ToDictionary(x => x, _ => 0); + ItemCounts = Enum.GetValues().ToDictionary(x => x, _ => 0); if (!AmongUsClient.Instance.AmHost) return; if (!Main.ResetCamPlayerList.Contains(playerId)) diff --git a/Roles/Neutral/Doppelganger.cs b/Roles/Neutral/Doppelganger.cs index ba065bdeb..11265729d 100644 --- a/Roles/Neutral/Doppelganger.cs +++ b/Roles/Neutral/Doppelganger.cs @@ -10,7 +10,7 @@ namespace EHR.Roles.Neutral; public class Doppelganger : RoleBase { - private const int Id = 194200; + private const int Id = 648100; public static List playerIdList = []; private static OptionItem KillCooldown; diff --git a/Roles/Neutral/Eclipse.cs b/Roles/Neutral/Eclipse.cs index 8a70d6f5f..dacb7b4a1 100644 --- a/Roles/Neutral/Eclipse.cs +++ b/Roles/Neutral/Eclipse.cs @@ -7,7 +7,7 @@ namespace EHR.Roles.Neutral; public class Eclipse : RoleBase { - private const int Id = 128000; + private const int Id = 648200; public static List playerIdList = []; private static OptionItem KillCooldown; diff --git a/Roles/Neutral/Predator.cs b/Roles/Neutral/Predator.cs index 1621bbf5d..2fdd51fa4 100644 --- a/Roles/Neutral/Predator.cs +++ b/Roles/Neutral/Predator.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using AmongUs.GameOptions; using HarmonyLib; @@ -44,7 +45,7 @@ namespace EHR.Roles.Neutral { RolesToKill = []; - var allRoles = EnumHelper.GetAllValues().ToList(); + var allRoles = Enum.GetValues().ToList(); allRoles.RemoveAll(x => x == CustomRoles.Predator || x >= CustomRoles.NotAssigned || !x.RoleExist(countDead: true)); var r = IRandom.Instance; diff --git a/Roles/Neutral/Pyromaniac.cs b/Roles/Neutral/Pyromaniac.cs index df2b663d3..0c301a33d 100644 --- a/Roles/Neutral/Pyromaniac.cs +++ b/Roles/Neutral/Pyromaniac.cs @@ -6,7 +6,7 @@ namespace EHR.Roles.Neutral; public class Pyromaniac : RoleBase { - private const int Id = 128020; + private const int Id = 648000; public static List playerIdList = []; private static OptionItem KillCooldown; diff --git a/Roles/Neutral/QuizMaster.cs b/Roles/Neutral/QuizMaster.cs index c6c873217..3996b131a 100644 --- a/Roles/Neutral/QuizMaster.cs +++ b/Roles/Neutral/QuizMaster.cs @@ -43,7 +43,7 @@ namespace EHR.Roles.Neutral ]; public static ((Color32 Color, string String, PlayerControl Player) LastReportedPlayer, string LastPlayerPressedButtonName, SystemTypes LastSabotage, string LastReporterName, int NumPlayersVotedLastMeeting, string FirstReportedBodyPlayerName, int NumEmergencyMeetings, int NumPlayersDeadThisRound, int NumPlayersDeadFirstRound, int NumSabotages, int NumMeetings) Data = ((new(), string.Empty, null), string.Empty, default, string.Empty, 0, string.Empty, 0, 0, 0, 0, 0); - + private Question CurrentQuestion; public byte QuizMasterId; public byte Target; @@ -212,7 +212,7 @@ namespace EHR.Roles.Neutral List indexes = abc ? allowedABCIndexes : allowedIndexes; int index = indexes[random.Next(indexes.Count)]; - var randomRole = EnumHelper.GetAllValues().Where(x => x.IsEnable()).Shuffle(random).First(); + var randomRole = Enum.GetValues().Where(x => x.IsEnable()).Shuffle(random).First(); string title = index switch { @@ -224,7 +224,7 @@ namespace EHR.Roles.Neutral (IEnumerable WrongAnswers, string CorrectAnswer) answers = index switch { - 1 when abc => (EnumHelper.GetAllValues().Skip(1).Where(x => x != Data.LastReportedPlayer.Player.GetTeam()).Select(x => Translator.GetString($"{x}")), Translator.GetString($"{Data.LastReportedPlayer.Player.GetTeam()}")), + 1 when abc => (Enum.GetValues().Skip(1).Where(x => x != Data.LastReportedPlayer.Player.GetTeam()).Select(x => Translator.GetString($"{x}")), Translator.GetString($"{Data.LastReportedPlayer.Player.GetTeam()}")), 1 => (AllColors.Shuffle(random).Take(2).Select(x => x.String), Data.LastReportedPlayer.String), 2 when abc => ((new[] { PlayerState.DeathReason.Suicide, PlayerState.DeathReason.Kill, PlayerState.DeathReason.etc }).Select(x => Translator.GetString($"DeathReason.{x}")), Translator.GetString($"DeathReason.{Main.PlayerStates[Data.LastReportedPlayer.Player!.PlayerId].deathReason}")), 2 => (GetTwoRandomNames(Data.LastPlayerPressedButtonName), Data.LastPlayerPressedButtonName), @@ -232,9 +232,9 @@ namespace EHR.Roles.Neutral 3 => (AllSabotages[..1].Select(x => Translator.GetString($"{x}")), Translator.GetString($"{Data.LastSabotage}")), 4 when abc => (new[] { "tukasa0001", "0xDrMoe" }, "Gurge44"), 4 => (CustomRoleSelector.RoleResult.Values.Shuffle(random).Take(2).Select(x => x.ToColoredString()), Main.LastVotedPlayerInfo!.Object.GetCustomRole().ToColoredString()), - 5 when abc => (EnumHelper.GetAllValues().Skip(1).Where(x => x != randomRole.GetTeam()).Select(x => Translator.GetString($"{x}")), Translator.GetString($"{randomRole.GetTeam()}")), + 5 when abc => (Enum.GetValues().Skip(1).Where(x => x != randomRole.GetTeam()).Select(x => Translator.GetString($"{x}")), Translator.GetString($"{randomRole.GetTeam()}")), 5 => (GetTwoRandomNames(Data.LastReporterName), Data.LastReporterName), - 6 when abc => (EnumHelper.GetAllValues().Where(x => x != randomRole.GetCustomRoleTypes()).Shuffle(random).Take(2).Select(x => Translator.GetString($"{x}")), Translator.GetString($"{randomRole.GetCustomRoleTypes()}")), + 6 when abc => (Enum.GetValues().Where(x => x != randomRole.GetCustomRoleTypes()).Shuffle(random).Take(2).Select(x => Translator.GetString($"{x}")), Translator.GetString($"{randomRole.GetCustomRoleTypes()}")), 6 => (GetTwoRandomNumbers(Data.NumPlayersVotedLastMeeting, 0, 15), Data.NumPlayersVotedLastMeeting.ToString()), 7 => (GetTwoRandomNumbers(Data.NumMeetings, Math.Max(Data.NumMeetings - 3, 0), Data.NumMeetings + 3), Data.NumMeetings.ToString()), 8 => (GetTwoRandomNames(Data.FirstReportedBodyPlayerName), Data.FirstReportedBodyPlayerName), @@ -243,7 +243,7 @@ namespace EHR.Roles.Neutral 11 => (GetTwoRandomNumbers(Data.NumPlayersDeadFirstRound, Math.Max(Data.NumPlayersDeadFirstRound - 3, 0), Data.NumPlayersDeadFirstRound + 3), Data.NumPlayersDeadFirstRound.ToString()), 12 => (GetTwoRandomNumbers(Data.NumSabotages, Math.Max(Data.NumSabotages - 3, 0), Data.NumSabotages + 3), Data.NumSabotages.ToString()), 13 => (GetTwoRandomNumbers(GameData.Instance.CompletedTasks, 0, GameData.Instance.TotalTasks), GameData.Instance.CompletedTasks.ToString()), - 14 => (EnumHelper.GetAllValues().Where(x => x != randomRole.GetRoleTypes()).Shuffle(random).Take(2).Select(x => Translator.GetString($"{x}")), Translator.GetString($"{randomRole.GetRoleTypes()}")), + 14 => (Enum.GetValues().Where(x => x != randomRole.GetRoleTypes()).Shuffle(random).Take(2).Select(x => Translator.GetString($"{x}")), Translator.GetString($"{randomRole.GetRoleTypes()}")), _ => ([], string.Empty) };