diff --git a/Main.cs b/Main.cs index e4f168461..cfece0742 100644 --- a/Main.cs +++ b/Main.cs @@ -41,9 +41,9 @@ public class Main : BasePlugin private const string DebugKeyHash = "c0fd562955ba56af3ae20d7ec9e64c664f0facecef4b3e366e109306adeae29d"; private const string DebugKeySalt = "59687b"; public const string PluginGuid = "com.gurge44.endlesshostroles"; - public const string PluginVersion = "7.5.1"; - public const string PluginDisplayVersion = "7.5.1"; - public const bool TestBuild = false; + public const string PluginVersion = "7.5.2"; + public const string PluginDisplayVersion = "7.5.2"; + public const bool TestBuild = true; public const string NeutralColor = "#ffab1b"; public const string ImpostorColor = "#ff1919"; diff --git a/Modules/ExtendedPlayerControl.cs b/Modules/ExtendedPlayerControl.cs index eb1013c3e..b24d4af32 100644 --- a/Modules/ExtendedPlayerControl.cs +++ b/Modules/ExtendedPlayerControl.cs @@ -1675,14 +1675,14 @@ internal static class ExtendedPlayerControl { if (!player || !target) return false; - return Revolutionist.IsDraw.GetValueOrDefault((player.PlayerId, target.PlayerId)); + return Revolutionist.IsDraw != null && Revolutionist.IsDraw.GetValueOrDefault((player.PlayerId, target.PlayerId)); } public bool IsRevealedPlayer(PlayerControl target) { if (!player || !target) return false; - return Investigator.IsRevealed.GetValueOrDefault((player.PlayerId, target.PlayerId)); + return Investigator.IsRevealed != null && Investigator.IsRevealed.GetValueOrDefault((player.PlayerId, target.PlayerId)); } public void RpcSetDousedPlayer(PlayerControl target, bool isDoused) diff --git a/Modules/GameOptionsSender/PlayerGameOptionsSender.cs b/Modules/GameOptionsSender/PlayerGameOptionsSender.cs index 16b2a184b..d3c0074b7 100644 --- a/Modules/GameOptionsSender/PlayerGameOptionsSender.cs +++ b/Modules/GameOptionsSender/PlayerGameOptionsSender.cs @@ -724,7 +724,7 @@ public sealed class PlayerGameOptionsSender(PlayerControl player) : GameOptionsS bool energeticIncreaseSpeed = false, energeticDecreaseCooldown = false; - if (state.SubRoles.Contains(CustomRoles.Energetic) || Empress.Encouraged.Contains(player.PlayerId)) + if (state.SubRoles.Contains(CustomRoles.Energetic) || (Empress.Encouraged != null && Empress.Encouraged.Contains(player.PlayerId))) { if (player.CanUseKillButton()) energeticDecreaseCooldown = true; diff --git a/Patches/CredentialsPatch.cs b/Patches/CredentialsPatch.cs index 5844dbbf2..10b3252f6 100644 --- a/Patches/CredentialsPatch.cs +++ b/Patches/CredentialsPatch.cs @@ -199,112 +199,6 @@ public static class UpdateFriendCodeUIPatch } } -[HarmonyPatch(typeof(FriendsListUI), nameof(FriendsListUI.Open))] -internal static class FriendsListUIOpenPatch -{ - public static bool Prefix(FriendsListUI __instance) - { - try - { - if (__instance.gameObject.activeSelf || __instance.currentSceneName == "") - __instance.Close(); - else - { - FriendsListBar[] componentsInChildren = __instance.GetComponentsInChildren(true); - - for (var index = 0; index < componentsInChildren.Length; ++index) - { - if (componentsInChildren[index]) - Object.Destroy(componentsInChildren[index].gameObject); - } - - Scene activeScene = SceneManager.GetActiveScene(); - __instance.currentSceneName = activeScene.name; - __instance.UpdateFriendCodeUI(); - - if ((HudManager.InstanceExists && HudManager.InstanceExists && HudManager.Instance.Chat && HudManager.Instance.Chat.IsOpenOrOpening) || ShipStatus.Instance) - return false; - - __instance.friendBars = new(); - __instance.lobbyBars = new(); - __instance.notifBars = new(); - __instance.platformFriendBars = new(); - __instance.viewingAllFriends = true; - __instance.gameObject.SetActive(true); - __instance.guestAccountWarnings.ForEach((Action)(t => t.gameObject.SetActive(false))); - __instance.ViewRequestsButton.color = __instance.NoRequestsColor; - __instance.ViewRequestsText.text = TranslationController.Instance.GetString(StringNames.NoNewRequests); - - __instance.StartCoroutine(FriendsListManager.Instance.RefreshFriendsList((Action)(() => - { - __instance.ClearNotifs(); - - if (EOSManager.Instance.IsFriendsListAllowed()) - { - __instance.AddFriendObjects.SetActive(true); - __instance.RefreshBlockedPlayers(); - __instance.RefreshFriends(); - __instance.RefreshNotifications(); - } - else - { - __instance.AddFriendObjects.SetActive(false); - __instance.guestAccountWarnings.ForEach((Action)(g => g.SetUp())); - } - - __instance.RefreshRecentlyPlayed(); - __instance.RefreshPlatformFriends(); - - foreach (FriendsListBar friendBar in __instance.friendBars) - { - foreach (PassiveButton passiveButton in friendBar.ControllerSelectable) - ControllerManager.Instance.AddSelectableUiElement(passiveButton); - } - - foreach (FriendsListBar platformFriendBar in __instance.platformFriendBars) - { - foreach (PassiveButton passiveButton in platformFriendBar.ControllerSelectable) - ControllerManager.Instance.AddSelectableUiElement(passiveButton); - } - - foreach (FriendsListBar notifBar in __instance.notifBars) - { - foreach (PassiveButton passiveButton in notifBar.ControllerSelectable) - ControllerManager.Instance.AddSelectableUiElement(passiveButton); - } - - foreach (FriendsListBar lobbyBar in __instance.lobbyBars) - { - foreach (PassiveButton passiveButton in lobbyBar.ControllerSelectable) - ControllerManager.Instance.AddSelectableUiElement(passiveButton); - } - - ControllerManager.Instance.PickTopSelectable(); - }))); - - if (__instance.currentSceneName == "OnlineGame") - { - __instance.RefreshLobbyPlayers(); - __instance.LobbyPlayersTab.SetActive(true); - __instance.LobbyPlayersInactiveTab.SetActive(false); - __instance.OpenTab(0); - } - else - { - __instance.LobbyPlayersInactiveTab.SetActive(true); - __instance.LobbyPlayersTab.SetActive(false); - __instance.OpenTab(2); - } - - ControllerManager.Instance.OpenOverlayMenu(__instance.name, __instance.BackButton, __instance.DefaultButtonSelected, __instance.ControllerSelectable); - } - } - catch (Exception e) { Utils.ThrowException(e); } - - return false; - } -} - [HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.Start))] [HarmonyPriority(Priority.First)] internal static class TitleLogoPatch diff --git a/Roles/Standard/Coven/Wyrd.cs b/Roles/Standard/Coven/Wyrd.cs index ea0ff141b..5e17e5a65 100644 --- a/Roles/Standard/Coven/Wyrd.cs +++ b/Roles/Standard/Coven/Wyrd.cs @@ -133,7 +133,7 @@ public class Wyrd : CovenBase public static bool CheckPlayerAction(PlayerControl pc, Action action) { - if (!ActionSuicideSettings[action] || Instances == null) return true; + if (ActionSuicideSettings == null || !ActionSuicideSettings[action] || Instances == null) return true; foreach (Wyrd instance in Instances) { diff --git a/Roles/Standard/Neutral/Killing/Chemist.cs b/Roles/Standard/Neutral/Killing/Chemist.cs index b895a8a5f..f666d6c38 100644 --- a/Roles/Standard/Neutral/Killing/Chemist.cs +++ b/Roles/Standard/Neutral/Killing/Chemist.cs @@ -193,18 +193,7 @@ internal class Chemist : RoleBase { On = false; Instances = []; - FactoryLocations = []; - - LateTask.New(() => - { - FactoryLocations = ShipStatus.Instance.AllRooms - .Select(x => x.RoomId) - .Where(x => x != SystemTypes.Outside && !x.ToString().Contains("Decontamination")) - .Distinct() - .Zip(Enum.GetValues()[1..]) - .ToDictionary(x => x.First, x => x.Second); - }, 20f, log: false); } public override void Add(byte playerId) @@ -226,6 +215,13 @@ internal class Chemist : RoleBase Grenades = []; ItemCounts = Enum.GetValues().ToDictionary(x => x, _ => 0); + + FactoryLocations = ShipStatus.Instance.AllRooms + .Select(x => x.RoomId) + .Where(x => x != SystemTypes.Outside && !x.ToString().Contains("Decontamination")) + .Distinct() + .Zip(Enum.GetValues()[1..]) + .ToDictionary(x => x.First, x => x.Second); } public override void Remove(byte playerId)