Adjust gamemode role checks for info guide

This commit is contained in:
Atony committed 2026-09-02 02:34:01 -05:00
1 parent 3e2c6df829
commit 85fb507a43
2 files changed
+46 -11

No files matched your search

+38 -10
View File
@@ -1,4 +1,5 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using AmongUs.GameOptions; using AmongUs.GameOptions;
@@ -7,6 +8,7 @@ using Innersloth.Assets;
using MiraAPI.Roles; using MiraAPI.Roles;
using MiraAPI.Utilities; using MiraAPI.Utilities;
using UnityEngine; using UnityEngine;
using Object = UnityEngine.Object;
namespace MiraAPI.Patches; namespace MiraAPI.Patches;
@@ -124,21 +126,41 @@ public static class RoleGuidePatches
} }
private static Dictionary<RoleBehaviour, MatchInfoRolePanel> _rolePanels = []; private static Dictionary<RoleBehaviour, MatchInfoRolePanel> _rolePanels = [];
public static void DisplayNormalRoleSettings(MatchInfoGuide instance, bool reset) public static void DisplayNormalRoleSettings(MatchInfoGuide instance, bool reset)
{ {
if (reset) if (reset)
{ {
_rolePanels.Clear(); _rolePanels.Clear();
instance.CreateSettingsEntry(StringNames.GameNumImpostors, GameManager.Instance.AllGameSettingData[StringNames.GameNumImpostors].GetValueString(GameManager.Instance.LogicOptions.NumImpostors)); instance.CreateSettingsEntry(
instance.CreateSettingsEntry(StringNames.GameKillCooldown, GameManager.Instance.AllGameSettingData[StringNames.GameKillCooldown].GetValueString(GameManager.Instance.LogicOptions.GetKillCooldown())); StringNames.GameNumImpostors,
instance.CreateSettingsEntry(StringNames.GameEmergencyCooldown, GameManager.Instance.AllGameSettingData[StringNames.GameEmergencyCooldown].GetValueString((float)GameManager.Instance.LogicOptions.GetEmergencyCooldown())); GameManager.Instance.AllGameSettingData[StringNames.GameNumImpostors]
instance.CreateSettingsEntry(StringNames.GameVisualTasks, instance.GetBoolString(GameManager.Instance.LogicOptions.GetVisualTasks())); .GetValueString(GameManager.Instance.LogicOptions.NumImpostors));
instance.CreateSettingsEntry(StringNames.GameAnonymousVotes, instance.GetBoolString(GameManager.Instance.LogicOptions.GetAnonymousVotes())); instance.CreateSettingsEntry(
instance.CreateSettingsEntry(StringNames.GameConfirmImpostor, instance.GetBoolString(GameManager.Instance.LogicOptions.GetConfirmImpostor())); StringNames.GameKillCooldown,
instance.CreateSettingsEntry(StringNames.GameTaskBarMode, GameManager.Instance.LogicOptions.GetTaskBarMode().ToString()); 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) 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( var panel = Object.Instantiate(
instance.MatchInfoRolePanelPrefab, instance.MatchInfoRolePanelPrefab,
@@ -155,11 +177,15 @@ public static class RoleGuidePatches
var panel = pair.Value; var panel = pair.Value;
var amount = GameOptionsManager.Instance.CurrentGameOptions.RoleOptions.GetNumPerGame(role.Role); var amount = GameOptionsManager.Instance.CurrentGameOptions.RoleOptions.GetNumPerGame(role.Role);
var chance = GameOptionsManager.Instance.CurrentGameOptions.RoleOptions.GetChancePerGame(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); panel.gameObject.SetActive(false);
continue; continue;
} }
panel.gameObject.SetActive(true); panel.gameObject.SetActive(true);
panel.SetPanel( panel.SetPanel(
role, role,
@@ -167,10 +193,12 @@ public static class RoleGuidePatches
chance); chance);
num++; num++;
} }
if (num == 0) if (num == 0)
{ {
instance.rolesEnabledMessage.SetActive(true); instance.rolesEnabledMessage.SetActive(true);
} }
instance.MatchInfoRoleScroller.SetYBoundsMax(Mathf.Clamp(Mathf.Ceil((float)num / 2f) * 1.3f - 1.5f, 0f, 999f)); instance.MatchInfoRoleScroller.SetYBoundsMax(Mathf.Clamp(Mathf.Ceil((float)num / 2f) * 1.3f - 1.5f, 0f, 999f));
instance.MatchInfoRoleMaskArea.material.SetInt(PlayerMaterial.MaskLayer, 50); instance.MatchInfoRoleMaskArea.material.SetInt(PlayerMaterial.MaskLayer, 50);
instance.matchInfoSettingsMaskArea.material.SetInt(PlayerMaterial.MaskLayer, 50); instance.matchInfoSettingsMaskArea.material.SetInt(PlayerMaterial.MaskLayer, 50);
+8 -1
View File
@@ -1,6 +1,7 @@
using System; using System;
using System.Text; using System.Text;
using BepInEx.Configuration; using BepInEx.Configuration;
using MiraAPI.GameModes;
using MiraAPI.GameOptions; using MiraAPI.GameOptions;
using MiraAPI.Modifiers; using MiraAPI.Modifiers;
using MiraAPI.PluginLoading; 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. /// Determines whether the role can spawn in general, accounting for gamemodes and everything else.
/// </summary> /// </summary>
/// <returns><see langword="true"/> if the role is able to spawn, otherwise <see langword="false"/>.</returns> /// <returns><see langword="true"/> if the role is able to spawn, otherwise <see langword="false"/>.</returns>
public virtual bool CanSpawnOnCurrentMode() => !GameManager.Instance.IsHideAndSeek(); public virtual bool CanSpawnOnCurrentMode() => Configuration.AssociatedGameMode.IsInstanceOfType(CustomGameModeManager.ActiveMode);
/// <summary>
/// Determines whether the role is forcibly shown or disabled in the wiki screen.
/// </summary>
/// <returns><see langword="true"/> if the role is always displayed, otherwise <see langword="false"/> if it is never displayable, or <see langword="null"/> if it is dictated by amount and chance.</returns>
public virtual bool? ForceShowRoleOnWiki => null;
/// <summary> /// <summary>
/// Gets the function that determines whether the role should be toggled on or off in the game settings. /// Gets the function that determines whether the role should be toggled on or off in the game settings.