diff --git a/Modules/GameOptionsSender/PlayerGameOptionsSender.cs b/Modules/GameOptionsSender/PlayerGameOptionsSender.cs index d3c0074b7..e3d899089 100644 --- a/Modules/GameOptionsSender/PlayerGameOptionsSender.cs +++ b/Modules/GameOptionsSender/PlayerGameOptionsSender.cs @@ -740,9 +740,6 @@ public sealed class PlayerGameOptionsSender(PlayerControl player) : GameOptionsS case RoleTypes.Engineer: AURoleOptions.EngineerCooldown *= 0.75f; break; - case RoleTypes.GuardianAngel: - AURoleOptions.GuardianAngelCooldown *= 0.75f; - break; case RoleTypes.Shapeshifter: AURoleOptions.ShapeshifterCooldown *= 0.75f; break; diff --git a/Modules/GhostRolesManager.cs b/Modules/GhostRolesManager.cs index 6167a02d6..dddc3ce70 100644 --- a/Modules/GhostRolesManager.cs +++ b/Modules/GhostRolesManager.cs @@ -32,13 +32,15 @@ internal static class GhostRolesManager IGhostRole instance = CreateGhostRoleInstance(suitableRole); pc.RpcSetCustomRole(suitableRole); pc.RpcSetRoleDesync(instance.RoleTypes, pc.OwnerId); - pc.AddAbilityCD(instance.Cooldown); instance.OnAssign(pc); Main.ResetCamPlayerList.Add(pc.PlayerId); AssignedGhostRoles[pc.PlayerId] = (suitableRole, instance); if (suitableRole == CustomRoles.Haunter) GhostRoles.Remove(suitableRole); + + if (instance.RoleTypes == RoleTypes.GuardianAngel) + pc.AddAbilityCD(instance.Cooldown); NotifyAboutGhostRole(pc, true); } diff --git a/Modules/LobbySharingAPI.cs b/Modules/LobbySharingAPI.cs index 3b32b9783..6bc4b6f69 100644 --- a/Modules/LobbySharingAPI.cs +++ b/Modules/LobbySharingAPI.cs @@ -162,7 +162,6 @@ internal static class ExitGamePatch GameStates.InGame = false; GameEndChecker.LoadingEndScreen = false; - Main.RealOptionsData?.Restore(GameOptionsManager.Instance.CurrentGameOptions); DataFlagRateLimiter.DropQueue(); if (SetUpRoleTextPatch.IsInIntro) @@ -170,6 +169,9 @@ internal static class ExitGamePatch SetUpRoleTextPatch.IsInIntro = false; Utils.NotifyRoles(ForceLoop: true); } + + if (GameSettingMenu.Instance) + GameSettingMenuPatch.Close_Prefix(); } public static void Postfix(InnerNetClient __instance) diff --git a/Modules/OnlinePresetsManager.cs b/Modules/OnlinePresetsManager.cs index 9effbb7ab..af5bc0907 100644 --- a/Modules/OnlinePresetsManager.cs +++ b/Modules/OnlinePresetsManager.cs @@ -156,7 +156,7 @@ public static class OnlinePresetsManager GameSettingMenu.Instance.ChangeTab(tabIndex, Controller.currentTouchType == Controller.TouchType.Joystick); ModGameOptionsMenu.TabIndex = tabIndex; }, 0.4f); - }); + }, showBackButton: false); })); TextMeshPro minusText = row.MinusBtn.GetComponentInChildren(); minusText.DestroyTranslator(); diff --git a/Modules/Prompt.cs b/Modules/Prompt.cs index 7ace0c1ea..424cdb764 100644 --- a/Modules/Prompt.cs +++ b/Modules/Prompt.cs @@ -14,7 +14,7 @@ public static class Prompt private static string CurrentQuestion = string.Empty; private static bool ShowBackButton; - public static void Show(string question, Action onYes, Action onNo, bool showBackButton = false) + public static void Show(string question, Action onYes, Action onNo, bool showBackButton = true) { try { diff --git a/Modules/SimpleButton.cs b/Modules/SimpleButton.cs index dd4c16a8d..f22719e7f 100644 --- a/Modules/SimpleButton.cs +++ b/Modules/SimpleButton.cs @@ -71,7 +71,9 @@ public class SimpleButton { if (BaseButton || !passiveButton) return; - BaseButton = Object.Instantiate(passiveButton); + GameObject parent = new GameObject("BaseButton parent"); + Object.DontDestroyOnLoad(parent); + BaseButton = Object.Instantiate(passiveButton, parent.transform); var label = BaseButton.transform.Find("FontPlacer/Text_TMP").GetComponent(); BaseButton.gameObject.SetActive(false); diff --git a/Modules/Utils.cs b/Modules/Utils.cs index 2d10716db..e745e3afe 100644 --- a/Modules/Utils.cs +++ b/Modules/Utils.cs @@ -5076,8 +5076,7 @@ public static class Utils Prompt.Show( string.Format(GetString("Promt.EnableRole"), count, all, rotStr, role.ToColoredString(), infoLong), (() => option.SetValue(1)) + increment, - (() => option.SetValue(0)) + increment, - showBackButton: true); + (() => option.SetValue(0)) + increment); } if (addons) return; @@ -5249,4 +5248,4 @@ public enum MessageImportance Low, Medium, High -} +} \ No newline at end of file diff --git a/Patches/GameOptionsMenuPatch.cs b/Patches/GameOptionsMenuPatch.cs index 29bcc4657..aaf0421b1 100644 --- a/Patches/GameOptionsMenuPatch.cs +++ b/Patches/GameOptionsMenuPatch.cs @@ -25,20 +25,9 @@ public static class ModGameOptionsMenu public static readonly Dictionary CategoryHeaderList = new(); public static readonly System.Collections.Generic.Dictionary HelpIconList = []; public static readonly System.Collections.Generic.Dictionary BaseGameSettingCache = []; - public static readonly HashSet SpawnedUI = new(); public static T Track(T obj) where T : Object { - switch (obj) - { - case GameObject go: - SpawnedUI.Add(go); - break; - case Component c: - SpawnedUI.Add(c.gameObject); - break; - } - return obj; } @@ -1000,6 +989,7 @@ public static class GameSettingMenuPatch public static readonly System.Collections.Generic.Dictionary ModSettingsTabs = []; public static long LastPresetChange; + public static bool ChangingPreset; public static FreeChatInputField InputField; private static System.Collections.Generic.List HiddenBySearch = []; @@ -1135,6 +1125,7 @@ public static class GameSettingMenuPatch minus.OnClick.AddListener((Action)(() => { + ChangingPreset = true; LastPresetChange = Utils.TimeStamp; Options.Preset--; Main.TabGroupValues.Do(GameOptionsMenuPatch.ReCreateSettings); @@ -1142,6 +1133,8 @@ public static class GameSettingMenuPatch GameOptionsMenuPatch.RefreshTabButtons(); presetTmp.SetText(Translator.GetString($"Preset_{OptionItem.CurrentPreset + 1}")); Logger.Info($"Current preset: {OptionItem.CurrentPreset + 1}", "GameOptionsMenuPatch"); + ChangingPreset = false; + NotificationPopperPatch.AddSettingsChangeMessage(Options.Preset, true); })); minus.activeTextColor = minus.inactiveTextColor = minus.disabledTextColor = minus.selectedTextColor = Color.white; @@ -1181,6 +1174,7 @@ public static class GameSettingMenuPatch plus.OnClick.AddListener((Action)(() => { + ChangingPreset = true; LastPresetChange = Utils.TimeStamp; Options.Preset++; Main.TabGroupValues.Do(GameOptionsMenuPatch.ReCreateSettings); @@ -1188,6 +1182,8 @@ public static class GameSettingMenuPatch GameOptionsMenuPatch.RefreshTabButtons(); presetTmp.SetText(Translator.GetString($"Preset_{OptionItem.CurrentPreset + 1}")); Logger.Info($"Current preset: {OptionItem.CurrentPreset + 1}", "GameOptionsMenuPatch"); + ChangingPreset = false; + NotificationPopperPatch.AddSettingsChangeMessage(Options.Preset, true); })); plus.activeTextColor = plus.inactiveTextColor = plus.disabledTextColor = plus.selectedTextColor = Color.white; diff --git a/Patches/MeetingHudPatch.cs b/Patches/MeetingHudPatch.cs index a374cfda3..f6b4cf040 100644 --- a/Patches/MeetingHudPatch.cs +++ b/Patches/MeetingHudPatch.cs @@ -1361,6 +1361,10 @@ internal static class MeetingHudOnDestroyPatch } if (Main.LIMap) Main.Instance.StartCoroutine(WaitForExileFinish()); + + GC.Collect(); + Resources.UnloadUnusedAssets(); + GC.Collect(); return; IEnumerator WaitForExileFinish() diff --git a/Patches/NotificationPopperPatch.cs b/Patches/NotificationPopperPatch.cs index 52a79fddc..a3aa84193 100644 --- a/Patches/NotificationPopperPatch.cs +++ b/Patches/NotificationPopperPatch.cs @@ -22,7 +22,7 @@ internal static class NotificationPopperPatch public static void AddSettingsChangeMessage(OptionItem option, bool playSound = false) { - if (Utils.TimeStamp == GameSettingMenuPatch.LastPresetChange) return; + if (GameSettingMenuPatch.ChangingPreset) return; string optValue = option.GetString(); if (optValue == "STRMISS") return; diff --git a/Patches/OnGameStartedPatch.cs b/Patches/OnGameStartedPatch.cs index f4e9b39ee..d8d2f2a0a 100644 --- a/Patches/OnGameStartedPatch.cs +++ b/Patches/OnGameStartedPatch.cs @@ -347,6 +347,7 @@ internal static class ChangeRoleSettings GC.Collect(); Resources.UnloadUnusedAssets(); + GC.Collect(); } catch (Exception ex) { diff --git a/Patches/OutroPatch.cs b/Patches/OutroPatch.cs index c50293f8a..a327b47cf 100644 --- a/Patches/OutroPatch.cs +++ b/Patches/OutroPatch.cs @@ -487,8 +487,9 @@ internal static class SetEverythingUpPatch yield return null; - // Clear unused assets + GC.Collect(); Resources.UnloadUnusedAssets(); + GC.Collect(); yield return null; Vector3 pos = main.ViewportToWorldPoint(new(0f, 1f, main.nearClipPlane)); diff --git a/Patches/PlayerJoinAndLeftPatch.cs b/Patches/PlayerJoinAndLeftPatch.cs index 7f5c71b63..e8494ae45 100644 --- a/Patches/PlayerJoinAndLeftPatch.cs +++ b/Patches/PlayerJoinAndLeftPatch.cs @@ -86,6 +86,8 @@ internal static class OnGameJoinedPatch LateTask.New(() => { JoiningGame = false; + + Main.RealOptionsData?.Restore(GameOptionsManager.Instance.CurrentGameOptions); Options.AutoSetFactionMinMaxSettings(); diff --git a/Roles/Standard/Crewmate/Miscellaneous/Vacuum.cs b/Roles/Standard/Crewmate/Miscellaneous/Vacuum.cs index 940fa2f87..3e3d2c548 100644 --- a/Roles/Standard/Crewmate/Miscellaneous/Vacuum.cs +++ b/Roles/Standard/Crewmate/Miscellaneous/Vacuum.cs @@ -60,9 +60,6 @@ public class Vacuum : RoleBase AURoleOptions.EngineerCooldown = AbilityCooldown.GetFloat(); AURoleOptions.EngineerInVentMaxTime = 1f; - - try { AURoleOptions.GuardianAngelCooldown = 900f; } - catch { } } public override void OnEnterVent(PlayerControl pc, Vent vent) @@ -99,7 +96,7 @@ public class Vacuum : RoleBase { if (instance.Timer == null) continue; PlayerControl vacuum = instance.VacuumId.GetPlayer(); - if (vacuum == null || !vacuum.IsAlive()) continue; + if (!vacuum || !vacuum.IsAlive()) continue; target.TP(vacuum); return false; } diff --git a/Roles/Standard/Crewmate/Power/Astral.cs b/Roles/Standard/Crewmate/Power/Astral.cs index 388339415..ee6a9c5f6 100644 --- a/Roles/Standard/Crewmate/Power/Astral.cs +++ b/Roles/Standard/Crewmate/Power/Astral.cs @@ -52,9 +52,6 @@ public class Astral : RoleBase AURoleOptions.EngineerCooldown = AbilityCooldown.GetFloat(); AURoleOptions.EngineerInVentMaxTime = 1f; - - try { AURoleOptions.GuardianAngelCooldown = 900f; } - catch { } } public override void OnEnterVent(PlayerControl pc, Vent vent)