From ad644dc7b3f7c9b379e240212827bdc719808e69 Mon Sep 17 00:00:00 2001 From: Gurge44 Date: Thu, 25 Jun 2026 18:37:21 +0200 Subject: [PATCH] idek --- Gamemodes/LoopWanted.cs | 9 ++++++--- Modules/Extensions/CountdownTimer.cs | 18 ++++++------------ .../PlayerGameOptionsSender.cs | 2 ++ Modules/GuessManager.cs | 3 +-- Modules/ModUpdater.cs | 9 ++++----- Modules/OnlinePresetsManager.cs | 7 +++---- Patches/ChatCommandPatch.cs | 2 ++ Patches/GameOptionsMenuPatch.cs | 3 +-- Patches/GameStartManagerPatch.cs | 13 +------------ Patches/LobbyViewSettingsPanePatch.cs | 15 +++++++-------- Patches/MainMenuManagerPatch.cs | 5 ++--- Patches/TextBoxPatch.cs | 2 ++ Roles/Standard/Crewmate/Support/Chef.cs | 2 +- 13 files changed, 38 insertions(+), 52 deletions(-) diff --git a/Gamemodes/LoopWanted.cs b/Gamemodes/LoopWanted.cs index 9d7eb290d..0e965eda0 100644 --- a/Gamemodes/LoopWanted.cs +++ b/Gamemodes/LoopWanted.cs @@ -232,8 +232,11 @@ internal static class LoopWanted TargetMap[hunterId] = nextTarget; if (ShowTargetArrow.GetBool()) TargetArrow.Add(hunterId, nextTarget); - PlayerControl hunter = Utils.GetPlayerById(hunterId); - if (hunter) Utils.NotifyRoles(SpecifySeer: hunter, SpecifyTarget: hunter); + LateTask.New(() => + { + PlayerControl hunter = Utils.GetPlayerById(hunterId); + if (hunter) Utils.NotifyRoles(SpecifySeer: hunter, SpecifyTarget: hunter); + }, 0.2f); } else if (hunterId != byte.MaxValue) { @@ -334,7 +337,7 @@ internal static class LoopWanted if (!AmongUsClient.Instance.AmHost) return; var writer = Utils.CreateRPC(CustomRPC.LoopWantedSync); - writer.Write(2); + writer.WritePacked(2); writer.Write(TargetMap.Count); foreach (var kvp in TargetMap) { diff --git a/Modules/Extensions/CountdownTimer.cs b/Modules/Extensions/CountdownTimer.cs index c69287d5a..ab0580418 100644 --- a/Modules/Extensions/CountdownTimer.cs +++ b/Modules/Extensions/CountdownTimer.cs @@ -14,9 +14,9 @@ public sealed class CountdownTimer : IDisposable private readonly bool _cancelOnMeeting; private readonly bool _cancelOnGameEnd; - private event Action OnElapsed; - private event Action OnTick; - private event Action OnCanceled; + private Action OnElapsed; + private Action OnTick; + private Action OnCanceled; private readonly bool _hasTickEvent; @@ -31,16 +31,10 @@ public sealed class CountdownTimer : IDisposable _cancelOnMeeting = cancelOnMeeting; _cancelOnGameEnd = cancelOnGameEnd; - if (onElapsed != null) - OnElapsed += onElapsed; - _hasTickEvent = onTick != null; - - if (_hasTickEvent) - OnTick += onTick; - - if (onCanceled != null) - OnCanceled += onCanceled; + OnElapsed = onElapsed; + OnTick = onTick; + OnCanceled = onCanceled; if (autoStart) Start(); diff --git a/Modules/GameOptionsSender/PlayerGameOptionsSender.cs b/Modules/GameOptionsSender/PlayerGameOptionsSender.cs index b2f30a0ec..e1d4c374b 100644 --- a/Modules/GameOptionsSender/PlayerGameOptionsSender.cs +++ b/Modules/GameOptionsSender/PlayerGameOptionsSender.cs @@ -210,6 +210,8 @@ public sealed class PlayerGameOptionsSender(PlayerControl player) : GameOptionsS protected override IEnumerator SendOptionsArrayAsync(Il2CppStructArray optionArray, byte logicOptionsIndex) { + if (PackedWriter == null) yield break; + if (PackedWriter.Length > 1000 || PackedWriterMessages >= AmongUsClient.Instance.GetMaxMessagePackingLimit()) { PackedWriter.EndMessage(); diff --git a/Modules/GuessManager.cs b/Modules/GuessManager.cs index 20416df99..550193d5d 100644 --- a/Modules/GuessManager.cs +++ b/Modules/GuessManager.cs @@ -12,7 +12,6 @@ using HarmonyLib; using Hazel; using TMPro; using UnityEngine; -using UnityEngine.Events; using static EHR.Translator; namespace EHR; @@ -895,7 +894,7 @@ public static class GuessManager { var passiveButton = teambutton.GetComponent(); passiveButton.OnClick.RemoveAllListeners(); - passiveButton.OnClick.AddListener((UnityAction)(() => + passiveButton.OnClick.AddListener((Action)(() => { GuesserSelectRole(type); ReloadPage(); diff --git a/Modules/ModUpdater.cs b/Modules/ModUpdater.cs index 04e6946c5..24328045a 100644 --- a/Modules/ModUpdater.cs +++ b/Modules/ModUpdater.cs @@ -9,7 +9,6 @@ using Newtonsoft.Json.Linq; using TMPro; using Twitch; using UnityEngine; -using UnityEngine.Events; using static EHR.Translator; namespace EHR; @@ -352,8 +351,8 @@ public static class ModUpdater var passiveButton = firstButton.GetComponent(); passiveButton.OnClick = new(); if (onClickOnFirstButton != null) - passiveButton.OnClick.AddListener((UnityAction)(() => { onClickOnFirstButton(); InfoPopupV2.Close();})); - else passiveButton.OnClick.AddListener((UnityAction)(() => InfoPopupV2.Close())); + passiveButton.OnClick.AddListener((Action)(() => { onClickOnFirstButton(); InfoPopupV2.Close();})); + else passiveButton.OnClick.AddListener((Action)(() => InfoPopupV2.Close())); } if (secondButton) @@ -377,8 +376,8 @@ public static class ModUpdater var passiveButton = secondButton.GetComponent(); passiveButton.OnClick = new(); if (onClickOnSecondButton != null) - passiveButton.OnClick.AddListener((UnityAction)(() => { onClickOnSecondButton(); InfoPopupV2.Close(); })); - else passiveButton.OnClick.AddListener((UnityAction)(() => InfoPopupV2.Close())); + passiveButton.OnClick.AddListener((Action)(() => { onClickOnSecondButton(); InfoPopupV2.Close(); })); + else passiveButton.OnClick.AddListener((Action)(() => InfoPopupV2.Close())); } } } diff --git a/Modules/OnlinePresetsManager.cs b/Modules/OnlinePresetsManager.cs index af5bc0907..c3c7d46d5 100644 --- a/Modules/OnlinePresetsManager.cs +++ b/Modules/OnlinePresetsManager.cs @@ -7,7 +7,6 @@ using System.Text; using System.Text.Json; using TMPro; using UnityEngine; -using UnityEngine.Events; using UnityEngine.Networking; namespace EHR.Modules; @@ -54,7 +53,7 @@ public static class OnlinePresetsManager upload.OnValueChanged = new Action(menu.ValueChanged); upload.MinusBtn.OnClick = new(); - upload.MinusBtn.OnClick.AddListener((UnityAction)(() => Main.Instance.StartCoroutine(UploadCurrentPreset()))); + upload.MinusBtn.OnClick.AddListener((Action)(() => Main.Instance.StartCoroutine(UploadCurrentPreset()))); TextMeshPro text = upload.MinusBtn.GetComponentInChildren(); text.DestroyTranslator(); text.text = "↸"; @@ -105,7 +104,7 @@ public static class OnlinePresetsManager plusText.DestroyTranslator(); plusText.text = "ⓘ"; row.PlusBtn.OnClick = new(); - row.PlusBtn.OnClick.AddListener((UnityAction)(() => + row.PlusBtn.OnClick.AddListener((Action)(() => { bool b = plusText.text == "ⓘ"; GameObject.Find("PlayerOptionsMenu(Clone)").transform.FindChild("What Is This?").gameObject.SetActive(b); @@ -116,7 +115,7 @@ public static class OnlinePresetsManager row.MinusBtn.transform.localPosition += new Vector3(1.7f, 0f, 0f); row.MinusBtn.OnClick = new(); - row.MinusBtn.OnClick.AddListener((UnityAction)(() => + row.MinusBtn.OnClick.AddListener((Action)(() => { LateTask.New(() => { }, 0.01f); GameSettingMenu.Instance.Close(); diff --git a/Patches/ChatCommandPatch.cs b/Patches/ChatCommandPatch.cs index 912d9240b..d3e0efb29 100644 --- a/Patches/ChatCommandPatch.cs +++ b/Patches/ChatCommandPatch.cs @@ -2773,6 +2773,8 @@ internal static class ChatCommands if (args.Length < 2) return; string name = Regex.Replace(string.Join(' ', args[1..]), "]*>", string.Empty).Trim(); + + if (BanManager.CheckDenyNamePlayer(player, name)) return; if (name.RemoveHtmlTags().Length is > 15 or < 1) Utils.SendMessage(GetString("Message.AllowNameLength"), player.PlayerId, importance: MessageImportance.Low); diff --git a/Patches/GameOptionsMenuPatch.cs b/Patches/GameOptionsMenuPatch.cs index 8d238a5e9..9a0d6a1dd 100644 --- a/Patches/GameOptionsMenuPatch.cs +++ b/Patches/GameOptionsMenuPatch.cs @@ -10,7 +10,6 @@ using HarmonyLib; using Il2CppSystem.Collections.Generic; using TMPro; using UnityEngine; -using UnityEngine.Events; // ReSharper disable PossibleLossOfFraction @@ -169,7 +168,7 @@ public static class GameOptionsMenuPatch chmButton.ClickSound = __instance.BackButton.GetComponent().ClickSound; chmButton.OnMouseOver = new(); chmButton.OnMouseOut = new(); - chmButton.OnClick.AddListener((UnityAction)(() => + chmButton.OnClick.AddListener((Action)(() => { toi.CollapsesSection = !toi.CollapsesSection; ReCreateSettings(__instance); diff --git a/Patches/GameStartManagerPatch.cs b/Patches/GameStartManagerPatch.cs index 9672926df..b132b4a62 100644 --- a/Patches/GameStartManagerPatch.cs +++ b/Patches/GameStartManagerPatch.cs @@ -231,7 +231,6 @@ public static class GameStartManagerPatch Options.DefaultKillCooldown = Main.NormalOptions.KillCooldown; Main.LastKillCooldown.Value = Main.NormalOptions.KillCooldown; - Main.NormalOptions.KillCooldown = 0f; AURoleOptions.SetOpt(opt); Main.LastShapeshifterCooldown.Value = AURoleOptions.ShapeshifterCooldown; AURoleOptions.ShapeshifterCooldown = 0f; @@ -559,13 +558,10 @@ public static class GameStartRandomMap if (Options.OverrideSpeedForEachMap.GetBool() && Options.MapSpeeds.TryGetValue(Main.CurrentMap, out var option)) Main.NormalOptions.PlayerSpeedMod = option.GetFloat(); - if (__instance.startState == GameStartManager.StartingStates.Countdown) - Main.NormalOptions.KillCooldown = Main.LastKillCooldown.Value; - else + if (__instance.startState != GameStartManager.StartingStates.Countdown) { Options.DefaultKillCooldown = Main.NormalOptions.KillCooldown; Main.LastKillCooldown.Value = Main.NormalOptions.KillCooldown; - Main.NormalOptions.KillCooldown = 0f; } var opt = Main.NormalOptions.CastFast(); @@ -615,13 +611,6 @@ internal static class ResetStartStatePatch { SoundManager.Instance.StopSound(__instance.gameStartSound); GameStartManagerPatch.UpdateSpriteStartButton = true; - - if (__instance.startState == GameStartManager.StartingStates.Countdown) - { - Main.NormalOptions.KillCooldown = Main.LastKillCooldown.Value; - GameManager.Instance.LogicOptions.SetDirty(); - OptionItem.SyncAllOptions(); - } } } diff --git a/Patches/LobbyViewSettingsPanePatch.cs b/Patches/LobbyViewSettingsPanePatch.cs index d67087bba..ec0b08175 100644 --- a/Patches/LobbyViewSettingsPanePatch.cs +++ b/Patches/LobbyViewSettingsPanePatch.cs @@ -7,7 +7,6 @@ using EHR.Roles; using HarmonyLib; using TMPro; using UnityEngine; -using UnityEngine.Events; namespace EHR.Patches; @@ -265,7 +264,7 @@ public static class LobbyViewSettingsPanePatch ShowOnlyEnabledRolesButton.selectedSprites.GetComponent().color = Color.cyan; ShowOnlyEnabledRolesButton.OnClick = new(); - ShowOnlyEnabledRolesButton.OnClick.AddListener((UnityAction)(() => + ShowOnlyEnabledRolesButton.OnClick.AddListener((Action)(() => { OnlyEnabledRoles = !OnlyEnabledRoles; @@ -304,7 +303,7 @@ public static class LobbyViewSettingsPanePatch var rightPassiveButton = rightButton.gameObject.GetComponent(); rightPassiveButton.OnClick = new(); - rightPassiveButton.OnClick.AddListener((UnityAction)(() => + rightPassiveButton.OnClick.AddListener((Action)(() => { LastGameModeSelected++; CustomGameMode[] enumGameModes = Main.CustomGameModeValues[..^1]; @@ -324,7 +323,7 @@ public static class LobbyViewSettingsPanePatch var leftButtonPassiveButton = leftButton.gameObject.GetComponent(); leftButtonPassiveButton.OnClick = new(); - leftButtonPassiveButton.OnClick.AddListener((UnityAction)(() => + leftButtonPassiveButton.OnClick.AddListener((Action)(() => { LastGameModeSelected--; CustomGameMode[] enumGameModes = Main.CustomGameModeValues[..^1]; @@ -376,7 +375,7 @@ public static class LobbyViewSettingsPanePatch cloneSettingTabButton.selectedSprites.GetComponent().color = color; cloneSettingTabButton.OnClick = new(); - cloneSettingTabButton.OnClick.AddListener((UnityAction)(() => { __instance.ChangeTab(stringName); })); + cloneSettingTabButton.OnClick.AddListener((Action)(() => { __instance.ChangeTab(stringName); })); TabButtons[stringName] = cloneSettingTabButton; AllTabButtons[tabGroup] = cloneSettingTabButton; @@ -415,7 +414,7 @@ public static class LobbyViewSettingsPanePatch cloneRoleTabButton.selectedSprites.GetComponent().color = color; cloneRoleTabButton.OnClick = new(); - cloneRoleTabButton.OnClick.AddListener((UnityAction)(() => { __instance.ChangeTab(stringName); })); + cloneRoleTabButton.OnClick.AddListener((Action)(() => { __instance.ChangeTab(stringName); })); TabButtons[stringName] = cloneRoleTabButton; AllTabButtons[tabGroup] = cloneRoleTabButton; @@ -639,7 +638,7 @@ public static class LobbyViewSettingsPanePatch chmButton.OnMouseOver = new(); chmButton.OnMouseOut = new(); chmButton.OnClick = new(); - chmButton.OnClick.AddListener((UnityAction)(() => + chmButton.OnClick.AddListener((Action)(() => { toi.CollapsesSection = !toi.CollapsesSection; viewSettings.ReDrawTab(LastTabPressed); @@ -819,7 +818,7 @@ public static class LobbyViewSettingsPanePatch chmButton.OnMouseOver = new(); chmButton.OnMouseOut = new(); chmButton.OnClick = new(); - chmButton.OnClick.AddListener((UnityAction)(() => + chmButton.OnClick.AddListener((Action)(() => { toi.CollapsesSection = !toi.CollapsesSection; viewSettings.ReDrawTab(LastTabPressed); diff --git a/Patches/MainMenuManagerPatch.cs b/Patches/MainMenuManagerPatch.cs index a4cb0693c..2cbad3681 100644 --- a/Patches/MainMenuManagerPatch.cs +++ b/Patches/MainMenuManagerPatch.cs @@ -3,7 +3,6 @@ using BepInEx.Unity.IL2CPP; using HarmonyLib; using TMPro; using UnityEngine; -using UnityEngine.Events; namespace EHR; @@ -48,7 +47,7 @@ public static class MainMenuManagerPatch ShowingPanel = true; TitleLogoPatch.RightPanel.transform.localPosition = TitleLogoPatch.RightPanelOp; Instance.OpenGameModeMenu(); - Instance.playButton.OnClick.AddListener((UnityAction)ShowRightPanelImmediately); + Instance.playButton.OnClick.AddListener((Action)ShowRightPanelImmediately); } [HarmonyPatch(typeof(SignInStatusComponent), nameof(SignInStatusComponent.SetOnline))] @@ -183,7 +182,7 @@ public static class MainMenuManagerPatch buttonText.text = Translator.GetString($"MainMenu.{buttonName.Replace(" ", "")}"); } - __instance.PlayOnlineButton.OnClick.AddListener((UnityAction)(() => + __instance.PlayOnlineButton.OnClick.AddListener((Action)(() => { GameOptionsManager.Instance.Initialize(); diff --git a/Patches/TextBoxPatch.cs b/Patches/TextBoxPatch.cs index 871297899..d244425c2 100644 --- a/Patches/TextBoxPatch.cs +++ b/Patches/TextBoxPatch.cs @@ -21,6 +21,8 @@ public static class TextBoxPatch [HarmonyPrefix] public static bool AllowAllCharacters(TextBoxTMP __instance, [HarmonyArgument(0)] char i, ref bool __result) { + if (Translator.GetUserTrueLang() is SupportedLangs.SChinese or SupportedLangs.TChinese or SupportedLangs.Korean) return true; + if (!__instance.IpMode && i is '\'' or '"' or '’' or '`' or '-' or '–' or '—' or '‐' or '.' or ',' or ':' or ';' or '!' or '?' or '(' or ')' or '[' or ']' or '{' or '}' or '<' or '>' or '+' or '=' or '~' or '^' or '*' or '%' or '&' or '|' or '$' or '€' or '£' or '¥' or '₽' or >= '\u0100' and <= '\u024F' or >= '\u0370' and <= '\u03FF') { __result = true; diff --git a/Roles/Standard/Crewmate/Support/Chef.cs b/Roles/Standard/Crewmate/Support/Chef.cs index c4d4147b8..de4b95999 100644 --- a/Roles/Standard/Crewmate/Support/Chef.cs +++ b/Roles/Standard/Crewmate/Support/Chef.cs @@ -209,7 +209,7 @@ public class Chef : RoleBase public override void OnReportDeadBody() { ActiveEvents.Clear(); - RottenFood.Keys.Do(x => Utils.GetPlayerById(x).Suicide()); + RottenFood.Keys.ToValidPlayers().Do(x => x.Suicide()); RottenFood.Clear(); }