This commit is contained in:
D1GQ committed 2026-02-26 16:22:31 -06:00
1 parent d23fc1e13c
commit 7cac41d5bb
2 files changed
+15 -4

No files matched your search

+12 -1
View File
@@ -7,6 +7,9 @@ namespace BetterAmongUs.Helpers;
/// </summary>
internal static class RoleHelper
{
/// <summary>
/// Provides a lazily initialized lookup dictionary that maps each role type to its corresponding role behavior.
/// </summary>
private static readonly Lazy<Dictionary<RoleTypes, RoleBehaviour>> roleLookup =
new(() =>
{
@@ -34,9 +37,17 @@ internal static class RoleHelper
/// </summary>
/// <param name="role">The role type to check.</param>
/// <returns>True if the role is part of the impostor team, false otherwise.</returns>
internal static bool IsImpostorRole(RoleTypes role) =>
internal static bool IsImpostorRole(this RoleTypes role) =>
role.GetBehaviourPrefab().TeamType is RoleTeamTypes.Impostor;
/// <summary>
/// Determines whether the specified role is considered a ghost role.
/// </summary>
/// <param name="role">The role type to check.</param>
/// <returns>true if the role is classified as a ghost role; otherwise, false.</returns>
internal static bool IsGhostRole(this RoleTypes role) =>
RoleManager.IsGhostRole(role);
/// <summary>
/// Gets the display name of a role type.
/// </summary>
@@ -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);