From 1c44653a8d752c194f3256064f22a18786512e1d Mon Sep 17 00:00:00 2001
From: Az <56699741+AlchlcDvl@users.noreply.github.com>
Date: Wed, 4 Nov 2026 14:12:06 -0500
Subject: [PATCH 1/4] slight project cleanup
---
MiraAPI/GameModes/GameModeOption.cs | 2 +-
.../Attributes/ModdedOptionAttribute.cs | 6 ++--
.../OptionList/ModdedOptionListAttribute.cs | 2 +-
.../LocalSettings/OptionsMenuPatches.cs | 13 ++-----
.../Patches/Menu/MainMenuManagerPatches.cs | 5 ++-
.../Roles/RoleOptionsCollectionPatch.cs | 34 ++++++++-----------
MiraAPI/Voting/PlayerVoteData.cs | 2 +-
7 files changed, 27 insertions(+), 37 deletions(-)
diff --git a/MiraAPI/GameModes/GameModeOption.cs b/MiraAPI/GameModes/GameModeOption.cs
index 79fccb28..254c043c 100644
--- a/MiraAPI/GameModes/GameModeOption.cs
+++ b/MiraAPI/GameModes/GameModeOption.cs
@@ -18,7 +18,7 @@ namespace MiraAPI.GameModes;
///
[HarmonyPatch]
[SuppressMessage("Critical Code Smell", "S2223:Non-constant static fields should not be visible", Justification = "Internal behaviour that does not need property-level validation.")]
-[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:Fields should be private", Justification = "Read above.")] // why so many warnings???
+[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:Fields should be private", Justification = "Read above.")]
public static class GameModeOption
{
///
diff --git a/MiraAPI/GameOptions/Attributes/ModdedOptionAttribute.cs b/MiraAPI/GameOptions/Attributes/ModdedOptionAttribute.cs
index 2a77afa6..79d5a3c3 100644
--- a/MiraAPI/GameOptions/Attributes/ModdedOptionAttribute.cs
+++ b/MiraAPI/GameOptions/Attributes/ModdedOptionAttribute.cs
@@ -12,7 +12,7 @@ namespace MiraAPI.GameOptions.Attributes;
/// Optional parameter to specify a game mode Type.
[AttributeUsage(AttributeTargets.Property)]
[SuppressMessage("Critical Code Smell", "S2223:Non-constant static fields should not be visible", Justification = "Internal behaviour that does not need property-level validation.")]
-[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:Fields should be private", Justification = "Read above.")] // why so many warnings???
+[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:Fields should be private", Justification = "Read above.")]
public abstract class ModdedOptionAttribute(string title, Type? roleType = null, Type? modeType = null) : PropertyOptionAttribute
{
internal IModdedOption? HolderOption;
@@ -26,12 +26,12 @@ public abstract class ModdedOptionAttribute(string title, Type? roleType = null,
///
/// Gets the role type of the option.
///
- protected Type? RoleType { get; private set; } = roleType;
+ protected Type? RoleType => roleType;
///
/// Gets the game mode type of the option.
///
- protected Type? ModeType { get; private set; } = modeType;
+ protected Type? ModeType => modeType;
internal abstract IModdedOption? CreateOption(object? value, PropertyInfo property);
}
diff --git a/MiraAPI/GameOptions/Attributes/OptionList/ModdedOptionListAttribute.cs b/MiraAPI/GameOptions/Attributes/OptionList/ModdedOptionListAttribute.cs
index f4d6933e..6881fcb3 100644
--- a/MiraAPI/GameOptions/Attributes/OptionList/ModdedOptionListAttribute.cs
+++ b/MiraAPI/GameOptions/Attributes/OptionList/ModdedOptionListAttribute.cs
@@ -13,7 +13,7 @@ namespace MiraAPI.GameOptions.Attributes;
/// The title of the options.
[AttributeUsage(AttributeTargets.Property)]
[SuppressMessage("Critical Code Smell", "S2223:Non-constant static fields should not be visible", Justification = "Internal behaviour that does not need property-level validation.")]
-[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:Fields should be private", Justification = "Read above.")] // why so many warnings???
+[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:Fields should be private", Justification = "Read above.")]
public abstract class ModdedOptionListAttribute(string title) : PropertyOptionAttribute
{
internal IModdedOptionList? HolderOptionList;
diff --git a/MiraAPI/Patches/LocalSettings/OptionsMenuPatches.cs b/MiraAPI/Patches/LocalSettings/OptionsMenuPatches.cs
index 6b64159e..9e043cf6 100644
--- a/MiraAPI/Patches/LocalSettings/OptionsMenuPatches.cs
+++ b/MiraAPI/Patches/LocalSettings/OptionsMenuPatches.cs
@@ -12,21 +12,14 @@ using UnityEngine.UI;
namespace MiraAPI.Patches.LocalSettings;
[HarmonyPatch(typeof(OptionsMenuBehaviour))]
+[SuppressMessage("Critical Code Smell", "S2223:Non-constant static fields should not be visible", Justification = "Internal behaviour that does not need property-level validation.")]
+[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:Fields should be private", Justification = "Read above.")]
public static class OptionsMenuPatches
{
private static readonly Dictionary> TabButtons = [];
private static int _currentPage = 1;
- internal static OptionsMenuBehaviour? Instance { get; private set; }
-
- [SuppressMessage(
- "Critical Code Smell",
- "S2223:Non-constant static fields should not be visible",
- Justification = "Internal behaviour that does not need property-level validation.")]
- [SuppressMessage(
- "StyleCop.CSharp.MaintainabilityRules",
- "SA1401:Fields should be private",
- Justification = "Read above.")]
+ internal static OptionsMenuBehaviour? Instance;
internal static BoxCollider2D MaskCollider = null!;
private static SpriteRenderer? background;
diff --git a/MiraAPI/Patches/Menu/MainMenuManagerPatches.cs b/MiraAPI/Patches/Menu/MainMenuManagerPatches.cs
index aff0906a..379bdcb6 100644
--- a/MiraAPI/Patches/Menu/MainMenuManagerPatches.cs
+++ b/MiraAPI/Patches/Menu/MainMenuManagerPatches.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections;
+using System.Diagnostics.CodeAnalysis;
using HarmonyLib;
using MiraAPI.LocalSettings;
using Reactor.Utilities;
@@ -13,7 +14,9 @@ namespace MiraAPI.Patches.Menu;
[HarmonyPatch(typeof(MainMenuManager))]
public static class MainMenuManagerPatches
{
- internal static bool NeedsDeepDestroy { get; private set; }
+ [SuppressMessage("Critical Code Smell", "S2223:Non-constant static fields should not be visible", Justification = "Internal behaviour that does not need property-level validation.")]
+ [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:Fields should be private", Justification = "Read above.")]
+ internal static bool NeedsDeepDestroy;
///
/// A postfix on to load all the addressables registered.
diff --git a/MiraAPI/Patches/Roles/RoleOptionsCollectionPatch.cs b/MiraAPI/Patches/Roles/RoleOptionsCollectionPatch.cs
index 0e856eff..84265321 100644
--- a/MiraAPI/Patches/Roles/RoleOptionsCollectionPatch.cs
+++ b/MiraAPI/Patches/Roles/RoleOptionsCollectionPatch.cs
@@ -1,6 +1,6 @@
using System;
+using System.Collections.Generic;
using System.Linq;
-using System.Reflection;
using AmongUs.GameOptions;
using HarmonyLib;
using MiraAPI.Roles;
@@ -12,24 +12,14 @@ namespace MiraAPI.Patches.Roles;
///
public static class RoleOptionsCollectionPatch
{
- internal static Assembly BaseAssembly { get; private set; }
- internal static Type[] BaseTypes { get; private set; }
- internal static Type CollectionsType { get; private set; }
public static void PatchRoleMethods(Harmony harmony)
{
- var assembly = Array.Find(
- AppDomain.CurrentDomain.GetAssemblies(),
- ass => ass.GetName().Name == "Assembly-CSharp");
-
- if (assembly == null)
- return;
-
- var compatType = typeof(RoleOptionsCollectionPatch);
- BaseAssembly = assembly;
- BaseTypes = AccessTools.GetTypesFromAssembly(assembly);
- var collections = BaseTypes.Where(x => x.Name.Contains("RoleOptionsCollectionV")).ToArray();
- var pairings = new System.Collections.Generic.Dictionary();
+ var baseAssembly = typeof(RoleBehaviour).Assembly;
+ var baseTypes = AccessTools.GetTypesFromAssembly(baseAssembly);
+ var collections = baseTypes.Where(x => x.Name.Contains("RoleOptionsCollectionV")).ToArray();
+ var pairings = new Dictionary();
var newestId = 0;
+
foreach (var collection in collections)
{
var remainder = collection.Name.Replace("RoleOptionsCollectionV", string.Empty);
@@ -45,22 +35,26 @@ public static class RoleOptionsCollectionPatch
}
}
+ Type? collectionsType = null;
+
if (pairings.TryGetValue(newestId, out var typeToGet))
{
- CollectionsType = typeToGet;
+ collectionsType = typeToGet;
}
- var anyRolesEnabledMethod = AccessTools.Method(CollectionsType, "AnyRolesEnabled");
+ var compatType = typeof(RoleOptionsCollectionPatch);
+
+ var anyRolesEnabledMethod = AccessTools.Method(collectionsType, "AnyRolesEnabled");
harmony.Patch(
anyRolesEnabledMethod,
new HarmonyMethod(AccessTools.Method(compatType, nameof(AnyRolesEnabledPrefix))));
- var chancePerGameMethod = AccessTools.Method(CollectionsType, "GetChancePerGame");
+ var chancePerGameMethod = AccessTools.Method(collectionsType, "GetChancePerGame");
harmony.Patch(
chancePerGameMethod,
new HarmonyMethod(AccessTools.Method(compatType, nameof(GetChancePrefix))));
- var numPerGameMethod = AccessTools.Method(CollectionsType, "GetNumPerGame");
+ var numPerGameMethod = AccessTools.Method(collectionsType, "GetNumPerGame");
harmony.Patch(
numPerGameMethod,
new HarmonyMethod(AccessTools.Method(compatType, nameof(GetNumPrefix))));
diff --git a/MiraAPI/Voting/PlayerVoteData.cs b/MiraAPI/Voting/PlayerVoteData.cs
index 5fe32ee7..ad07aeb1 100644
--- a/MiraAPI/Voting/PlayerVoteData.cs
+++ b/MiraAPI/Voting/PlayerVoteData.cs
@@ -23,7 +23,7 @@ public class PlayerVoteData(nint cppPtr) : MonoBehaviour(cppPtr)
/// Gets the list of s the owner has.
///
[HideFromIl2Cpp]
- public List Votes { get; private set; } = [];
+ public List Votes { get; } = [];
///
/// Gets or sets the amount of votes the owner has left.
From 1bd96041eeb04555a57c2f232f4fb53963432587 Mon Sep 17 00:00:00 2001
From: Az <56699741+AlchlcDvl@users.noreply.github.com>
Date: Wed, 4 Nov 2026 15:00:54 -0500
Subject: [PATCH 2/4] complete two todos + minor improvements
---
.../Patches/GameModes/CreateOptionsPatch.cs | 19 -------
.../LocalSettings/OptionsMenuPatches.cs | 39 ++++++++------
.../Patches/Options/RoleSettingMenuPatches.cs | 51 ++++++++-----------
MiraAPI/PluginLoading/MiraPluginManager.cs | 4 +-
.../Components/RoleSettingsMenuUpdater.cs | 49 ++++++++++++++++++
5 files changed, 95 insertions(+), 67 deletions(-)
delete mode 100644 MiraAPI/Patches/GameModes/CreateOptionsPatch.cs
create mode 100644 MiraAPI/Utilities/Components/RoleSettingsMenuUpdater.cs
diff --git a/MiraAPI/Patches/GameModes/CreateOptionsPatch.cs b/MiraAPI/Patches/GameModes/CreateOptionsPatch.cs
deleted file mode 100644
index b33c1fd3..00000000
--- a/MiraAPI/Patches/GameModes/CreateOptionsPatch.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using HarmonyLib;
-using GameModesEnum = AmongUs.GameOptions.GameModes;
-
-namespace MiraAPI.Patches.GameModes;
-
-[HarmonyPatch(typeof(CreateOptionsPicker), nameof(CreateOptionsPicker.SetGameMode))]
-internal static class CreateOptionsPatch
-{
- public static bool Prefix(CreateOptionsPicker __instance, GameModesEnum mode)
- {
- if (mode <= GameModesEnum.SeekFools)
- {
- return true;
- }
-
- // TODO: finish this
- return false;
- }
-}
diff --git a/MiraAPI/Patches/LocalSettings/OptionsMenuPatches.cs b/MiraAPI/Patches/LocalSettings/OptionsMenuPatches.cs
index 9e043cf6..074afd4e 100644
--- a/MiraAPI/Patches/LocalSettings/OptionsMenuPatches.cs
+++ b/MiraAPI/Patches/LocalSettings/OptionsMenuPatches.cs
@@ -1,4 +1,5 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using HarmonyLib;
@@ -70,7 +71,7 @@ public static class OptionsMenuPatches
_currentPage = 1;
TabButtons.Clear();
- float yOffset = 0;
+ var yOffset = 0f;
var i = 0;
var tabIdx = 0;
var page = 1;
@@ -144,9 +145,9 @@ public static class OptionsMenuPatches
UpdatePages();
}));
button.OnMouseOver = new UnityEvent();
- button.OnMouseOver.AddListener((UnityAction)(() => rollover.DoMouseOver()));
+ button.OnMouseOver.AddListener((Action)rollover.DoMouseOver);
button.OnMouseOut = new UnityEvent();
- button.OnMouseOut.AddListener((UnityAction)(() => rollover.DoMouseOut()));
+ button.OnMouseOut.AddListener((Action)rollover.DoMouseOut);
}
private static void ChangePage(int increase)
@@ -207,14 +208,17 @@ public static class OptionsMenuPatches
private static void CustomOpen(LocalSettingsTab tab)
{
- if (tab.TabButton?.Button)
- tab.TabButton!.Button.color = tab.TabAppearance.TabButtonHoverColor;
+ if (tab.TabButton)
+ {
+ if (tab.TabButton!.Button)
+ tab.TabButton.Button.color = tab.TabAppearance.TabButtonHoverColor;
- if (tab.TabButton?.Rollover)
- tab.TabButton!.Rollover.OutColor = tab.TabAppearance.TabButtonHoverColor;
+ if (tab.TabButton.Rollover)
+ tab.TabButton.Rollover.OutColor = tab.TabAppearance.TabButtonHoverColor;
- if (tab.TabButton?.Content)
- tab.TabButton!.Content.SetActive(true);
+ if (tab.TabButton.Content)
+ tab.TabButton.Content.SetActive(true);
+ }
if (background != null)
background.color = tab.TabAppearance.TabColor;
@@ -224,14 +228,17 @@ public static class OptionsMenuPatches
private static void CustomClose(LocalSettingsTab tab)
{
- if (tab.TabButton?.Button)
- tab.TabButton!.Button.color = tab.TabAppearance.TabButtonColor;
+ if (tab.TabButton)
+ {
+ if (tab.TabButton!.Button)
+ tab.TabButton.Button.color = tab.TabAppearance.TabButtonColor;
- if (tab.TabButton?.Rollover)
- tab.TabButton!.Rollover.OutColor = tab.TabAppearance.TabButtonColor;
+ if (tab.TabButton.Rollover)
+ tab.TabButton.Rollover.OutColor = tab.TabAppearance.TabButtonColor;
- if (tab.TabButton?.Content)
- tab.TabButton!.Content.SetActive(false);
+ if (tab.TabButton.Content)
+ tab.TabButton.Content.SetActive(false);
+ }
if (background != null)
background.color = Color.white;
diff --git a/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs b/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs
index 3d2ed2ec..3106adba 100644
--- a/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs
+++ b/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Linq;
using AmongUs.GameOptions;
using BepInEx.Unity.IL2CPP.Utils.Collections;
@@ -12,6 +13,7 @@ using MiraAPI.Roles;
using MiraAPI.Translation;
using MiraAPI.Utilities;
using MiraAPI.Utilities.Assets;
+using MiraAPI.Utilities.Components;
using Reactor.Networking.Rpc;
using Reactor.Utilities.Extensions;
using TMPro;
@@ -23,15 +25,24 @@ using Object = UnityEngine.Object;
namespace MiraAPI.Patches.Options;
[HarmonyPatch(typeof(RolesSettingsMenu))]
+[SuppressMessage("Critical Code Smell", "S2223:Non-constant static fields should not be visible", Justification = "Is internal code. Property-level protections are not required.")]
+[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:Fields should be private", Justification = "Read above.")]
public static class RoleSettingMenuPatches
{
private static readonly Dictionary RoleGroupHidden = [];
- private static RoleBehaviour? currentRole;
- private static List? currentRoleOptions;
+ internal static RoleBehaviour? CurrentRole;
+ internal static List? CurrentRoleOptions;
private static float scrollerNum = 0.522f;
+ [HarmonyPostfix]
+ [HarmonyPatch(nameof(RolesSettingsMenu.Awake))]
+ public static void OnAwake(RolesSettingsMenu __instance)
+ {
+ __instance.gameObject.AddComponent();
+ }
+
[HarmonyPostfix]
[HarmonyPatch(nameof(RolesSettingsMenu.OnEnable))]
public static void OpenPatch()
@@ -41,8 +52,8 @@ public static class RoleSettingMenuPatches
private static IEnumerator CoQuotaTabPatch(RolesSettingsMenu roleMenu)
{
- currentRole = null;
- currentRoleOptions = null;
+ CurrentRole = null;
+ CurrentRoleOptions = null;
roleMenu.QuotaTabSelectables.Clear();
roleMenu.roleChances.Clear();
@@ -91,7 +102,7 @@ public static class RoleSettingMenuPatches
Object.Destroy(child.gameObject);
}
- yield return new WaitForEndOfFrame();
+ yield return null;
MenuState.Instance.QueuedRoleMenuRefresh[MenuState.Instance.CurrentModIdx] = false;
}
@@ -186,7 +197,7 @@ public static class RoleSettingMenuPatches
Object.Destroy(child.gameObject);
}
- yield return new WaitForEndOfFrame();
+ yield return null;
var roleGroups = MenuState.Instance.CurrentMod.InternalRoles.Values.OfType()
.ToLookup(x => x.RoleOptionsGroup);
@@ -431,32 +442,12 @@ public static class RoleSettingMenuPatches
scroller.SetYBoundsMax(-scrollerNum - 2);
}
- // TODO: turn this into a fixed update
+ // Completed: turn this into a fixed update
[HarmonyPrefix]
[HarmonyPatch(nameof(RolesSettingsMenu.Update))]
public static bool UpdatePatch(RolesSettingsMenu __instance)
{
- if (MenuState.Instance.CurrentModIdx == 0) return true;
- if (currentRole == null || currentRoleOptions == null) return false;
-
- var hasImage = currentRole.RoleScreenshot != null;
- var num = hasImage ? -0.872f : -1;
- foreach (var opt in currentRoleOptions)
- {
- if (opt.OptionBehaviour == null) continue;
-
- if (!opt.Visible.Invoke())
- {
- opt.OptionBehaviour.gameObject.SetActive(false);
- continue;
- }
-
- opt.OptionBehaviour.transform.localPosition = new Vector3(hasImage ? 2.17f : 1.1f, num, -2f);
- opt.OptionBehaviour.gameObject.SetActive(true);
- num += -0.45f;
- }
-
- __instance.scrollBar.SetYBoundsMax(-num - 3);
+ // See RoleSettingsMenuUpdater.FixedUpdate in Utilities/Components/RoleSettingsMenuUpdater.cs
return false;
}
@@ -508,7 +499,7 @@ public static class RoleSettingMenuPatches
optBehaviour.gameObject.Destroy();
}
- currentRole = role;
+ CurrentRole = role;
__instance.advancedSettingChildren.Clear();
// TODO: create sub groups under the role settings.
@@ -547,7 +538,7 @@ public static class RoleSettingMenuPatches
newOpt.Initialize();
}
- currentRoleOptions = filteredOptions;
+ CurrentRoleOptions = filteredOptions;
}
[HarmonyPrefix]
diff --git a/MiraAPI/PluginLoading/MiraPluginManager.cs b/MiraAPI/PluginLoading/MiraPluginManager.cs
index c2f1caed..840d8926 100644
--- a/MiraAPI/PluginLoading/MiraPluginManager.cs
+++ b/MiraAPI/PluginLoading/MiraPluginManager.cs
@@ -68,7 +68,7 @@ public sealed class MiraPluginManager
MiraApiPluginInfo = info;
registrationTimer.Stop();
- Info($"Registering Mira API as mod in {registrationTimer.ElapsedMilliseconds}ms.");
+ Info($"Registered Mira API as mod in {registrationTimer.ElapsedMilliseconds}ms.");
}
IL2CPPChainloader.Instance.PluginLoad += (pluginInfo, assembly, plugin) =>
@@ -81,7 +81,7 @@ public sealed class MiraPluginManager
var registrationTimer = Stopwatch.StartNew();
RegisterPlugin(assembly, miraPlugin, pluginInfo, plugin, false);
registrationTimer.Stop();
- Info($"Registering mod {pluginInfo.Metadata.Name} with Mira API in {registrationTimer.ElapsedMilliseconds}ms.");
+ Info($"Registered mod {pluginInfo.Metadata.Name} with Mira API in {registrationTimer.ElapsedMilliseconds}ms.");
};
IL2CPPChainloader.Instance.Finished += () =>
diff --git a/MiraAPI/Utilities/Components/RoleSettingsMenuUpdater.cs b/MiraAPI/Utilities/Components/RoleSettingsMenuUpdater.cs
new file mode 100644
index 00000000..219e4f28
--- /dev/null
+++ b/MiraAPI/Utilities/Components/RoleSettingsMenuUpdater.cs
@@ -0,0 +1,49 @@
+using System.Diagnostics.CodeAnalysis;
+using MiraAPI.Patches.Options;
+using Reactor.Utilities.Attributes;
+using UnityEngine;
+
+namespace MiraAPI.Utilities.Components;
+
+///
+/// Updates the visuals of the in a fixed update loop.
+///
+/// The C++ pointer to the object.
+[RegisterInIl2Cpp]
+[SuppressMessage("Style", "IDE0051:Remove unused private members", Justification = "Unity convention.")]
+public sealed class RoleSettingsMenuUpdater(nint cppPtr) : MonoBehaviour(cppPtr)
+{
+ private RolesSettingsMenu menu;
+
+ private void Awake()
+ {
+ menu = GetComponent();
+ }
+
+ private void FixedUpdate()
+ {
+ if (MenuState.Instance.CurrentModIdx == 0) return;
+ if (menu == null || RoleSettingMenuPatches.CurrentRole == null || RoleSettingMenuPatches.CurrentRoleOptions == null) return;
+
+ var hasImage = RoleSettingMenuPatches.CurrentRole.RoleScreenshot != null;
+ var num = hasImage ? -0.872f : -1;
+ foreach (var opt in RoleSettingMenuPatches.CurrentRoleOptions)
+ {
+ var behaviour = opt.OptionBehaviour;
+
+ if (behaviour == null) continue;
+
+ if (!opt.Visible())
+ {
+ behaviour.gameObject.SetActive(false);
+ continue;
+ }
+
+ behaviour.transform.localPosition = new Vector3(hasImage ? 2.17f : 1.1f, num, -2f);
+ behaviour.gameObject.SetActive(true);
+ num += -0.45f;
+ }
+
+ menu.scrollBar.SetYBoundsMax(-num - 3);
+ }
+}
From fbeb610cb504f7b44fcd43482ead2a86781c5d33 Mon Sep 17 00:00:00 2001
From: Az <56699741+AlchlcDvl@users.noreply.github.com>
Date: Wed, 4 Nov 2026 21:21:12 -0500
Subject: [PATCH 3/4] some more code cleanup + undoing a todo
it is a miracle the game mod option worked the way it did. i would like to have a word with the one who was using a dictionary like a list. prepare to meet your maker
---
MiraAPI/GameModes/AbstractGameMode.cs | 2 +
MiraAPI/GameModes/CustomGameModeManager.cs | 24 ++--
MiraAPI/GameModes/GameModeOption.cs | 108 +++++-------------
MiraAPI/Hud/CustomMultiSelectMenu.cs | 7 +-
.../LocalSettings/OptionsMenuPatches.cs | 8 +-
.../Patches/Options/GameOptionsMenuPatch.cs | 40 +++----
.../Patches/Options/RoleSettingMenuPatches.cs | 7 +-
MiraAPI/Patches/Voting/MeetingHudPatches.cs | 2 +-
MiraAPI/Utilities/Extensions.cs | 2 +-
MiraAPI/Utilities/Helpers.cs | 2 +-
10 files changed, 71 insertions(+), 131 deletions(-)
diff --git a/MiraAPI/GameModes/AbstractGameMode.cs b/MiraAPI/GameModes/AbstractGameMode.cs
index 83448394..8f90de2b 100644
--- a/MiraAPI/GameModes/AbstractGameMode.cs
+++ b/MiraAPI/GameModes/AbstractGameMode.cs
@@ -77,6 +77,8 @@ public abstract class AbstractGameMode : IOptionable
///
public virtual float DefaultImpostorKillCooldown => GameOptionsManager.Instance.CurrentGameOptions.GetFloat(FloatOptionNames.KillCooldown);
+ internal StringNames StringName { get; set; }
+
///
/// Called on GameManager.GetBodyType().
///
diff --git a/MiraAPI/GameModes/CustomGameModeManager.cs b/MiraAPI/GameModes/CustomGameModeManager.cs
index d5678012..acb0f51b 100644
--- a/MiraAPI/GameModes/CustomGameModeManager.cs
+++ b/MiraAPI/GameModes/CustomGameModeManager.cs
@@ -44,9 +44,10 @@ public static class CustomGameModeManager
if (mode.HideMode)
return true;
- IdToModeMap.Add(GetNextId(), mode);
- pluginInfo.GameModes.Add(lastId, mode);
- mode.ID = lastId;
+ var id = GetNextId();
+ mode.ID = id;
+ IdToModeMap.Add(id, mode);
+ pluginInfo.GameModes.Add(id, mode);
GameModeOption.AddOption(mode);
return true;
}
@@ -107,34 +108,31 @@ public static class CustomGameModeManager
internal static void RegisterDefaultMode()
{
- var defaultMode = new ClassicMode();
+ var defaultMode = new ClassicMode { ID = 0 };
IdToModeMap.Add(0, defaultMode);
+ GameModeOption.AddOption(defaultMode);
- // no need to add to game mode option as it already contains it
- // because we cannot have the option be created with no values
- defaultMode.ID = 0;
- var hnsMode = new HideAndSeekMode();
+ var hnsMode = new HideAndSeekMode() { ID = 1 };
if (hnsMode.HideMode)
return;
IdToModeMap.Add(1, hnsMode);
- hnsMode.ID = 1;
GameModeOption.AddOption(hnsMode);
lastId++;
}
internal static void GetAndSetGameMode()
{
- var id = (uint)GameModeOption.Value;
+ var index = GameModeOption.Value;
- if (IdToModeMap.TryGetValue(id, out var mode))
+ if ((uint)index < (uint)GameModeOption.Values.Count)
{
- ActiveMode = mode;
+ ActiveMode = GameModeOption.Values[index];
return;
}
ActiveMode = IdToModeMap[0];
- Warning($"Unable to find game mode of id {id}!");
+ Warning($"Unable to find game mode at index {index}!");
}
}
diff --git a/MiraAPI/GameModes/GameModeOption.cs b/MiraAPI/GameModes/GameModeOption.cs
index 254c043c..a9c3bcbb 100644
--- a/MiraAPI/GameModes/GameModeOption.cs
+++ b/MiraAPI/GameModes/GameModeOption.cs
@@ -1,6 +1,5 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
-using System.Linq;
using HarmonyLib;
using MiraAPI.GameOptions;
using MiraAPI.Networking;
@@ -27,113 +26,63 @@ public static class GameModeOption
///
public static int Value
{
- get =>
- OptionBehaviour != null
- ? OptionBehaviour.GetInt()
- : LastValue;
+ get => OptionBehaviour != null
+ ? OptionBehaviour.GetInt()
+ : LastValue;
private set
{
LastValue = value;
+
if (OptionBehaviour == null)
return;
+
OptionBehaviour.Value = value;
OptionBehaviour.UpdateValue();
- LastValue = value;
}
}
internal static readonly StringNames GamemodeName = MiraLocaleManager.GetOrCreateLocaleString("MiraApi.Gamemode");
internal static readonly StringNames CustomName = MiraLocaleManager.GetOrCreateLocaleString("Custom");
- internal static readonly Dictionary Values = new()
- {
- [0] = MiraLocaleManager.GetOrCreateLocaleString("MiraApi.Gamemode.Classic"),
- };
+ internal static readonly List Values = [];
internal static StringOption OptionBehaviour = null!;
internal static int LastValue;
internal static void AddOption(AbstractGameMode mode)
{
- if (!Values.ContainsKey(mode.ID))
- Values.Add(mode.ID, MiraLocaleManager.GetOrCreateLocaleString(mode.Name));
+ mode.StringName = MiraLocaleManager.GetOrCreateLocaleString(mode.Name);
+ Values.Add(mode);
}
- /*[HarmonyPatch(typeof(GameOptionsMenu), nameof(GameOptionsMenu.CreateSettings))]
- [HarmonyPostfix]
- private static void CreateSettingsPatch(GameOptionsMenu __instance)
- {
- if (MenuState.Instance.CurrentModIdx != 0 || GameManager.Instance.IsHideAndSeek() || CustomGameModeManager.ActiveMode == null)
- {
- return;
- }
-
- var num = 0.713f;
-
- foreach (var category in __instance.settingsContainer.GetComponentsInChildren())
- {
- if (category)
- category.gameObject.transform.localPosition -= new Vector3(0, 1.3f, 0);
- }
- CategoryHeaderMasked categoryHeaderMasked = Object.Instantiate(__instance.categoryHeaderOrigin, Vector3.zero, Quaternion.identity, __instance.settingsContainer);
- categoryHeaderMasked.SetHeader(CustomName, 20);
- categoryHeaderMasked.transform.localScale = Vector3.one * 0.63f;
- categoryHeaderMasked.transform.localPosition = new Vector3(-0.903f, num, -2f);
- OptionBehaviour = Object.Instantiate(
- __instance.stringOptionOrigin,
- Vector3.zero,
- Quaternion.identity,
- __instance.settingsContainer);
- num -= 0.63f;
- OptionBehaviour.transform.localPosition = new Vector3(0.952f, num, -2f);
- OptionBehaviour.SetClickMask(__instance.ButtonClickMask);
- StringGameSetting setting = ScriptableObject.CreateInstance();
- setting.Type = OptionTypes.MultipleChoice;
- setting.Title = GamemodeName;
- setting.Index = _lastValue;
- setting.Values = new Il2CppStructArray([Values[0]]);
- OptionBehaviour.SetUpFromData(setting, 20);
- Set(_lastValue);
- OptionBehaviour.TitleText.fontSize = 3;
- foreach (var optionBehaviour in __instance.Children.ToArray().Skip(1))
- {
- optionBehaviour.gameObject.transform.localPosition -= new Vector3(0, 1.3f, 0);
- }
- __instance.Children.Add(OptionBehaviour);
- for (var i = 1; i < Values.Count; i++)
- OptionBehaviour.Values = (Il2CppStructArray)OptionBehaviour.Values.Add(Values.ElementAt(i).Value);
- __instance.scrollBar.SetYBoundsMax(__instance.scrollBar.GetYBounds().max + 1);
- }*/
-
internal static void Set(int val)
{
Value = val;
var previousMode = CustomGameModeManager.ActiveMode;
CustomGameModeManager.GetAndSetGameMode();
- HudPatches.SetGameModeText(CustomGameModeManager.GetMode(Values.ElementAt(LastValue).Key).ColoredName);
+ HudPatches.SetGameModeText(Values[LastValue].ColoredName);
var gm = CustomGameModeManager.ActiveMode!;
- if (gm != previousMode)
- {
- ModdedOptionsManager.AddSettingsChangeMessage(
- HudManager.Instance.Notifier,
- GamemodeName,
- gm.ColoredName,
- new Color(0.7333f, 0.7333f, 0.7333f, 1),
- gm.TmpIcon);
- if (MenuState.Instance)
- {
- // should force reset roles for gamemodes properly
- foreach (var roleMenu in MenuState.Instance.QueuedRoleMenuRefresh)
- {
- MenuState.Instance.QueuedRoleMenuRefresh[roleMenu.Key] = true;
- }
- }
+ if (gm == previousMode)
+ return;
- GameOptionsMenuPatch.RefreshForGameMode();
- RoleGuidePatches.RefreshSettingsForGameMode();
+ ModdedOptionsManager.AddSettingsChangeMessage(
+ HudManager.Instance.Notifier,
+ GamemodeName,
+ gm.ColoredName,
+ new Color(0.7333f, 0.7333f, 0.7333f, 1),
+ gm.TmpIcon);
+
+ if (MenuState.Instance)
+ {
+ // should force reset roles for gamemodes properly
+ foreach (var roleMenu in MenuState.Instance.QueuedRoleMenuRefresh)
+ {
+ MenuState.Instance.QueuedRoleMenuRefresh[roleMenu.Key] = true;
+ }
}
- // TODO: could make Values a dict of AbstractGameMode too
+ GameOptionsMenuPatch.RefreshForGameMode();
+ RoleGuidePatches.RefreshSettingsForGameMode();
}
[HarmonyPatch(typeof(GameOptionsMenu), nameof(GameOptionsMenu.ValueChanged))]
@@ -150,8 +99,7 @@ public static class GameModeOption
}
[MethodRpc((uint)MiraRpc.SyncGamemodeOption)]
- [SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Intentionally unused because the main intent is for it to be used by dependent mods to add to a blacklist.")]
- internal static void RpcSyncGamemode(PlayerControl host, int data)
+ internal static void RpcSyncGamemode(PlayerControl _, int data)
{
Set(data);
}
diff --git a/MiraAPI/Hud/CustomMultiSelectMenu.cs b/MiraAPI/Hud/CustomMultiSelectMenu.cs
index 50e2ff58..5b405053 100644
--- a/MiraAPI/Hud/CustomMultiSelectMenu.cs
+++ b/MiraAPI/Hud/CustomMultiSelectMenu.cs
@@ -29,12 +29,7 @@ public abstract class CustomMultiSelectMenu : CustomPhoneMenu>? onSelection;
///
diff --git a/MiraAPI/Patches/LocalSettings/OptionsMenuPatches.cs b/MiraAPI/Patches/LocalSettings/OptionsMenuPatches.cs
index 074afd4e..39b84870 100644
--- a/MiraAPI/Patches/LocalSettings/OptionsMenuPatches.cs
+++ b/MiraAPI/Patches/LocalSettings/OptionsMenuPatches.cs
@@ -175,13 +175,13 @@ public static class OptionsMenuPatches
LocalSettingsManager.AvailableTabs.ForEach(CustomClose); // Close all mod tabs
// Tabs with index 10 and above are the mod settings tabs
- if (index >= 10)
+ if (index < 10)
{
- CustomOpen(LocalSettingsManager.AvailableTabs[index - 10]);
- return false;
+ return true;
}
- return true;
+ CustomOpen(LocalSettingsManager.AvailableTabs[index - 10]);
+ return false;
}
///
diff --git a/MiraAPI/Patches/Options/GameOptionsMenuPatch.cs b/MiraAPI/Patches/Options/GameOptionsMenuPatch.cs
index 9dacf030..0799bf2f 100644
--- a/MiraAPI/Patches/Options/GameOptionsMenuPatch.cs
+++ b/MiraAPI/Patches/Options/GameOptionsMenuPatch.cs
@@ -4,7 +4,6 @@ using System.Collections.Generic;
using System.Linq;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using HarmonyLib;
-using Il2CppInterop.Runtime.InteropTypes.Arrays;
using MiraAPI.GameModes;
using MiraAPI.GameOptions;
using MiraAPI.Modifiers;
@@ -16,7 +15,6 @@ using Reactor.Utilities.Extensions;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
-using UnityEngine.ProBuilder;
using UnityEngine.UI;
using Object = UnityEngine.Object;
@@ -218,7 +216,7 @@ internal static class GameOptionsMenuPatch
{
if (!option || !option.gameObject.activeInHierarchy ||
option == menu.MapPicker ||
- (GameModeOption.OptionBehaviour && option == GameModeOption.OptionBehaviour) ||
+ option == GameModeOption.OptionBehaviour ||
!option.Data)
{
continue;
@@ -250,7 +248,6 @@ internal static class GameOptionsMenuPatch
private static void CreateSettings(GameOptionsMenu instance, Transform container)
{
- var num = 0.713f;
VanillaHeaders.Clear();
VanillaOptions.Clear();
MainOptions.Clear();
@@ -258,35 +255,36 @@ internal static class GameOptionsMenuPatch
GameModeOptions.Clear();
GameModeGroups.Clear();
- var gmCategory = Object.Instantiate(instance.categoryHeaderOrigin, Vector3.zero, Quaternion.identity, container);
+ var num = 0.713f;
+
+ var gmCategory = Object.Instantiate(instance.categoryHeaderOrigin, container);
gmCategory.SetHeader(GameModeOption.CustomName, 20);
gmCategory.transform.localScale = Vector3.one * 0.63f;
gmCategory.transform.localPosition = new Vector3(-0.903f, num, -2f);
- GameModeOption.OptionBehaviour = Object.Instantiate(instance.stringOptionOrigin, container);
+
num -= 0.63f;
+
+ GameModeOption.OptionBehaviour = Object.Instantiate(instance.stringOptionOrigin, container);
GameModeOption.OptionBehaviour.transform.localPosition = new Vector3(0.952f, num, -2f);
GameModeOption.OptionBehaviour.SetClickMask(instance.ButtonClickMask);
+
var setting = ScriptableObject.CreateInstance();
setting.Type = OptionTypes.MultipleChoice;
setting.Title = GameModeOption.GamemodeName;
setting.Index = GameModeOption.LastValue;
- setting.Values = new Il2CppStructArray([GameModeOption.Values[0]]);
+ setting.Values = GameModeOption.Values.Select(x => x.StringName).ToArray();
+
GameModeOption.OptionBehaviour.SetUpFromData(setting, 20);
GameModeOption.Set(GameModeOption.LastValue);
GameModeOption.OptionBehaviour.TitleText.fontSize = 3;
+
instance.Children.Add(GameModeOption.OptionBehaviour);
+
foreach (var optionBehaviour in instance.Children)
{
MainOptions.Add(optionBehaviour);
}
- for (var i = 1; i < GameModeOption.Values.Count; i++)
- {
- GameModeOption.OptionBehaviour.Values =
- (Il2CppStructArray)GameModeOption.OptionBehaviour.Values.Add(
- GameModeOption.Values.ElementAt(i).Value);
- }
-
var modeInfoHolder = new GameObject("GamemodeInfo")
{
transform =
@@ -298,7 +296,7 @@ internal static class GameOptionsMenuPatch
layer = container.gameObject.layer,
}.transform;
- var gamemodeBg = Object.Instantiate(GameModeOption.OptionBehaviour.transform.GetChild(0).gameObject, Vector3.zero, Quaternion.identity, modeInfoHolder);
+ var gamemodeBg = Object.Instantiate(GameModeOption.OptionBehaviour.transform.GetChild(0).gameObject, modeInfoHolder);
gamemodeBg.transform.localPosition = Vector3.zero;
gamemodeBg.transform.localScale = new Vector3(1.35f, 0.85f, 1);
gamemodeBg.name = "Background";
@@ -317,7 +315,7 @@ internal static class GameOptionsMenuPatch
_modIcon.sprite = MiraAssets.BlankSprite.LoadAsset();
_modIcon.material = gamemodeBg.gameObject.GetComponent().material;
- var gamemodeTextObj = Object.Instantiate(GameModeOption.OptionBehaviour.transform.GetChild(1).gameObject, Vector3.zero, Quaternion.identity, modeInfoHolder);
+ var gamemodeTextObj = Object.Instantiate(GameModeOption.OptionBehaviour.transform.GetChild(1).gameObject, modeInfoHolder);
gamemodeTextObj.transform.localPosition = new Vector3(0.3f, 0, -0.01f);
gamemodeTextObj.transform.localScale = new Vector3(2.12f, 2.12f, 1);
_gamemodeDescription = gamemodeTextObj.GetComponentInChildren();
@@ -469,11 +467,7 @@ internal static class GameOptionsMenuPatch
private static void CreateGroup(GameOptionsMenu menu, AbstractOptionGroup group, Transform container, ref float num, ref List optionBehaviours, ref List categoryHeaders)
{
- var categoryHeaderMasked = Object.Instantiate(
- menu.categoryHeaderOrigin,
- Vector3.zero,
- Quaternion.identity,
- container);
+ var categoryHeaderMasked = Object.Instantiate(menu.categoryHeaderOrigin, container);
categoryHeaderMasked.transform.localPosition = new Vector3(-0.903f, num + 1, -2f);
categoryHeaderMasked.transform.localScale = Vector3.one * 0.63f;
categoryHeaders.Add(categoryHeaderMasked);
@@ -510,12 +504,14 @@ internal static class GameOptionsMenuPatch
foreach (var newOpt in options)
{
newOpt.SetClickMask(menu.ButtonClickMask);
- SpriteRenderer[] componentsInChildren = newOpt.GetComponentsInChildren(true);
+ var componentsInChildren = newOpt.GetComponentsInChildren(true);
+
foreach (var renderer in componentsInChildren)
{
if (group.GroupColor != MiraApiPlugin.DefaultHeaderColor)
{
renderer.color = group.GroupColor.FindAlternateColor();
+
if (renderer.transform.parent.TryGetComponent(out var btn))
{
btn.interactableColor = group.GroupColor.FindAlternateColor();
diff --git a/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs b/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs
index 3106adba..36c3735a 100644
--- a/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs
+++ b/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs
@@ -32,7 +32,7 @@ public static class RoleSettingMenuPatches
private static readonly Dictionary RoleGroupHidden = [];
internal static RoleBehaviour? CurrentRole;
- internal static List? CurrentRoleOptions;
+ internal static IModdedOption[]? CurrentRoleOptions;
private static float scrollerNum = 0.522f;
@@ -503,10 +503,11 @@ public static class RoleSettingMenuPatches
__instance.advancedSettingChildren.Clear();
// TODO: create sub groups under the role settings.
+ var type = role.GetType();
var filteredOptions = MenuState.Instance.CurrentMod.InternalOptionGroups
- .Where(x => x.GroupVisible() && x.OptionableType == role.GetType())
+ .Where(x => x.OptionableType == type && x.GroupVisible())
.SelectMany(x => x.Options)
- .ToList();
+ .ToArray();
foreach (var option in filteredOptions)
{
diff --git a/MiraAPI/Patches/Voting/MeetingHudPatches.cs b/MiraAPI/Patches/Voting/MeetingHudPatches.cs
index d0f02fbb..a41b7e41 100644
--- a/MiraAPI/Patches/Voting/MeetingHudPatches.cs
+++ b/MiraAPI/Patches/Voting/MeetingHudPatches.cs
@@ -269,7 +269,7 @@ internal static class MeetingHudPatches
[HarmonyPrefix]
[HarmonyPatch(nameof(MeetingHud.PopulateResults))]
- public static bool PopulateResultsPatch(ref Il2CppStructArray states)
+ public static bool PopulateResultsPatch(Il2CppStructArray states)
{
var votes = states.Select(x => new CustomVote(x.VoterId, x.VotedForId)).ToList();
diff --git a/MiraAPI/Utilities/Extensions.cs b/MiraAPI/Utilities/Extensions.cs
index 868bef17..0446e84f 100644
--- a/MiraAPI/Utilities/Extensions.cs
+++ b/MiraAPI/Utilities/Extensions.cs
@@ -682,7 +682,7 @@ public static class Extensions
/// if the is for a custom options, otherwise.
public static bool IsCustom(this OptionBehaviour optionBehaviour)
{
- return ModdedOptionsManager.ModdedOptions.Values.Any(opt => opt.OptionBehaviour && opt.OptionBehaviour == optionBehaviour) || optionBehaviour.Equals(GameModeOption.OptionBehaviour);
+ return ModdedOptionsManager.ModdedOptions.Values.Any(opt => opt.OptionBehaviour == optionBehaviour) || optionBehaviour.Equals(GameModeOption.OptionBehaviour);
}
///
diff --git a/MiraAPI/Utilities/Helpers.cs b/MiraAPI/Utilities/Helpers.cs
index fe3b5020..6caa973c 100644
--- a/MiraAPI/Utilities/Helpers.cs
+++ b/MiraAPI/Utilities/Helpers.cs
@@ -370,7 +370,7 @@ public static class Helpers
public static LobbyNotificationMessage CreateAndShowNotification(string text, Color color, Vector3 localPos, AudioClip? clip = null, Sprite? spr = null)
{
var popper = HudManager.Instance.Notifier;
- var newMessage = Object.Instantiate(popper.notificationMessageOrigin, Vector3.zero, Quaternion.identity, popper.transform);
+ var newMessage = Object.Instantiate(popper.notificationMessageOrigin, popper.transform);
newMessage.transform.localPosition = localPos;
newMessage.SetUp(text, spr ?? null, color, new Action(() => popper.OnMessageDestroy(newMessage)));
popper.lastMessageKey = -1;
From 5dd5f33ae4bec93613adca1bba4963d3eb22bb44 Mon Sep 17 00:00:00 2001
From: Az <56699741+AlchlcDvl@users.noreply.github.com>
Date: Thu, 5 Nov 2026 02:55:40 -0500
Subject: [PATCH 4/4] lol new warnings
---
MiraAPI/GameModes/HideAndSeekMode.cs | 4 ++--
MiraAPI/Hud/CustomPaginableMenu.cs | 15 +++++++-----
MiraAPI/Hud/MultiTargetButton.cs | 9 ++++---
.../SettingTypes/LocalEnumSetting.cs | 11 +++++----
MiraAPI/Patches/Roles/SelectRolesPatch.cs | 4 ++--
MiraAPI/Utilities/GuideOptionsPatches.cs | 24 ++++++++++++-------
6 files changed, 41 insertions(+), 26 deletions(-)
diff --git a/MiraAPI/GameModes/HideAndSeekMode.cs b/MiraAPI/GameModes/HideAndSeekMode.cs
index 71146fe6..6e0666ac 100644
--- a/MiraAPI/GameModes/HideAndSeekMode.cs
+++ b/MiraAPI/GameModes/HideAndSeekMode.cs
@@ -92,9 +92,9 @@ public class HideAndSeekMode : AbstractGameMode
runOriginal = false;
CppCollections.List list = new();
AmongUsClient.Instance.GetAllClients(list);
- List list2 = [.. list.ToArray()
+ var list2 = list.ToArray()
.Where(c => c.Character != null && c.Character.Data != null && !c.Character.Data.Disconnected &&
- !c.Character.Data.IsDead).OrderBy(c => c.Id).Select(c => c.Character.Data),];
+ !c.Character.Data.IsDead).OrderBy(c => c.Id).Select(c => c.Character.Data).ToList();
foreach (var networkedPlayerInfo in GameData.Instance.AllPlayers)
{
diff --git a/MiraAPI/Hud/CustomPaginableMenu.cs b/MiraAPI/Hud/CustomPaginableMenu.cs
index 0654c9d0..159f7166 100644
--- a/MiraAPI/Hud/CustomPaginableMenu.cs
+++ b/MiraAPI/Hud/CustomPaginableMenu.cs
@@ -108,12 +108,15 @@ public abstract class CustomPaginableMenu : CustomPhoneMenu e.SortKey.Contains(query, StringComparison.OrdinalIgnoreCase))
- .OrderByDescending(e => e.SortKey.Equals(query, StringComparison.OrdinalIgnoreCase))
- .ThenByDescending(e => e.SortKey.StartsWith(query, StringComparison.OrdinalIgnoreCase))
- .ThenByDescending(e => e.SortKey.Contains(query, StringComparison.OrdinalIgnoreCase))
- .ThenBy(e => e.SortKey, StringComparer.OrdinalIgnoreCase),];
+ return
+ [
+ .. MenuEntries
+ .Where(e => e.SortKey.Contains(query, StringComparison.OrdinalIgnoreCase))
+ .OrderByDescending(e => e.SortKey.Equals(query, StringComparison.OrdinalIgnoreCase))
+ .ThenByDescending(e => e.SortKey.StartsWith(query, StringComparison.OrdinalIgnoreCase))
+ .ThenByDescending(e => e.SortKey.Contains(query, StringComparison.OrdinalIgnoreCase))
+ .ThenBy(e => e.SortKey, StringComparer.OrdinalIgnoreCase),
+ ];
}
private static int GetTotalPages(int itemCount)
diff --git a/MiraAPI/Hud/MultiTargetButton.cs b/MiraAPI/Hud/MultiTargetButton.cs
index 83c28000..6f931e7e 100644
--- a/MiraAPI/Hud/MultiTargetButton.cs
+++ b/MiraAPI/Hud/MultiTargetButton.cs
@@ -55,9 +55,12 @@ public abstract class MultiTargetButton : CustomActionButton
}
}
- Targets = [.. newTargets
- .Where(IsTargetValid)
- .Take(MaxTargets),];
+ Targets =
+ [
+ .. newTargets
+ .Where(IsTargetValid)
+ .Take(MaxTargets),
+ ];
Targets.Do(t => SetOutline(t, true));
return base.CanUse() && Targets.Length > 0;
diff --git a/MiraAPI/LocalSettings/SettingTypes/LocalEnumSetting.cs b/MiraAPI/LocalSettings/SettingTypes/LocalEnumSetting.cs
index 91d2eeb1..5fcbb081 100644
--- a/MiraAPI/LocalSettings/SettingTypes/LocalEnumSetting.cs
+++ b/MiraAPI/LocalSettings/SettingTypes/LocalEnumSetting.cs
@@ -36,10 +36,13 @@ public class LocalEnumSetting(
///
/// Gets the values.
///
- public string[] Values { get; } = values ?? [.. Enum
- .GetValues(configEntry.SettingType)
- .Cast()
- .Select(x => x.ToDisplayString()),];
+ public string[] Values { get; } = values ??
+ [
+ .. Enum
+ .GetValues(configEntry.SettingType)
+ .Cast()
+ .Select(x => x.ToDisplayString()),
+ ];
private SpriteRenderer _highlight;
private TextMeshPro _btnText;
diff --git a/MiraAPI/Patches/Roles/SelectRolesPatch.cs b/MiraAPI/Patches/Roles/SelectRolesPatch.cs
index 204e1f9e..630402e3 100644
--- a/MiraAPI/Patches/Roles/SelectRolesPatch.cs
+++ b/MiraAPI/Patches/Roles/SelectRolesPatch.cs
@@ -45,9 +45,9 @@ public static class SelectRolesPatch
CppCollections.List list = new();
AmongUsClient.Instance.GetAllClients(list);
- List list2 = [.. list.ToArray()
+ var list2 = list.ToArray()
.Where(c => c.Character != null && c.Character.Data != null && !c.Character.Data.Disconnected &&
- !c.Character.Data.IsDead).OrderBy(c => c.Id).Select(c => c.Character.Data),];
+ !c.Character.Data.IsDead).OrderBy(c => c.Id).Select(c => c.Character.Data).ToList();
foreach (var networkedPlayerInfo in GameData.Instance.AllPlayers)
{
diff --git a/MiraAPI/Utilities/GuideOptionsPatches.cs b/MiraAPI/Utilities/GuideOptionsPatches.cs
index 4d4b046d..f44626a4 100644
--- a/MiraAPI/Utilities/GuideOptionsPatches.cs
+++ b/MiraAPI/Utilities/GuideOptionsPatches.cs
@@ -142,12 +142,15 @@ internal static class GuideOptionPages
}
}
- return [.. pages
- .OrderBy(page => page.MenuOrder)
- .ThenBy(page => page.GroupPriority)
- .ThenBy(page => page.Order)
- .ThenBy(page => page.Group.GroupName, StringComparer.OrdinalIgnoreCase)
- .ThenBy(page => page.ModAbbreviation, StringComparer.OrdinalIgnoreCase),];
+ return
+ [
+ .. pages
+ .OrderBy(page => page.MenuOrder)
+ .ThenBy(page => page.GroupPriority)
+ .ThenBy(page => page.Order)
+ .ThenBy(page => page.Group.GroupName, StringComparer.OrdinalIgnoreCase)
+ .ThenBy(page => page.ModAbbreviation, StringComparer.OrdinalIgnoreCase),
+ ];
}
private static int GetMenuOrder(MenuCategory menu)
@@ -184,12 +187,15 @@ internal static class GuideOptionPages
return [.. matchingModPages.SelectMany(page => page.Entries)];
}
- return [.. pageList
- .SelectMany(page => page.Entries
+ return
+ [
+ .. pageList
+ .SelectMany(page => page.Entries
.Select(entry => (Entry: entry, Rank: Rank(entry, query, cmp)))
.Where(result => result.Rank < int.MaxValue)
.OrderBy(result => result.Rank)
- .Select(result => result.Entry)),];
+ .Select(result => result.Entry)),
+ ];
}
private static string[] GetModSearchTerms(MiraPluginInfo plugin, AbstractOptionGroup group)