diff --git a/Modules/ExtendedPlayerControl.cs b/Modules/ExtendedPlayerControl.cs index 11187b10c..e9688fcd2 100644 --- a/Modules/ExtendedPlayerControl.cs +++ b/Modules/ExtendedPlayerControl.cs @@ -2242,25 +2242,30 @@ internal static class ExtendedPlayerControl { try { - if (Main.HasJustStarted) throw new("HasJustStarted"); + if (Main.HasJustStarted) return player.GetEstimatedRoleTypes(); return player.GetRoleMap().RoleType; } catch { - return player.GetCustomSubRoles() switch - { - { } x when x.Contains(CustomRoles.Bloodlust) => RoleTypes.Impostor, - { } x when x.Contains(CustomRoles.Nimble) && !player.HasDesyncRole() => RoleTypes.Engineer, - { } x when x.Contains(CustomRoles.Physicist) => RoleTypes.Scientist, - { } x when x.Contains(CustomRoles.Finder) => RoleTypes.Tracker, - { } x when x.Contains(CustomRoles.Noisy) => RoleTypes.Noisemaker, - { } x when x.Contains(CustomRoles.Examiner) => RoleTypes.Detective, - { } x when x.Contains(CustomRoles.Venom) => RoleTypes.Viper, - _ => player.GetCustomRole().GetRoleTypes() - }; + return player.GetEstimatedRoleTypes(); } } + public RoleTypes GetEstimatedRoleTypes() + { + return player.GetCustomSubRoles() switch + { + { } x when x.Contains(CustomRoles.Bloodlust) => RoleTypes.Impostor, + { } x when x.Contains(CustomRoles.Nimble) && !player.HasDesyncRole() => RoleTypes.Engineer, + { } x when x.Contains(CustomRoles.Physicist) => RoleTypes.Scientist, + { } x when x.Contains(CustomRoles.Finder) => RoleTypes.Tracker, + { } x when x.Contains(CustomRoles.Noisy) => RoleTypes.Noisemaker, + { } x when x.Contains(CustomRoles.Examiner) => RoleTypes.Detective, + { } x when x.Contains(CustomRoles.Venom) => RoleTypes.Viper, + _ => player.GetCustomRole().GetRoleTypes() + }; + } + public bool Is(CustomRoles role) { return role > CustomRoles.NotAssigned ? player.GetCustomSubRoles().Contains(role) : player.GetCustomRole() == role; diff --git a/Patches/HudPatch.cs b/Patches/HudPatch.cs index 0d10c5956..18870e458 100644 --- a/Patches/HudPatch.cs +++ b/Patches/HudPatch.cs @@ -347,7 +347,7 @@ internal static class HudManagerPatch if ((usesPetInsteadOfKill && player.Is(CustomRoles.Nimble) && player.GetRoleTypes() == RoleTypes.Engineer) || player.Is(CustomRoles.GM)) __instance.AbilityButton?.SetEnabled(); - __instance.SabotageButton?.ToggleVisible(player.GetRoleTypes() is RoleTypes.ImpostorGhost or RoleTypes.Impostor or RoleTypes.Phantom or RoleTypes.Shapeshifter or RoleTypes.Viper); + __instance.SabotageButton?.ToggleVisible(player.GetEstimatedRoleTypes() is RoleTypes.ImpostorGhost or RoleTypes.Impostor or RoleTypes.Phantom or RoleTypes.Shapeshifter or RoleTypes.Viper); float abilityUseLimit = player.GetAbilityUseLimit(); @@ -682,7 +682,7 @@ internal static class SetHudActivePatch __instance.KillButton?.ToggleVisible(player.CanUseKillButton()); __instance.ImpostorVentButton?.ToggleVisible(player.CanUseImpostorVentButton()); - __instance.SabotageButton?.ToggleVisible(player.GetRoleTypes() is RoleTypes.ImpostorGhost or RoleTypes.Impostor or RoleTypes.Phantom or RoleTypes.Shapeshifter or RoleTypes.Viper); + __instance.SabotageButton?.ToggleVisible(player.GetEstimatedRoleTypes() is RoleTypes.ImpostorGhost or RoleTypes.Impostor or RoleTypes.Phantom or RoleTypes.Shapeshifter or RoleTypes.Viper); if (Options.UseMeetingShapeshift.GetBool() && PlayerControl.LocalPlayer.UsesMeetingShapeshift() && GameStates.IsMeeting) { @@ -812,10 +812,8 @@ internal static class MapBehaviourShowPatch } else if (opts.Mode is MapOptions.Modes.Normal or MapOptions.Modes.Sabotage) { - if (player.Is(CustomRoleTypes.Impostor) || player.CanUseSabotage() || player.Is(CustomRoles.Glitch) || player.Is(CustomRoles.WeaponMaster) || player.Is(CustomRoles.Magician) || player.Is(CustomRoles.Parasite) || player.Is(CustomRoles.Renegade) || (player.Is(CustomRoles.Jackal) && Jackal.CanSabotage.GetBool()) || (player.Is(CustomRoles.Traitor) && Traitor.CanSabotage.GetBool())) - opts.Mode = MapOptions.Modes.Sabotage; - else - opts.Mode = MapOptions.Modes.Normal; + bool impBasis = player.GetEstimatedRoleTypes() is RoleTypes.ImpostorGhost or RoleTypes.Impostor or RoleTypes.Phantom or RoleTypes.Shapeshifter or RoleTypes.Viper; + opts.Mode = impBasis ? MapOptions.Modes.Sabotage : MapOptions.Modes.Normal; } if (Main.GodMode.Value) opts.ShowLivePlayerPosition = true; @@ -973,9 +971,10 @@ internal static class TaskPanelBehaviourPatch // Role info tab panel code from https://github.com/All-Of-Us-Mods/MiraAPI and https://github.com/AU-Avengers/TOU-Mira public static PassiveButton RolePanelButton; - public static TaskPanelBehaviour TaskPanel; - public static TextMeshPro TabText; - public static TextMeshPro TabPanelName; + private static TaskPanelBehaviour TaskPanel; + private static TextMeshPro TabText; + private static TextMeshPro TabPanelName; + internal static TaskPanelBehaviour CreateRoleTab(CustomRoles role) { TaskPanel = HudManager.Instance.TaskStuff.transform.FindChild("TaskPanel").gameObject.GetComponent();