From 7cac41d5bb98ffc2e7506512cea5dea351f35472 Mon Sep 17 00:00:00 2001 From: D1GQ Date: Thu, 26 Feb 2026 16:22:31 -0600 Subject: [PATCH] Clean up --- src/Helpers/RoleHelper.cs | 13 ++++++++++++- src/Patches/Gameplay/Managers/RoleManagerPatch.cs | 6 +++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/Helpers/RoleHelper.cs b/src/Helpers/RoleHelper.cs index 6ea6d4f..133baa4 100644 --- a/src/Helpers/RoleHelper.cs +++ b/src/Helpers/RoleHelper.cs @@ -7,6 +7,9 @@ namespace BetterAmongUs.Helpers; /// internal static class RoleHelper { + /// + /// Provides a lazily initialized lookup dictionary that maps each role type to its corresponding role behavior. + /// private static readonly Lazy> roleLookup = new(() => { @@ -34,9 +37,17 @@ internal static class RoleHelper /// /// The role type to check. /// True if the role is part of the impostor team, false otherwise. - internal static bool IsImpostorRole(RoleTypes role) => + internal static bool IsImpostorRole(this RoleTypes role) => role.GetBehaviourPrefab().TeamType is RoleTeamTypes.Impostor; + /// + /// Determines whether the specified role is considered a ghost role. + /// + /// The role type to check. + /// true if the role is classified as a ghost role; otherwise, false. + internal static bool IsGhostRole(this RoleTypes role) => + RoleManager.IsGhostRole(role); + /// /// Gets the display name of a role type. /// diff --git a/src/Patches/Gameplay/Managers/RoleManagerPatch.cs b/src/Patches/Gameplay/Managers/RoleManagerPatch.cs index 7e93071..44e6d14 100644 --- a/src/Patches/Gameplay/Managers/RoleManagerPatch.cs +++ b/src/Patches/Gameplay/Managers/RoleManagerPatch.cs @@ -26,9 +26,9 @@ internal static class RoleManagerPatch private static void RoleManager_SetRole_Prefix(RoleManager __instance, PlayerControl targetPlayer, RoleTypes roleType) { // Store the original role when player dies (for ghost role purposes) - if (RoleManager.IsGhostRole(roleType)) + if (roleType.IsGhostRole()) { - if (!RoleManager.IsGhostRole(targetPlayer.Data.RoleType)) + if (!targetPlayer.Data.RoleType.IsGhostRole()) { targetPlayer.BetterData().RoleInfo.DeadDisplayRole = targetPlayer.Data.RoleType; } @@ -113,7 +113,7 @@ internal static class RoleManagerPatch // Get role counts from game options foreach (RoleTypes role in Roles) { - if (role.GetBehaviourPrefab().IsImpostor) + if (role.IsImpostorRole()) ImpostorRoles[role] = GameOptionsManager.Instance.CurrentGameOptions.RoleOptions.GetNumPerGame(role); else CrewmateRoles[role] = GameOptionsManager.Instance.CurrentGameOptions.RoleOptions.GetNumPerGame(role);