From 026bd1e05b954b532decaa2ffeeaf88f2ab01eba Mon Sep 17 00:00:00 2001 From: Gurge44 Date: Tue, 21 Oct 2025 11:48:28 +0200 Subject: [PATCH] Replace DestroyableSingleton with direct access --- GameMode/Mingle.cs | 20 +++++++++---- Modules/AutoHaunt.cs | 2 +- Modules/ChatBubbleShower.cs | 2 +- Modules/ExtendedPlayerControl.cs | 4 +-- Modules/Extensions/ObjectHelper.cs | 31 -------------------- Modules/FixedUpdateCaller.cs | 4 +-- Modules/GuessManager.cs | 2 +- Modules/Prompt.cs | 2 +- Modules/RPC.cs | 6 ++-- Modules/Translator.cs | 2 +- Modules/Utils.cs | 10 +++---- Modules/Zoom.cs | 4 +-- Patches/ChatCommandPatch.cs | 10 +++---- Patches/ChatControlPatch.cs | 4 +-- Patches/ControlPatch.cs | 10 +++---- Patches/CredentialsPatch.cs | 12 ++++---- Patches/Crowded.cs | 4 +-- Patches/GameOptionsMenuPatch.cs | 8 ++++-- Patches/GameStartManagerPatch.cs | 30 +++++++++---------- Patches/HudPatch.cs | 2 +- Patches/IntroPatch.cs | 18 ++++++------ Patches/NotificationPopperPatch.cs | 6 ++-- Patches/OnGameStartedPatch.cs | 46 +++++++++++++++--------------- Patches/PhantomRolePatch.cs | 6 ++-- Patches/PlayerControlPatch.cs | 2 +- Patches/PlayerJoinAndLeftPatch.cs | 4 +-- Patches/SabotageButtonPatch.cs | 2 +- Patches/ServerDropdownPatch.cs | 4 +-- Patches/TextBoxPatch.cs | 8 +++--- Roles/Impostor/Stealth.cs | 2 +- 30 files changed, 123 insertions(+), 144 deletions(-) diff --git a/GameMode/Mingle.cs b/GameMode/Mingle.cs index bc7635713..653dc6b18 100644 --- a/GameMode/Mingle.cs +++ b/GameMode/Mingle.cs @@ -316,7 +316,10 @@ public static class Mingle public static void HandleDisconnect() { - RequiredPlayerCount[AllRooms.First(x => RequiredPlayerCount.TryGetValue(x, out var required) && GetNumPlayersInRoom(x) < required)]--; + SystemTypes decreaseRoom = AllRooms.First(x => RequiredPlayerCount.TryGetValue(x, out var required) && GetNumPlayersInRoom(x) < required); + + if (RequiredPlayerCount[decreaseRoom] <= 1) RequiredPlayerCount.Remove(decreaseRoom); + else RequiredPlayerCount[decreaseRoom]--; } public static class FixedUpdatePatch @@ -339,12 +342,17 @@ public static class Mingle KillPlayers(); StartNewRound(); } - else if (RequiredPlayerCount.All(x => GetNumPlayersInRoom(x.Key) == x.Value)) + else { - Main.AllAlivePlayerControls.NotifyPlayers(Utils.ColorString(Color.green, "✓"), 3f); - Time = Math.Max(Time - TimeDecreaseOnNoDeath, MinTime); - StartNewRound(); - return; + Dictionary numPlayersInRoom = Main.AllAlivePlayerControls.Select(x => (pc: x, room: x.GetPlainShipRoom())).GroupBy(x => x.room == null ? SystemTypes.Outside : x.room.RoomId).ToDictionary(x => x.Key, x => x.Count()); + + if (RequiredPlayerCount.All(x => numPlayersInRoom.GetValueOrDefault(x.Key, 0) == x.Value)) + { + Main.AllAlivePlayerControls.NotifyPlayers(Utils.ColorString(Color.green, "✓"), 3f); + Time = Math.Max(Time - TimeDecreaseOnNoDeath, MinTime); + StartNewRound(); + return; + } } Utils.NotifyRoles(); diff --git a/Modules/AutoHaunt.cs b/Modules/AutoHaunt.cs index 14256791a..e8ad86319 100644 --- a/Modules/AutoHaunt.cs +++ b/Modules/AutoHaunt.cs @@ -50,7 +50,7 @@ public static class AutoHaunt HauntMenuMinigameSetHauntTargetPatch.Prefix(HauntMenuMinigameStartPatch.Instance, preferredTarget); } else - FastDestroyableSingleton.Instance.AbilityButton.DoClick(); + HudManager.Instance.AbilityButton.DoClick(); } yield return new WaitForSeconds(5f); diff --git a/Modules/ChatBubbleShower.cs b/Modules/ChatBubbleShower.cs index 815d576db..02962cec1 100644 --- a/Modules/ChatBubbleShower.cs +++ b/Modules/ChatBubbleShower.cs @@ -27,7 +27,7 @@ public static class ChatBubbleShower (string message, string title) = Queue.First(); Queue.Remove((message, title)); - ChatController chat = FastDestroyableSingleton.Instance.Chat; + ChatController chat = HudManager.Instance.Chat; if (GameStates.IsMeeting || chat.IsOpenOrOpening) ShowBubbleWithoutPlayer(); else if (GameStates.IsLobby) Utils.SendMessage(message, PlayerControl.LocalPlayer.PlayerId, title); diff --git a/Modules/ExtendedPlayerControl.cs b/Modules/ExtendedPlayerControl.cs index a2bb652c9..219d38ae2 100644 --- a/Modules/ExtendedPlayerControl.cs +++ b/Modules/ExtendedPlayerControl.cs @@ -2039,7 +2039,7 @@ internal static class ExtendedPlayerControl ReportDeadBodyPatch.AfterReportTasks(reporter, target); MeetingRoomManager.Instance.AssignSelf(reporter, target); - FastDestroyableSingleton.Instance.OpenMeetingRoom(reporter); + HudManager.Instance.OpenMeetingRoom(reporter); reporter.RpcStartMeeting(target); } @@ -2282,7 +2282,7 @@ internal static class ExtendedPlayerControl if (Main.UserData.TryGetValue(pc.FriendCode, out Options.UserData userData) && !string.IsNullOrWhiteSpace(userData.Tag) && userData.Tag.Length > 0) return true; ClientData client = pc.GetClient(); - return client != null && FriendsListManager.InstanceExists && FastDestroyableSingleton.Instance.IsPlayerFriend(client.ProductUserId); + return client != null && FriendsListManager.InstanceExists && FriendsListManager.Instance.IsPlayerFriend(client.ProductUserId); } public static bool IsBeginner(this PlayerControl pc) diff --git a/Modules/Extensions/ObjectHelper.cs b/Modules/Extensions/ObjectHelper.cs index f24c7249d..d643a9740 100644 --- a/Modules/Extensions/ObjectHelper.cs +++ b/Modules/Extensions/ObjectHelper.cs @@ -46,37 +46,6 @@ public static class ObjectHelper } } -// From: https://github.com/TheOtherRolesAU/TheOtherRoles/blob/a5126c5d1eae15e8a9def2dc27dc1e3f63681f2c/TheOtherRoles/Utilities/FastDestroyableSingleton.cs -public static unsafe class FastDestroyableSingleton where T : MonoBehaviour -{ - private static readonly IntPtr FieldPtr; - private static readonly Func CreateObject; - - static FastDestroyableSingleton() - { - FieldPtr = IL2CPP.GetIl2CppField(Il2CppClassPointerStore>.NativeClassPtr, nameof(DestroyableSingleton._instance)); - ConstructorInfo constructor = typeof(T).GetConstructor([typeof(IntPtr)]); - ParameterExpression ptr = Expression.Parameter(typeof(IntPtr)); - NewExpression create = Expression.New(constructor!, ptr); - Expression> lambda = Expression.Lambda>(create, ptr); - CreateObject = lambda.Compile(); - } - - public static T Instance - { - get - { -#if ANDROID - return DestroyableSingleton.Instance; -#else - IntPtr objectPointer; - IL2CPP.il2cpp_field_static_get_value(FieldPtr, &objectPointer); - return objectPointer == IntPtr.Zero ? DestroyableSingleton.Instance : CreateObject(objectPointer); -#endif - } - } -} - // The codes below I stole from TommyXL public static class Il2CppCastHelper { diff --git a/Modules/FixedUpdateCaller.cs b/Modules/FixedUpdateCaller.cs index 3d19e726d..822d2a0d9 100644 --- a/Modules/FixedUpdateCaller.cs +++ b/Modules/FixedUpdateCaller.cs @@ -63,7 +63,7 @@ public static class FixedUpdateCaller if (HudManager.InstanceExists) { - HudManager hudManager = FastDestroyableSingleton.Instance; + HudManager hudManager = HudManager.Instance; if (hudManager) { @@ -102,7 +102,7 @@ public static class FixedUpdateCaller List players = PlayerControl.LocalPlayer.GetPlayersInAbilityRangeSorted(predicate); PlayerControl closest = players.Count == 0 ? null : players[0]; - KillButton killButton = FastDestroyableSingleton.Instance.KillButton; + KillButton killButton = HudManager.Instance.KillButton; if (killButton.currentTarget && killButton.currentTarget != closest) killButton.currentTarget.ToggleHighlight(false, RoleTeamTypes.Impostor); diff --git a/Modules/GuessManager.cs b/Modules/GuessManager.cs index 93f621c46..088e9f693 100644 --- a/Modules/GuessManager.cs +++ b/Modules/GuessManager.cs @@ -612,7 +612,7 @@ public static class GuessManager private static void ProcessGuess(PlayerControl pc, MeetingHud meetingHud) { if (!HudManager.InstanceExists) return; - HudManager hudManager = FastDestroyableSingleton.Instance; + HudManager hudManager = HudManager.Instance; SoundManager.Instance.PlaySound(pc.KillSfx, false, 0.8f); if (!Options.DisableKillAnimationOnGuess.GetBool()) hudManager.KillOverlay.ShowKillAnimation(pc.Data, pc.Data); diff --git a/Modules/Prompt.cs b/Modules/Prompt.cs index cc401b5b5..25ade5835 100644 --- a/Modules/Prompt.cs +++ b/Modules/Prompt.cs @@ -18,7 +18,7 @@ public static class Prompt try { if (!HudManager.InstanceExists) return; - HudManager hud = FastDestroyableSingleton.Instance; + HudManager hud = HudManager.Instance; if (CurrentQuestion != string.Empty || !hud) { diff --git a/Modules/RPC.cs b/Modules/RPC.cs index e7f04d9e4..f619fe17c 100644 --- a/Modules/RPC.cs +++ b/Modules/RPC.cs @@ -1521,13 +1521,13 @@ internal static class RPC SoundManager.Instance.PlaySound(PlayerControl.LocalPlayer.KillSfx, false); break; case Sounds.TaskComplete when HudManager.InstanceExists: - SoundManager.Instance.PlaySound(FastDestroyableSingleton.Instance.TaskCompleteSound, false); + SoundManager.Instance.PlaySound(HudManager.Instance.TaskCompleteSound, false); break; case Sounds.TaskUpdateSound when HudManager.InstanceExists: - SoundManager.Instance.PlaySound(FastDestroyableSingleton.Instance.TaskUpdateSound, false); + SoundManager.Instance.PlaySound(HudManager.Instance.TaskUpdateSound, false); break; case Sounds.ImpTransform: - SoundManager.Instance.PlaySound(FastDestroyableSingleton.Instance.HnSOtherImpostorTransformSfx, false, 0.8f); + SoundManager.Instance.PlaySound(DestroyableSingleton.Instance.HnSOtherImpostorTransformSfx, false, 0.8f); break; } } diff --git a/Modules/Translator.cs b/Modules/Translator.cs index d58be85f2..2165d6125 100644 --- a/Modules/Translator.cs +++ b/Modules/Translator.cs @@ -180,7 +180,7 @@ public static class Translator #if ANDROID return TranslationController.Instance.GetString(stringName); #else - return FastDestroyableSingleton.Instance.GetString(stringName, new Il2CppReferenceArray(0)); + return TranslationController.Instance.GetString(stringName, new Il2CppReferenceArray(0)); #endif } diff --git a/Modules/Utils.cs b/Modules/Utils.cs index ac5f8d000..dada82a45 100644 --- a/Modules/Utils.cs +++ b/Modules/Utils.cs @@ -142,7 +142,7 @@ public static class Utils } } - try { FastDestroyableSingleton.Instance.ToggleLoadingBar(false); } + try { LoadingBarManager.Instance.ToggleLoadingBar(false); } catch (Exception e) { ThrowException(e); } } @@ -1858,7 +1858,7 @@ public static class Utils { string name = sender.Data.PlayerName; sender.SetName(title); - FastDestroyableSingleton.Instance.Chat.AddChat(sender, text); + HudManager.Instance.Chat.AddChat(sender, text); sender.SetName(name); } @@ -2068,7 +2068,7 @@ public static class Utils { string name = sender.Data.PlayerName; sender.SetName(title); - FastDestroyableSingleton.Instance.Chat.AddChat(sender, text); + HudManager.Instance.Chat.AddChat(sender, text); sender.SetName(name); } @@ -3765,7 +3765,7 @@ public static class Utils if (!open) return; if (PlayerControl.LocalPlayer != null && HudManager.InstanceExists) - FastDestroyableSingleton.Instance?.Chat?.AddChat(PlayerControl.LocalPlayer, string.Format(GetString("Message.DumpfileSaved"), "EHR" + filename.Split("EHR")[1])); + HudManager.Instance?.Chat?.AddChat(PlayerControl.LocalPlayer, string.Format(GetString("Message.DumpfileSaved"), "EHR" + filename.Split("EHR")[1])); #if !ANDROID Process.Start("explorer.exe", f.Replace("/", "\\")); @@ -4007,7 +4007,7 @@ public static class Utils public static void FlashColor(Color color, float duration = 1f) { if (!HudManager.InstanceExists) return; - HudManager hud = FastDestroyableSingleton.Instance; + HudManager hud = HudManager.Instance; if (hud.FullScreen == null) return; GameObject obj = hud.transform.FindChild("FlashColor_FullScreen")?.gameObject; diff --git a/Modules/Zoom.cs b/Modules/Zoom.cs index 29db6b89a..dac71ea48 100644 --- a/Modules/Zoom.cs +++ b/Modules/Zoom.cs @@ -70,7 +70,7 @@ public static class Zoom HudManager.Instance.UICamera.orthographicSize *= size; } - FastDestroyableSingleton.Instance?.ShadowQuad?.gameObject.SetActive((reset || Mathf.Approximately(Camera.main.orthographicSize, 3.0f)) && PlayerControl.LocalPlayer.IsAlive()); + HudManager.Instance?.ShadowQuad?.gameObject.SetActive((reset || Mathf.Approximately(Camera.main.orthographicSize, 3.0f)) && PlayerControl.LocalPlayer.IsAlive()); if (ResetButtons) { @@ -83,7 +83,7 @@ public static class Zoom { if (Camera.main == null || !HudManager.InstanceExists) return; - FastDestroyableSingleton.Instance?.ShadowQuad?.gameObject.SetActive(Mathf.Approximately(Camera.main.orthographicSize, 3.0f) && PlayerControl.LocalPlayer.IsAlive()); + HudManager.Instance?.ShadowQuad?.gameObject.SetActive(Mathf.Approximately(Camera.main.orthographicSize, 3.0f) && PlayerControl.LocalPlayer.IsAlive()); } } diff --git a/Patches/ChatCommandPatch.cs b/Patches/ChatCommandPatch.cs index 71d70969a..af539e3b7 100644 --- a/Patches/ChatCommandPatch.cs +++ b/Patches/ChatCommandPatch.cs @@ -2834,7 +2834,7 @@ internal static class ChatCommands default: if (!HudManager.InstanceExists) break; - FastDestroyableSingleton.Instance.Chat.AddChat(player, "crew | imp"); + HudManager.Instance.Chat.AddChat(player, "crew | imp"); break; } @@ -3359,7 +3359,7 @@ internal static class ChatCommands private static void VersionCommand(PlayerControl player, string text, string[] args) { string versionText = Main.PlayerVersion.OrderBy(pair => pair.Key).Aggregate(string.Empty, (current, kvp) => current + $"{kvp.Key}: ({Main.AllPlayerNames[kvp.Key]}) {kvp.Value.forkId}/{kvp.Value.version}({kvp.Value.tag})\n"); - if (versionText != string.Empty && HudManager.InstanceExists) FastDestroyableSingleton.Instance.Chat.AddChat(player, (player.FriendCode.GetDevUser().HasTag() ? "\n" : string.Empty) + versionText); + if (versionText != string.Empty && HudManager.InstanceExists) HudManager.Instance.Chat.AddChat(player, (player.FriendCode.GetDevUser().HasTag() ? "\n" : string.Empty) + versionText); } private static void LTCommand(PlayerControl player, string text, string[] args) @@ -3685,7 +3685,7 @@ internal static class ChatUpdatePatch if (clientId == -1 && HudManager.InstanceExists) { player.SetName(title); - FastDestroyableSingleton.Instance.Chat.AddChat(player, msg); + HudManager.Instance.Chat.AddChat(player, msg); player.SetName(name); } @@ -3754,9 +3754,9 @@ internal static class RpcSendChatPatch int return_count = PlayerControl.LocalPlayer.name.Count(x => x == '\n'); chatText = new StringBuilder(chatText).Insert(0, "\n", return_count).ToString(); - if (AmongUsClient.Instance.AmClient && HudManager.InstanceExists) FastDestroyableSingleton.Instance.Chat.AddChat(__instance, chatText); + if (AmongUsClient.Instance.AmClient && HudManager.InstanceExists) HudManager.Instance.Chat.AddChat(__instance, chatText); - if (chatText.Contains("who", StringComparison.OrdinalIgnoreCase)) FastDestroyableSingleton.Instance.SendWho(); + if (chatText.Contains("who", StringComparison.OrdinalIgnoreCase)) UnityTelemetry.Instance.SendWho(); MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(__instance.NetId, (byte)RpcCalls.SendChat, SendOption.Reliable); messageWriter.Write(chatText); diff --git a/Patches/ChatControlPatch.cs b/Patches/ChatControlPatch.cs index 26c6f2b75..b532f8699 100644 --- a/Patches/ChatControlPatch.cs +++ b/Patches/ChatControlPatch.cs @@ -227,7 +227,7 @@ public static class ChatManager if (aapc.Length == 0) return; string[] filtered = ChatHistory.Where(a => Utils.GetPlayerById(Convert.ToByte(a.Split(':')[0].Trim())).IsAlive()).ToArray(); - ChatController chat = FastDestroyableSingleton.Instance.Chat; + ChatController chat = HudManager.Instance.Chat; var writer = CustomRpcSender.Create("SendPreviousMessagesToAll", SendOption.Reliable); var hasValue = false; @@ -284,7 +284,7 @@ public static class ChatManager { bool toEveryone = receiver == null; bool toLocalPlayer = !toEveryone && receiver.IsLocalPlayer(); - if (HudManager.InstanceExists && (toLocalPlayer || toEveryone)) FastDestroyableSingleton.Instance.Chat.AddChat(player, "."); + if (HudManager.InstanceExists && (toLocalPlayer || toEveryone)) HudManager.Instance.Chat.AddChat(player, "."); if (toLocalPlayer) return; MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(player.NetId, (byte)RpcCalls.SendChat, SendOption.Reliable, toEveryone ? -1 : receiver.OwnerId); writer.Write("."); diff --git a/Patches/ControlPatch.cs b/Patches/ControlPatch.cs index 0f9cf19f2..fa9c3bf6d 100644 --- a/Patches/ControlPatch.cs +++ b/Patches/ControlPatch.cs @@ -149,7 +149,7 @@ internal static class ControllerManagerUpdatePatch yield return new WaitForSeconds(0.1f); string format = GetString("ResettingOptions"); - HudManager hudManager = FastDestroyableSingleton.Instance; + HudManager hudManager = HudManager.Instance; hudManager.ShowPopUp(string.Format(format, 0, OptionItem.AllOptions.Count)); hudManager.Dialogue.BackButton.gameObject.SetActive(false); @@ -205,7 +205,7 @@ internal static class ControllerManagerUpdatePatch if (KeysDown(KeyCode.Return, KeyCode.G, KeyCode.LeftShift) && GameStates.IsInGame && HudManager.InstanceExists) { HudManager.Instance.StartCoroutine(HudManager.Instance.CoFadeFullScreen(Color.clear, Color.black)); - HudManager.Instance.StartCoroutine(FastDestroyableSingleton.Instance.CoShowIntro()); + HudManager.Instance.StartCoroutine(HudManager.Instance.CoShowIntro()); } if (KeysDown(KeyCode.Return, KeyCode.V, KeyCode.LeftShift) && GameStates.IsMeeting) @@ -238,7 +238,7 @@ internal static class ControllerManagerUpdatePatch if (Input.GetKeyDown(KeyCode.Equals) && !GameStates.IsMeeting && HudManager.InstanceExists && !HudManager.Instance.Chat.IsOpenOrOpening) { Main.VisibleTasksCount = !Main.VisibleTasksCount; - FastDestroyableSingleton.Instance.Notifier.AddDisconnectMessage($"VisibleTaskCount changed to {Main.VisibleTasksCount}."); + HudManager.Instance.Notifier.AddDisconnectMessage($"VisibleTaskCount changed to {Main.VisibleTasksCount}."); } if (Input.GetKeyDown(KeyCode.I) && !GameStates.IsMeeting && !HudManager.Instance.Chat.IsOpenOrOpening) @@ -327,13 +327,13 @@ internal static class HandleHUDPatch HudManager.InstanceExists && PlayerControl.LocalPlayer.Data?.Role?.IsImpostor == false && PlayerControl.LocalPlayer.CanUseKillButton()) - FastDestroyableSingleton.Instance.KillButton.DoClick(); + HudManager.Instance.KillButton.DoClick(); if (player.GetButtonDown(50) && // 50: Impostor vent button actionId HudManager.InstanceExists && PlayerControl.LocalPlayer.Data?.Role?.IsImpostor == false && PlayerControl.LocalPlayer.CanUseImpostorVentButton()) - FastDestroyableSingleton.Instance.ImpostorVentButton.DoClick(); + HudManager.Instance.ImpostorVentButton.DoClick(); } } diff --git a/Patches/CredentialsPatch.cs b/Patches/CredentialsPatch.cs index 9bc7c2710..4dc413c0e 100644 --- a/Patches/CredentialsPatch.cs +++ b/Patches/CredentialsPatch.cs @@ -199,7 +199,7 @@ internal static class FriendsListUIOpenPatch __instance.currentSceneName = activeScene.name; __instance.UpdateFriendCodeUI(); - if ((HudManager.InstanceExists && FastDestroyableSingleton.Instance != null && FastDestroyableSingleton.Instance.Chat != null && FastDestroyableSingleton.Instance.Chat.IsOpenOrOpening) || ShipStatus.Instance != null) + if ((HudManager.InstanceExists && HudManager.Instance != null && HudManager.Instance.Chat != null && HudManager.Instance.Chat.IsOpenOrOpening) || ShipStatus.Instance != null) return false; __instance.friendBars = new(); @@ -210,13 +210,13 @@ internal static class FriendsListUIOpenPatch __instance.gameObject.SetActive(true); __instance.guestAccountWarnings.ForEach((Action)(t => t.gameObject.SetActive(false))); __instance.ViewRequestsButton.color = __instance.NoRequestsColor; - __instance.ViewRequestsText.text = FastDestroyableSingleton.Instance.GetString(StringNames.NoNewRequests); + __instance.ViewRequestsText.text = TranslationController.Instance.GetString(StringNames.NoNewRequests); - __instance.StartCoroutine(FastDestroyableSingleton.Instance.RefreshFriendsList((Action)(() => + __instance.StartCoroutine(FriendsListManager.Instance.RefreshFriendsList((Action)(() => { __instance.ClearNotifs(); - if (FastDestroyableSingleton.Instance.IsFriendsListAllowed()) + if (EOSManager.Instance.IsFriendsListAllowed()) { __instance.AddFriendObjects.SetActive(true); __instance.RefreshBlockedPlayers(); @@ -418,7 +418,7 @@ internal static class ModManagerLateUpdatePatch { __instance.localCamera = !HudManager.InstanceExists ? Camera.main - : FastDestroyableSingleton.Instance.GetComponentInChildren(); + : HudManager.Instance.GetComponentInChildren(); if (__instance.localCamera != null) { @@ -438,7 +438,7 @@ internal static class OptionsMenuBehaviourOpenPatch { try { - if (HudManager.InstanceExists && !FastDestroyableSingleton.Instance.SettingsButton.activeSelf) return false; + if (HudManager.InstanceExists && !HudManager.Instance.SettingsButton.activeSelf) return false; } catch { } diff --git a/Patches/Crowded.cs b/Patches/Crowded.cs index d8b99a502..1ea61d2f1 100644 --- a/Patches/Crowded.cs +++ b/Patches/Crowded.cs @@ -240,7 +240,7 @@ internal static class Crowded [SuppressMessage("ReSharper", "UnusedMember.Global")] public static bool Prefix(CreateOptionsPicker __instance, int maxPlayers) { - if (DestroyableSingleton.InstanceExists || __instance.mode != SettingsMode.Host) + if (FindAGameManager.InstanceExists || __instance.mode != SettingsMode.Host) return true; IGameOptions targetOptions = __instance.GetTargetOptions(); @@ -261,7 +261,7 @@ internal static class Crowded __instance.UpdateMaxPlayersButtons(targetOptions); __instance.UpdateLanguageButton((uint)targetOptions.Keywords); __instance.MapMenu.UpdateMapButtons(targetOptions.MapId); - __instance.GameModeText.text = FastDestroyableSingleton.Instance.GetString(GameModesHelpers.ModeToName[GameOptionsManager.Instance.CurrentGameOptions.GameMode]); + __instance.GameModeText.text = TranslationController.Instance.GetString(GameModesHelpers.ModeToName[GameOptionsManager.Instance.CurrentGameOptions.GameMode]); return false; } } diff --git a/Patches/GameOptionsMenuPatch.cs b/Patches/GameOptionsMenuPatch.cs index 71071a483..e60d2bdd5 100644 --- a/Patches/GameOptionsMenuPatch.cs +++ b/Patches/GameOptionsMenuPatch.cs @@ -1074,7 +1074,7 @@ public static class GameSettingMenuPatch presetTmp.DestroyTranslator(); presetTmp.text = Translator.GetString($"Preset_{OptionItem.CurrentPreset + 1}"); - bool russian = FastDestroyableSingleton.Instance.currentLanguage.languageID == SupportedLangs.Russian; + bool russian = TranslationController.Instance.currentLanguage.languageID == SupportedLangs.Russian; float size = !russian ? 2.45f : 1.45f; presetTmp.fontSizeMax = presetTmp.fontSizeMin = size; @@ -1196,7 +1196,9 @@ public static class GameSettingMenuPatch } - FreeChatInputField freeChatField = FastDestroyableSingleton.Instance.Chat.freeChatField; // FastDestroyableSingleton DOES NOT WORK HERE!!!! IF YOU USE THAT, IT BREAKS THE ENTIRE SETTINGS MENU + if (!HudManager.InstanceExists) return; + + FreeChatInputField freeChatField = HudManager.Instance.Chat.freeChatField; FreeChatInputField field = Object.Instantiate(freeChatField, parentLeftPanel.parent); field.transform.localScale = new(0.3f, 0.59f, 1); field.transform.localPosition = new(-0.7f, -2.5f, -5f); @@ -1394,7 +1396,7 @@ public static class GameSettingMenuPatch ModGameOptionsMenu.CategoryHeaderList = new(); ControllerManager.Instance.OpenOverlayMenu(__instance.name, __instance.BackButton, __instance.DefaultButtonSelected, __instance.ControllerSelectable); - if (HudManager.InstanceExists) FastDestroyableSingleton.Instance.menuNavigationPrompts.SetActive(false); + if (HudManager.InstanceExists) HudManager.Instance.menuNavigationPrompts.SetActive(false); if (Controller.currentTouchType != Controller.TouchType.Joystick) __instance.ChangeTab(1, false); __instance.StartCoroutine(__instance.CoSelectDefault()); diff --git a/Patches/GameStartManagerPatch.cs b/Patches/GameStartManagerPatch.cs index b8b63d960..b5ca8b121 100644 --- a/Patches/GameStartManagerPatch.cs +++ b/Patches/GameStartManagerPatch.cs @@ -53,7 +53,7 @@ public static class GameStartManagerPatch if (GameData.Instance && HudManager.InstanceExists && AmongUsClient.Instance.NetworkMode != NetworkModes.LocalGame && GameStates.CurrentServerType == GameStates.ServerType.Vanilla) { - HudManager hudManager = FastDestroyableSingleton.Instance; + HudManager hudManager = HudManager.Instance; hudManager.ShowLobbyTimer(597); hudManager.LobbyTimerExtensionUI.timerText.transform.parent.transform.Find("Icon").gameObject.SetActive(false); GameStartManagerUpdatePatch.Warned = false; @@ -62,7 +62,7 @@ public static class GameStartManagerPatch if (AmongUsClient.Instance.AmHost) { __instance.GameStartTextParent.GetComponent().sprite = null; - __instance.StartButton.ChangeButtonText(FastDestroyableSingleton.Instance.GetString(StringNames.StartLabel)); + __instance.StartButton.ChangeButtonText(TranslationController.Instance.GetString(StringNames.StartLabel)); __instance.GameStartText.transform.localPosition = new(__instance.GameStartText.transform.localPosition.x, 2f, __instance.GameStartText.transform.localPosition.z); __instance.StartButton.activeTextColor = __instance.StartButton.inactiveTextColor = Color.white; @@ -258,11 +258,11 @@ public static class GameStartManagerPatch instance.CheckSettingsDiffs(); instance.StartButton.gameObject.SetActive(true); - instance.RulesPresetText.text = FastDestroyableSingleton.Instance.GetString(GameOptionsManager.Instance.CurrentGameOptions.GetRulesPresetTitle()); + instance.RulesPresetText.text = TranslationController.Instance.GetString(GameOptionsManager.Instance.CurrentGameOptions.GetRulesPresetTitle()); - if (GameCode.IntToGameName(AmongUsClient.Instance.GameId) == null) instance.privatePublicPanelText.text = FastDestroyableSingleton.Instance.GetString(StringNames.LocalButton); - else if (AmongUsClient.Instance.IsGamePublic) instance.privatePublicPanelText.text = FastDestroyableSingleton.Instance.GetString(StringNames.PublicHeader); - else instance.privatePublicPanelText.text = FastDestroyableSingleton.Instance.GetString(StringNames.PrivateHeader); + if (GameCode.IntToGameName(AmongUsClient.Instance.GameId) == null) instance.privatePublicPanelText.text = TranslationController.Instance.GetString(StringNames.LocalButton); + else if (AmongUsClient.Instance.IsGamePublic) instance.privatePublicPanelText.text = TranslationController.Instance.GetString(StringNames.PublicHeader); + else instance.privatePublicPanelText.text = TranslationController.Instance.GetString(StringNames.PrivateHeader); instance.HostPrivateButton.gameObject.SetActive(!AmongUsClient.Instance.IsGamePublic); instance.HostPublicButton.gameObject.SetActive(AmongUsClient.Instance.IsGamePublic); @@ -282,12 +282,12 @@ public static class GameStartManagerPatch ActionMapGlyphDisplay startButtonGlyph = instance.StartButtonGlyph; startButtonGlyph?.SetColor(instance.LastPlayerCount >= instance.MinPlayers ? Palette.EnabledColor : Palette.DisabledClear); - if (DestroyableSingleton.InstanceExists) + if (DiscordManager.InstanceExists) { if (AmongUsClient.Instance.AmHost && AmongUsClient.Instance.NetworkMode == NetworkModes.OnlineGame) - FastDestroyableSingleton.Instance.SetInLobbyHost(instance.LastPlayerCount, GameManager.Instance.LogicOptions.MaxPlayers, AmongUsClient.Instance.GameId); + DiscordManager.Instance.SetInLobbyHost(instance.LastPlayerCount, GameManager.Instance.LogicOptions.MaxPlayers, AmongUsClient.Instance.GameId); else - FastDestroyableSingleton.Instance.SetInLobbyClient(instance.LastPlayerCount, GameManager.Instance.LogicOptions.MaxPlayers, AmongUsClient.Instance.GameId); + DiscordManager.Instance.SetInLobbyClient(instance.LastPlayerCount, GameManager.Instance.LogicOptions.MaxPlayers, AmongUsClient.Instance.GameId); } } @@ -307,14 +307,14 @@ public static class GameStartManagerPatch if (!instance.GameStartTextParent.activeSelf) SoundManager.Instance.PlaySound(instance.gameStartSound, false); instance.GameStartTextParent.SetActive(true); - instance.GameStartText.text = FastDestroyableSingleton.Instance.GetString(StringNames.GameStarting, num2); + instance.GameStartText.text = TranslationController.Instance.GetString(StringNames.GameStarting, num2); if (num != num2) PlayerControl.LocalPlayer.RpcSetStartCounter(num2); if (num2 <= 0) instance.FinallyBegin(); } else { - instance.StartButton.ChangeButtonText(FastDestroyableSingleton.Instance.GetString(StringNames.StartLabel)); + instance.StartButton.ChangeButtonText(TranslationController.Instance.GetString(StringNames.StartLabel)); instance.StartButton.inactiveSprites.GetComponent().color = new(0.1f, 0.1f, 0.1f, 1f); instance.StartButton.activeSprites.GetComponent().color = new(0.2f, 0.2f, 0.2f, 1f); instance.StartButton.inactiveSprites.transform.Find("Shine").GetComponent().color = new(0.3f, 0.3f, 0.3f, 0.5f); @@ -326,10 +326,10 @@ public static class GameStartManagerPatch if (!HudManager.InstanceExists) return; - if (instance.LobbyInfoPane.gameObject.activeSelf && FastDestroyableSingleton.Instance.Chat.IsOpenOrOpening) + if (instance.LobbyInfoPane.gameObject.activeSelf && HudManager.Instance.Chat.IsOpenOrOpening) instance.LobbyInfoPane.DeactivatePane(); - instance.LobbyInfoPane.gameObject.SetActive(!FastDestroyableSingleton.Instance.Chat.IsOpenOrOpening); + instance.LobbyInfoPane.gameObject.SetActive(!HudManager.Instance.Chat.IsOpenOrOpening); } #if !ANDROID @@ -461,14 +461,14 @@ public static class GameStartManagerPatch { float timer = Timer; - if (LobbyTimerBg == null) LobbyTimerBg = FastDestroyableSingleton.Instance.LobbyTimerExtensionUI.timerText.transform.parent.transform.Find("LabelBackground").GetComponent(); + if (LobbyTimerBg == null) LobbyTimerBg = HudManager.Instance.LobbyTimerExtensionUI.timerText.transform.parent.transform.Find("LabelBackground").GetComponent(); LobbyTimerBg.sprite = Utils.LoadSprite("EHR.Resources.Images.LobbyTimerBG.png", 100f); LobbyTimerBg.color = GetTimerColor(timer); if (timer <= 60 && !Warned && AmongUsClient.Instance.AmHost) { Warned = true; - LobbyTimerExtensionUI lobbyTimerExtensionUI = FastDestroyableSingleton.Instance.LobbyTimerExtensionUI; + LobbyTimerExtensionUI lobbyTimerExtensionUI = HudManager.Instance.LobbyTimerExtensionUI; lobbyTimerExtensionUI.timerText.transform.parent.transform.Find("Icon").gameObject.SetActive(true); SoundManager.Instance.PlaySound(lobbyTimerExtensionUI.lobbyTimerPopUpSound, false); Utils.FlashColor(new(1f, 1f, 0f, 0.4f), 2f); diff --git a/Patches/HudPatch.cs b/Patches/HudPatch.cs index 7af688d5f..e4c904739 100644 --- a/Patches/HudPatch.cs +++ b/Patches/HudPatch.cs @@ -1237,7 +1237,7 @@ internal static class TaskPanelBehaviourPatch if (taskList == "None" || GameStates.IsLobby || player == null) return; NetworkedPlayerInfo data = PlayerControl.LocalPlayer.Data; - if (data && data.Role) taskList = taskList.Replace($"\n{data.Role.NiceName} {FastDestroyableSingleton.Instance.GetString(StringNames.RoleHint)}\n{data.Role.BlurbMed}", string.Empty); + if (data && data.Role) taskList = taskList.Replace($"\n{data.Role.NiceName} {TranslationController.Instance.GetString(StringNames.RoleHint)}\n{data.Role.BlurbMed}", string.Empty); if (Options.CurrentGameMode is not (CustomGameMode.Standard or CustomGameMode.MoveAndStop or CustomGameMode.HideAndSeek or CustomGameMode.Speedrun)) taskList = GetString("None"); diff --git a/Patches/IntroPatch.cs b/Patches/IntroPatch.cs index 06804effa..df8ee119c 100644 --- a/Patches/IntroPatch.cs +++ b/Patches/IntroPatch.cs @@ -131,7 +131,7 @@ static class CoShowIntroPatch else { int adjustedNumImpostors = GameManager.Instance.LogicOptions.GetAdjustedNumImpostors(GameData.Instance.PlayerCount); - introCutscene.ImpostorText.text = adjustedNumImpostors == 1 ? FastDestroyableSingleton.Instance.GetString(StringNames.NumImpostorsS) : FastDestroyableSingleton.Instance.GetString(StringNames.NumImpostorsP, adjustedNumImpostors); + introCutscene.ImpostorText.text = adjustedNumImpostors == 1 ? TranslationController.Instance.GetString(StringNames.NumImpostorsS) : TranslationController.Instance.GetString(StringNames.NumImpostorsP, adjustedNumImpostors); introCutscene.ImpostorText.text = introCutscene.ImpostorText.text.Replace("[FF1919FF]", ""); introCutscene.ImpostorText.text = introCutscene.ImpostorText.text.Replace("[]", ""); } @@ -632,21 +632,21 @@ internal static class BeginCrewmatePatch CustomRoles.Dictator or CustomRoles.Mayor or CustomRoles.NiceSwapper - => FastDestroyableSingleton.Instance.Chat.messageSound, + => HudManager.Instance.Chat.messageSound, CustomRoles.AntiAdminer or CustomRoles.Monitor - => FastDestroyableSingleton.Instance.Chat.warningSound, + => HudManager.Instance.Chat.warningSound, CustomRoles.GM or CustomRoles.Snitch or CustomRoles.Speedrunner or CustomRoles.Workaholic - => FastDestroyableSingleton.Instance.TaskCompleteSound, + => HudManager.Instance.TaskCompleteSound, CustomRoles.Helper or CustomRoles.TaskManager - => FastDestroyableSingleton.Instance.TaskUpdateSound, + => HudManager.Instance.TaskUpdateSound, CustomRoles.Inhibitor or CustomRoles.Mechanic or @@ -687,11 +687,11 @@ internal static class BeginCrewmatePatch CustomRoles.Chronomancer or CustomRoles.Tremor - => FastDestroyableSingleton.Instance.HnSOtherImpostorTransformSfx, + => DestroyableSingleton.Instance.HnSOtherImpostorTransformSfx, CustomRoles.Deputy or CustomRoles.Sheriff - => FastDestroyableSingleton.Instance.HnSOtherYeehawSfx, + => DestroyableSingleton.Instance.HnSOtherYeehawSfx, CustomRoles.Hater or CustomRoles.Lawyer or @@ -850,7 +850,7 @@ internal static class BeginCrewmatePatch __instance.ImpostorText.gameObject.SetActive(true); __instance.ImpostorText.text = GetString("ModeSoloKombat"); __instance.BackgroundBar.material.color = color; - PlayerControl.LocalPlayer.Data.Role.IntroSound = FastDestroyableSingleton.Instance.HnSOtherImpostorTransformSfx; + PlayerControl.LocalPlayer.Data.Role.IntroSound = DestroyableSingleton.Instance.HnSOtherImpostorTransformSfx; break; } case CustomGameMode.FFA: @@ -1329,7 +1329,7 @@ internal static class IntroCutsceneDestroyPatch if (!HudManager.InstanceExists) return; - HudManager hud = FastDestroyableSingleton.Instance; + HudManager hud = HudManager.Instance; HudSpritePatch.DefaultIcons = [ diff --git a/Patches/NotificationPopperPatch.cs b/Patches/NotificationPopperPatch.cs index 4e8d2d6bc..3ef0c3273 100644 --- a/Patches/NotificationPopperPatch.cs +++ b/Patches/NotificationPopperPatch.cs @@ -34,8 +34,8 @@ internal static class NotificationPopperPatch if (parentName == "Accept") return; string str = key.Parent != null - ? FastDestroyableSingleton.Instance.GetString(StringNames.LobbyChangeSettingNotification, "" + parentName + ": " + name + "", "" + optValue + "") - : FastDestroyableSingleton.Instance.GetString(StringNames.LobbyChangeSettingNotification, "" + name + "", "" + optValue + ""); + ? TranslationController.Instance.GetString(StringNames.LobbyChangeSettingNotification, "" + parentName + ": " + name + "", "" + optValue + "") + : TranslationController.Instance.GetString(StringNames.LobbyChangeSettingNotification, "" + name + "", "" + optValue + ""); SettingsChangeMessageLogic(key, str, playSound); } @@ -49,7 +49,7 @@ internal static class NotificationPopperPatch if (name == "Accept") return; SendRpc(1, index, customRole, playSound); - string str = FastDestroyableSingleton.Instance.GetString(StringNames.LobbyChangeSettingNotification, "" + name + "", "" + optValue + ""); + string str = TranslationController.Instance.GetString(StringNames.LobbyChangeSettingNotification, "" + name + "", "" + optValue + ""); SettingsChangeMessageLogic(key, str, playSound); } diff --git a/Patches/OnGameStartedPatch.cs b/Patches/OnGameStartedPatch.cs index aeecfe688..5fd718b8b 100644 --- a/Patches/OnGameStartedPatch.cs +++ b/Patches/OnGameStartedPatch.cs @@ -43,14 +43,14 @@ internal static class ChangeRoleSettings { AmongUsClient amongUsClient = __instance; - if (FastDestroyableSingleton.Instance.GameMenu.IsOpen) - FastDestroyableSingleton.Instance.GameMenu.Close(); + if (HudManager.Instance.GameMenu.IsOpen) + HudManager.Instance.GameMenu.Close(); - FastDestroyableSingleton.Instance.Init(); + UnityTelemetry.Instance.Init(); amongUsClient.logger.Info("Received game start: " + amongUsClient.AmHost); yield return null; - while (!DestroyableSingleton.InstanceExists) + while (!HudManager.InstanceExists) yield return null; while (!PlayerControl.LocalPlayer) @@ -68,34 +68,34 @@ internal static class ChangeRoleSettings if (objectOfType2) objectOfType2.Close(); - if (DestroyableSingleton.InstanceExists) + if (GameStartManager.InstanceExists) { - amongUsClient.DisconnectHandlers.Remove(FastDestroyableSingleton.Instance.CastFast()); - Object.Destroy(FastDestroyableSingleton.Instance.gameObject); + amongUsClient.DisconnectHandlers.Remove(GameStartManager.Instance.CastFast()); + Object.Destroy(GameStartManager.Instance.gameObject); } - if (DestroyableSingleton.InstanceExists) - Object.Destroy(FastDestroyableSingleton.Instance.gameObject); + if (LobbyInfoPane.InstanceExists) + Object.Destroy(LobbyInfoPane.Instance.gameObject); - if (DestroyableSingleton.InstanceExists) - FastDestroyableSingleton.Instance.SetPlayingGame(); + if (DiscordManager.InstanceExists) + DiscordManager.Instance.SetPlayingGame(); if (!string.IsNullOrEmpty(DataManager.Player.Store.ActiveCosmicube)) - AmongUsClient.Instance.SetActivePodType(FastDestroyableSingleton.Instance.GetCubeDataByID(DataManager.Player.Store.ActiveCosmicube).podId); + AmongUsClient.Instance.SetActivePodType(CosmicubeManager.Instance.GetCubeDataByID(DataManager.Player.Store.ActiveCosmicube).podId); else { - PlayerStorageManager.CloudPlayerPrefs playerPrefs = FastDestroyableSingleton.Instance.PlayerPrefs; + PlayerStorageManager.CloudPlayerPrefs playerPrefs = PlayerStorageManager.Instance.PlayerPrefs; AmongUsClient.Instance.SetActivePodType(playerPrefs.ActivePodType); } - FastDestroyableSingleton.Instance.ConfirmationScreen.Cancel(); - FastDestroyableSingleton.Instance.Ui.Close(true); - FastDestroyableSingleton.Instance.ReparentUI(); + FriendsListManager.Instance.ConfirmationScreen.Cancel(); + FriendsListManager.Instance.Ui.Close(true); + FriendsListManager.Instance.ReparentUI(); try { CosmeticsCache.ClearUnusedCosmetics(); } catch (Exception e) { Utils.ThrowException(e); } - yield return FastDestroyableSingleton.Instance.CoFadeFullScreen(Color.clear, Color.black); + yield return HudManager.Instance.CoFadeFullScreen(Color.clear, Color.black); ++DataManager.Player.Ban.BanPoints; DataManager.Player.Ban.PreviousGameStartDate = DateTime.UtcNow; DataManager.Player.Save(); @@ -126,17 +126,17 @@ internal static class ChangeRoleSettings } } - FastDestroyableSingleton.Instance.SetRecentlyPlayed(GameData.Instance.AllPlayers); + FriendsListManager.Instance.SetRecentlyPlayed(GameData.Instance.AllPlayers); GameData.TimeGameStarted = Time.realtimeSinceStartup; int map = Mathf.Clamp(GameOptionsManager.Instance.CurrentGameOptions.MapId, 0, Constants.MapNames.Length - 1); string gameName = GameCode.IntToGameName(AmongUsClient.Instance.GameId); - FastDestroyableSingleton.Instance.Analytics.StartGame(PlayerControl.LocalPlayer.Data, GameData.Instance.PlayerCount, GameOptionsManager.Instance.CurrentGameOptions.NumImpostors, AmongUsClient.Instance.NetworkMode, (MapNames)map, GameOptionsManager.Instance.CurrentGameOptions.GameMode, gameName, FastDestroyableSingleton.Instance.CurrentRegion.Name, GameOptionsManager.Instance.CurrentGameOptions, GameData.Instance.AllPlayers); + DebugAnalytics.Instance.Analytics.StartGame(PlayerControl.LocalPlayer.Data, GameData.Instance.PlayerCount, GameOptionsManager.Instance.CurrentGameOptions.NumImpostors, AmongUsClient.Instance.NetworkMode, (MapNames)map, GameOptionsManager.Instance.CurrentGameOptions.GameMode, gameName, ServerManager.Instance.CurrentRegion.Name, GameOptionsManager.Instance.CurrentGameOptions, GameData.Instance.AllPlayers); try { - FastDestroyableSingleton.Instance.StartGame(AmongUsClient.Instance.AmHost, GameData.Instance.PlayerCount, GameOptionsManager.Instance.CurrentGameOptions.NumImpostors, AmongUsClient.Instance.NetworkMode, DataManager.Player.Stats.GetStat(StatID.GamesAsImpostor), DataManager.Player.Stats.GetStat(StatID.GamesStarted), DataManager.Player.Stats.GetStat(StatID.CrewmateStreak)); + UnityTelemetry.Instance.StartGame(AmongUsClient.Instance.AmHost, GameData.Instance.PlayerCount, GameOptionsManager.Instance.CurrentGameOptions.NumImpostors, AmongUsClient.Instance.NetworkMode, DataManager.Player.Stats.GetStat(StatID.GamesAsImpostor), DataManager.Player.Stats.GetStat(StatID.GamesStarted), DataManager.Player.Stats.GetStat(StatID.CrewmateStreak)); NetworkedPlayerInfo.PlayerOutfit defaultOutfit = PlayerControl.LocalPlayer.Data.DefaultOutfit; - FastDestroyableSingleton.Instance.StartGameCosmetics(defaultOutfit.ColorId, defaultOutfit.HatId, defaultOutfit.SkinId, defaultOutfit.PetId, defaultOutfit.VisorId, defaultOutfit.NamePlateId); + UnityTelemetry.Instance.StartGameCosmetics(defaultOutfit.ColorId, defaultOutfit.HatId, defaultOutfit.SkinId, defaultOutfit.PetId, defaultOutfit.VisorId, defaultOutfit.NamePlateId); } catch { } @@ -540,7 +540,7 @@ internal static class StartGameHostPatch catch (Exception e) { Utils.ThrowException(e); } string loadingTextText1 = GetString("LoadingBarText.1"); - LoadingBarManager loadingBarManager = FastDestroyableSingleton.Instance; + LoadingBarManager loadingBarManager = LoadingBarManager.Instance; try { @@ -1136,7 +1136,7 @@ internal static class StartGameHostPatch } - LoadingBarManager loadingBarManager = FastDestroyableSingleton.Instance; + LoadingBarManager loadingBarManager = LoadingBarManager.Instance; yield return loadingBarManager.WaitAndSmoothlyUpdate(90f, 95f, 1f, GetString("LoadingBarText.1")); foreach (PlayerControl pc in PlayerControl.AllPlayerControls) diff --git a/Patches/PhantomRolePatch.cs b/Patches/PhantomRolePatch.cs index cf8641a76..cfe2be05b 100644 --- a/Patches/PhantomRolePatch.cs +++ b/Patches/PhantomRolePatch.cs @@ -160,7 +160,7 @@ public static class PhantomRolePatch { if (phantom.AmOwner) { - FastDestroyableSingleton.Instance.AbilityButton.SetFromSettings(phantom.Data.Role.Ability); + HudManager.Instance.AbilityButton.SetFromSettings(phantom.Data.Role.Ability); if (Utils.ShouldNotApplyAbilityCooldown(roleBase)) return false; phantom.Data.Role.SetCooldown(); return false; @@ -353,8 +353,8 @@ public static class PhantomRoleUseAbilityPatch return false; } - FastDestroyableSingleton.Instance.AbilityButton.SetSecondImage(__instance.Ability); - FastDestroyableSingleton.Instance.AbilityButton.OverrideText(FastDestroyableSingleton.Instance.GetString(StringNames.PhantomAbilityUndo, new Il2CppReferenceArray(0))); + HudManager.Instance.AbilityButton.SetSecondImage(__instance.Ability); + HudManager.Instance.AbilityButton.OverrideText(TranslationController.Instance.GetString(StringNames.PhantomAbilityUndo, new Il2CppReferenceArray(0))); __instance.Player.CmdCheckVanish(GameManager.Instance.LogicOptions.GetRoleFloat(FloatOptionNames.PhantomDuration)); return false; } diff --git a/Patches/PlayerControlPatch.cs b/Patches/PlayerControlPatch.cs index 7ece64fa6..0cfda9073 100644 --- a/Patches/PlayerControlPatch.cs +++ b/Patches/PlayerControlPatch.cs @@ -1189,7 +1189,7 @@ internal static class ReportDeadBodyPatch CustomNetObject.OnMeeting(); - if (HudManager.InstanceExists) FastDestroyableSingleton.Instance.SetRolePanelOpen(false); + if (HudManager.InstanceExists) HudManager.Instance.SetRolePanelOpen(false); Asthmatic.RunChecks = false; diff --git a/Patches/PlayerJoinAndLeftPatch.cs b/Patches/PlayerJoinAndLeftPatch.cs index f0a24bec2..0699f7d30 100644 --- a/Patches/PlayerJoinAndLeftPatch.cs +++ b/Patches/PlayerJoinAndLeftPatch.cs @@ -472,7 +472,7 @@ internal static class OnPlayerJoinedPatch Logger.Info(msg, "Android Kick"); } - if (FriendsListManager.InstanceExists && FastDestroyableSingleton.Instance.IsPlayerBlockedUsername(client.FriendCode) && AmongUsClient.Instance.AmHost && GameStates.CurrentServerType is not GameStates.ServerType.Modded and not GameStates.ServerType.Niko and not GameStates.ServerType.Local) + if (FriendsListManager.InstanceExists && FriendsListManager.Instance.IsPlayerBlockedUsername(client.FriendCode) && AmongUsClient.Instance.AmHost && GameStates.CurrentServerType is not GameStates.ServerType.Modded and not GameStates.ServerType.Niko and not GameStates.ServerType.Local) { AmongUsClient.Instance.KickPlayer(client.Id, true); Logger.Info($"Blocked Player {client.PlayerName}({client.FriendCode}) has been banned.", "BAN"); @@ -503,7 +503,7 @@ internal static class OnPlayerLeftPatch case CustomGameMode.HideAndSeek: CustomHnS.PlayerRoles.Remove(data.Character.PlayerId); break; - case CustomGameMode.Mingle: + case CustomGameMode.Mingle when data.Character.IsAlive(): Mingle.HandleDisconnect(); break; } diff --git a/Patches/SabotageButtonPatch.cs b/Patches/SabotageButtonPatch.cs index d0cd5d51e..a38a9ba10 100644 --- a/Patches/SabotageButtonPatch.cs +++ b/Patches/SabotageButtonPatch.cs @@ -10,7 +10,7 @@ public static class SabotageButtonDoClickPatch { if (!PlayerControl.LocalPlayer.inVent && GameManager.Instance.SabotagesEnabled() && HudManager.InstanceExists) { - FastDestroyableSingleton.Instance.ToggleMapVisible(new() + HudManager.Instance.ToggleMapVisible(new() { Mode = MapOptions.Modes.Sabotage }); diff --git a/Patches/ServerDropdownPatch.cs b/Patches/ServerDropdownPatch.cs index 5b169e8e0..f01e0629c 100644 --- a/Patches/ServerDropdownPatch.cs +++ b/Patches/ServerDropdownPatch.cs @@ -17,8 +17,8 @@ public static class ServerDropdownPatch if (SceneManager.GetActiveScene().name == "FindAGame") return true; SpriteRenderer bg = __instance.background; bg.size = new Vector2(4, 1); - ServerManager sm = FastDestroyableSingleton.Instance; - TranslationController tc = FastDestroyableSingleton.Instance; + ServerManager sm = ServerManager.Instance; + TranslationController tc = TranslationController.Instance; int totalCols = Mathf.Max(1, Mathf.CeilToInt(sm.AvailableRegions.Length / (float)5)); int rowLimit = Mathf.Min(sm.AvailableRegions.Length, 5); diff --git a/Patches/TextBoxPatch.cs b/Patches/TextBoxPatch.cs index a0d25e85d..77e0131d1 100644 --- a/Patches/TextBoxPatch.cs +++ b/Patches/TextBoxPatch.cs @@ -63,7 +63,7 @@ public static class TextBoxPatch } } - if (!__instance.tempTxt.ToString().Equals(FastDestroyableSingleton.Instance.GetString(StringNames.EnterName), StringComparison.OrdinalIgnoreCase) && __instance.characterLimit > 0) + if (!__instance.tempTxt.ToString().Equals(TranslationController.Instance.GetString(StringNames.EnterName), StringComparison.OrdinalIgnoreCase) && __instance.characterLimit > 0) { int length = __instance.tempTxt.Length; __instance.tempTxt.Length = Math.Min(__instance.tempTxt.Length, __instance.characterLimit); @@ -185,7 +185,7 @@ public static class TextBoxPatch } IsInvalidCommand = false; - HudManager hud = FastDestroyableSingleton.Instance; + HudManager hud = HudManager.Instance; if (PlaceHolderText == null) { @@ -341,7 +341,7 @@ public static class TextBoxPatch if (AdditionalInfoText != null) { - bool showLobbyCode = FastDestroyableSingleton.Instance?.Chat?.IsOpenOrOpening == true && GameStates.IsLobby && Options.GetSuffixMode() == SuffixModes.Streaming && !Options.HideGameSettings.GetBool() && !DataManager.Settings.Gameplay.StreamerMode; + bool showLobbyCode = HudManager.Instance?.Chat?.IsOpenOrOpening == true && GameStates.IsLobby && Options.GetSuffixMode() == SuffixModes.Streaming && !Options.HideGameSettings.GetBool() && !DataManager.Settings.Gameplay.StreamerMode; AdditionalInfoText.enabled = showLobbyCode; if (showLobbyCode) AdditionalInfoText.text = $"\n\n{Translator.GetString("LobbyCode")}:\n{GameCode.IntToGameName(AmongUsClient.Instance.GameId)}"; } @@ -363,7 +363,7 @@ public static class TextBoxPatch { try { - bool open = HudManager.InstanceExists && (FastDestroyableSingleton.Instance?.Chat?.IsOpenOrOpening ?? false); + bool open = HudManager.InstanceExists && (HudManager.Instance?.Chat?.IsOpenOrOpening ?? false); PlaceHolderText?.gameObject.SetActive(open); CommandInfoText?.gameObject.SetActive(open); AdditionalInfoText?.gameObject.SetActive(open); diff --git a/Roles/Impostor/Stealth.cs b/Roles/Impostor/Stealth.cs index 76ed6fbf5..769301a72 100644 --- a/Roles/Impostor/Stealth.cs +++ b/Roles/Impostor/Stealth.cs @@ -227,6 +227,6 @@ public sealed class Stealth : RoleBase seen ??= seer; if (isForMeeting || seer != StealthPC || seen != StealthPC || !darkenedRoom.HasValue) return base.GetSuffix(seer, seen, isForMeeting, isForHud); - return string.Format(Translator.GetString("StealthDarkened"), FastDestroyableSingleton.Instance.GetString(darkenedRoom.Value)); + return string.Format(Translator.GetString("StealthDarkened"), TranslationController.Instance.GetString(darkenedRoom.Value)); } } \ No newline at end of file