From 85fb507a43634b8763fdbbe91ff74016224d47af Mon Sep 17 00:00:00 2001 From: Atony <75191600+AtonyGit@users.noreply.github.com> Date: Wed, 2 Sep 2026 02:34:01 -0500 Subject: [PATCH] Adjust gamemode role checks for info guide --- MiraAPI/Patches/RoleGuidePatches.cs | 48 +++++++++++++++++++++++------ MiraAPI/Roles/ICustomRole.cs | 9 +++++- 2 files changed, 46 insertions(+), 11 deletions(-) diff --git a/MiraAPI/Patches/RoleGuidePatches.cs b/MiraAPI/Patches/RoleGuidePatches.cs index c6edf06..a4878e4 100644 --- a/MiraAPI/Patches/RoleGuidePatches.cs +++ b/MiraAPI/Patches/RoleGuidePatches.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Globalization; using System.Linq; using AmongUs.GameOptions; @@ -7,6 +8,7 @@ using Innersloth.Assets; using MiraAPI.Roles; using MiraAPI.Utilities; using UnityEngine; +using Object = UnityEngine.Object; namespace MiraAPI.Patches; @@ -124,21 +126,41 @@ public static class RoleGuidePatches } private static Dictionary _rolePanels = []; + public static void DisplayNormalRoleSettings(MatchInfoGuide instance, bool reset) { if (reset) { _rolePanels.Clear(); - instance.CreateSettingsEntry(StringNames.GameNumImpostors, GameManager.Instance.AllGameSettingData[StringNames.GameNumImpostors].GetValueString(GameManager.Instance.LogicOptions.NumImpostors)); - instance.CreateSettingsEntry(StringNames.GameKillCooldown, GameManager.Instance.AllGameSettingData[StringNames.GameKillCooldown].GetValueString(GameManager.Instance.LogicOptions.GetKillCooldown())); - instance.CreateSettingsEntry(StringNames.GameEmergencyCooldown, GameManager.Instance.AllGameSettingData[StringNames.GameEmergencyCooldown].GetValueString((float)GameManager.Instance.LogicOptions.GetEmergencyCooldown())); - instance.CreateSettingsEntry(StringNames.GameVisualTasks, instance.GetBoolString(GameManager.Instance.LogicOptions.GetVisualTasks())); - instance.CreateSettingsEntry(StringNames.GameAnonymousVotes, instance.GetBoolString(GameManager.Instance.LogicOptions.GetAnonymousVotes())); - instance.CreateSettingsEntry(StringNames.GameConfirmImpostor, instance.GetBoolString(GameManager.Instance.LogicOptions.GetConfirmImpostor())); - instance.CreateSettingsEntry(StringNames.GameTaskBarMode, GameManager.Instance.LogicOptions.GetTaskBarMode().ToString()); + instance.CreateSettingsEntry( + StringNames.GameNumImpostors, + GameManager.Instance.AllGameSettingData[StringNames.GameNumImpostors] + .GetValueString(GameManager.Instance.LogicOptions.NumImpostors)); + instance.CreateSettingsEntry( + StringNames.GameKillCooldown, + GameManager.Instance.AllGameSettingData[StringNames.GameKillCooldown] + .GetValueString(GameManager.Instance.LogicOptions.GetKillCooldown())); + instance.CreateSettingsEntry( + StringNames.GameEmergencyCooldown, + GameManager.Instance.AllGameSettingData[StringNames.GameEmergencyCooldown] + .GetValueString((float)GameManager.Instance.LogicOptions.GetEmergencyCooldown())); + instance.CreateSettingsEntry( + StringNames.GameVisualTasks, + instance.GetBoolString(GameManager.Instance.LogicOptions.GetVisualTasks())); + instance.CreateSettingsEntry( + StringNames.GameAnonymousVotes, + instance.GetBoolString(GameManager.Instance.LogicOptions.GetAnonymousVotes())); + instance.CreateSettingsEntry( + StringNames.GameConfirmImpostor, + instance.GetBoolString(GameManager.Instance.LogicOptions.GetConfirmImpostor())); + instance.CreateSettingsEntry( + StringNames.GameTaskBarMode, + GameManager.Instance.LogicOptions.GetTaskBarMode().ToString()); foreach (RoleBehaviour roleBehaviour in RoleManager.Instance.AllRoles) { - if (roleBehaviour.Role != RoleTypes.Crewmate && roleBehaviour.Role != RoleTypes.Impostor && roleBehaviour.Role is not RoleTypes.CrewmateGhost && roleBehaviour.Role is not RoleTypes.ImpostorGhost) + if (roleBehaviour.Role != RoleTypes.Crewmate && roleBehaviour.Role != RoleTypes.Impostor && + roleBehaviour.Role is not RoleTypes.CrewmateGhost && + roleBehaviour.Role is not RoleTypes.ImpostorGhost) { var panel = Object.Instantiate( instance.MatchInfoRolePanelPrefab, @@ -155,11 +177,15 @@ public static class RoleGuidePatches var panel = pair.Value; var amount = GameOptionsManager.Instance.CurrentGameOptions.RoleOptions.GetNumPerGame(role.Role); var chance = GameOptionsManager.Instance.CurrentGameOptions.RoleOptions.GetChancePerGame(role.Role); - if (amount == 0 || chance == 0) + var forciblyShow = role is ICustomRole custom ? custom.ForceShowRoleOnWiki : null; + if (amount == 0 || chance == 0 || (Enum.IsDefined(role.Role) && role.IsRoleBlacklisted()) || + (role is ICustomRole custom2 && ((!custom2.CanSpawnOnCurrentMode() && forciblyShow == null) || + (forciblyShow.HasValue && !forciblyShow.Value)))) { panel.gameObject.SetActive(false); continue; } + panel.gameObject.SetActive(true); panel.SetPanel( role, @@ -167,10 +193,12 @@ public static class RoleGuidePatches chance); num++; } + if (num == 0) { instance.rolesEnabledMessage.SetActive(true); } + instance.MatchInfoRoleScroller.SetYBoundsMax(Mathf.Clamp(Mathf.Ceil((float)num / 2f) * 1.3f - 1.5f, 0f, 999f)); instance.MatchInfoRoleMaskArea.material.SetInt(PlayerMaterial.MaskLayer, 50); instance.matchInfoSettingsMaskArea.material.SetInt(PlayerMaterial.MaskLayer, 50); diff --git a/MiraAPI/Roles/ICustomRole.cs b/MiraAPI/Roles/ICustomRole.cs index 13020ff..50a9224 100644 --- a/MiraAPI/Roles/ICustomRole.cs +++ b/MiraAPI/Roles/ICustomRole.cs @@ -1,6 +1,7 @@ using System; using System.Text; using BepInEx.Configuration; +using MiraAPI.GameModes; using MiraAPI.GameOptions; using MiraAPI.Modifiers; using MiraAPI.PluginLoading; @@ -301,7 +302,13 @@ public interface ICustomRole : IOptionable /// Determines whether the role can spawn in general, accounting for gamemodes and everything else. /// /// if the role is able to spawn, otherwise . - public virtual bool CanSpawnOnCurrentMode() => !GameManager.Instance.IsHideAndSeek(); + public virtual bool CanSpawnOnCurrentMode() => Configuration.AssociatedGameMode.IsInstanceOfType(CustomGameModeManager.ActiveMode); + + /// + /// Determines whether the role is forcibly shown or disabled in the wiki screen. + /// + /// if the role is always displayed, otherwise if it is never displayable, or if it is dictated by amount and chance. + public virtual bool? ForceShowRoleOnWiki => null; /// /// Gets the function that determines whether the role should be toggled on or off in the game settings.