use aliases and add documentation for new method

This commit is contained in:
Az committed 2026-09-13 17:10:33 -04:00
1 parent 1fbd93d6f7
commit cd94666ed9
24 files changed
+47 -50

No files matched your search

+1 -2
View File
@@ -20,8 +20,7 @@ public static class PaletteManager
{
var colors = CustomColors.Select(x => x.MainColor).ToArray();
var shadowColors = CustomColors.Select(x => x.ShadowColor).ToArray();
var stringNames = CustomColors.Select(x =>
x.Name).ToArray();
var stringNames = CustomColors.Select(x => x.Name).ToArray();
Palette.PlayerColors = Palette.PlayerColors.ToArray().AddRangeToArray(colors);
Palette.ShadowColors = Palette.ShadowColors.ToArray().AddRangeToArray(shadowColors);
@@ -3,11 +3,8 @@
namespace MiraAPI.Events.Mira;
/// <summary>
/// Invoked when a <see cref="CustomActionButton"/> click is cancelled.
/// Invoked when a <see cref="CustomActionButton"/> click is cancelled. Do not use for vanilla <see cref="AbilityButton"/>s.
/// </summary>
/// <remarks>
/// Do not use for vanilla <see cref="AbilityButton"/>s.
/// </remarks>
/// <typeparam name="T">The <see cref="CustomActionButton"/> type.</typeparam>
/// <param name="button">The <see cref="CustomActionButton"/> whose click was cancelled.</param>
public sealed class MiraButtonCancelledEvent<T>(T button) : MiraEvent where T : CustomActionButton
@@ -19,11 +16,8 @@ public sealed class MiraButtonCancelledEvent<T>(T button) : MiraEvent where T :
}
/// <summary>
/// Invoked when a <see cref="CustomActionButton"/> click is cancelled.
/// Invoked when a <see cref="CustomActionButton"/> click is cancelled. Do not use for vanilla <see cref="AbilityButton"/>s.
/// </summary>
/// <remarks>
/// Do not use for vanilla <see cref="AbilityButton"/>s.
/// </remarks>
/// <param name="button">The <see cref="CustomActionButton"/> whose click was cancelled.</param>
public sealed class MiraButtonCancelledEvent(CustomActionButton button) : MiraEvent
{
+2 -8
View File
@@ -3,11 +3,8 @@
namespace MiraAPI.Events.Mira;
/// <summary>
/// Button click event for <see cref="CustomActionButton"/>s only.
/// Button click event for <see cref="CustomActionButton"/>s only. Do not use for vanilla <see cref="AbilityButton"/>s.
/// </summary>
/// <remarks>
/// Do not use for vanilla <see cref="AbilityButton"/>s.
/// </remarks>
/// <typeparam name="T">The <see cref="CustomActionButton"/> type.</typeparam>
/// <param name="button">The <see cref="CustomActionButton"/> that was clicked.</param>
/// <param name="genericClickEvent">The generic <see cref="MiraButtonClickEvent"/> invoked before button-specific events.</param>
@@ -25,11 +22,8 @@ public class MiraButtonClickEvent<T>(T button, MiraButtonClickEvent genericClick
}
/// <summary>
/// Button click event for <see cref="CustomActionButton"/>s only.
/// Button click event for <see cref="CustomActionButton"/>s only. Do not use for vanilla <see cref="AbilityButton"/>s.
/// </summary>
/// <remarks>
/// Do not use for vanilla <see cref="AbilityButton"/>s.
/// </remarks>
/// <param name="button">The <see cref="CustomActionButton"/> that was clicked.</param>
public class MiraButtonClickEvent(CustomActionButton button) : MiraCancelableEvent
{
+3
View File
@@ -20,6 +20,7 @@ public static class MiraEventManager
public static bool InvokeEvent<T>(this T eventInstance) where T : MiraEvent
{
EventWrappers.TryGetValue(typeof(T), out var handlers);
if (handlers == null || handlers.Count == 0)
{
return false;
@@ -49,6 +50,7 @@ public static class MiraEventManager
public static bool InvokeEvent(this MiraEvent eventInstance, Type type)
{
EventWrappers.TryGetValue(type, out var handlers);
if (handlers == null || handlers.Count == 0)
{
return false;
@@ -146,6 +148,7 @@ public static class MiraEventManager
{
EventWrappers.Remove(eventHandle.EventType);
}
return true;
}
}
@@ -1,7 +1,7 @@
namespace MiraAPI.Events.Vanilla.Meeting;
/// <summary>
/// The event that is invoked when a body is reported.
/// The event that is invoked when a body is reported.<br/>
/// This is invoked in <see cref="PlayerControl.CmdReportDeadBody(NetworkedPlayerInfo)"/>.
/// </summary>
/// <param name="reporter">The player who reported the body.</param>
+2 -1
View File
@@ -275,7 +275,7 @@ public abstract class AbstractGameMode : IOptionable
/// <param name="instance">The task panel to update.</param>
public virtual void UpdateTaskPanel(TaskPanelBehaviour instance)
{
instance.background.transform.localScale = (instance.taskText.textBounds.size.x > 0f)
instance.background.transform.localScale = instance.taskText.textBounds.size.x > 0f
? new Vector3(instance.taskText.textBounds.size.x + 0.2f, instance.taskText.textBounds.size.y + 0.2f, 1f)
: Vector3.zero;
var vector = instance.background.sprite.bounds.extents;
@@ -287,6 +287,7 @@ public abstract class AbstractGameMode : IOptionable
vector2.y = -vector2.y;
vector2.x += vector.x * 2f;
instance.tab.transform.localPosition = vector2;
if (GameManager.Instance == null)
{
return;
+1 -1
View File
@@ -91,7 +91,7 @@ public class HideAndSeekMode : AbstractGameMode
public override void AssignRoles(out bool runOriginal, LogicRoleSelectionNormal instance)
{
runOriginal = false;
Il2CppSystem.Collections.Generic.List<ClientData> list = new();
CppCollections.List<ClientData> list = new();
AmongUsClient.Instance.GetAllClients(list);
List<NetworkedPlayerInfo> list2 = [.. list.ToArray()
.Where(c => c.Character != null && c.Character.Data != null && !c.Character.Data.Disconnected &&
+2
View File
@@ -0,0 +1,2 @@
global using CppCollections = Il2CppSystem.Collections.Generic;
global using CppIEnumerator = Il2CppSystem.Collections.IEnumerator;
+4 -6
View File
@@ -51,12 +51,10 @@ public class CustomPlayerMenu(IntPtr il2CppPtr) : Minigame(il2CppPtr)
customMenu.xOffset = newMenu.XOffset;
customMenu.yOffset = newMenu.YOffset;
customMenu.backButton = newMenu.BackButton;
var back = customMenu.backButton.GetComponent<PassiveButton>();
back.OnClick.RemoveAllListeners();
back.OnClick.AddListener((UnityAction)(() =>
{
Instance.Close();
}));
back.OnClick.AddListener((UnityAction)Instance.Close);
customMenu.CloseSound = newMenu.CloseSound;
customMenu.logger = newMenu.logger;
@@ -99,7 +97,7 @@ public class CustomPlayerMenu(IntPtr il2CppPtr) : Minigame(il2CppPtr)
DebugAnalytics.Instance.Analytics.MinigameOpened(PlayerControl.LocalPlayer.Data, TaskType);
var list = PlayerControl.AllPlayerControls.ToArray().Where(playerMatch).ToList();
potentialVictims = [];
var list2 = new Il2CppSystem.Collections.Generic.List<UiElement>();
var list2 = new CppCollections.List<UiElement>();
for (var i = 0; i < list.Count; i++)
{
@@ -109,7 +107,7 @@ public class CustomPlayerMenu(IntPtr il2CppPtr) : Minigame(il2CppPtr)
var flag = PlayerControl.LocalPlayer.Data.Role.NameColor == player.Data.Role.NameColor;
var shapeshifterPanel = Instantiate(panelPrefab, transform);
shapeshifterPanel.transform.localPosition = new Vector3(xStart + num * xOffset, yStart + num2 * yOffset, -1f);
shapeshifterPanel.SetPlayer(i, player.Data, (Il2CppSystem.Action)(() => { onClick(player); }));
shapeshifterPanel.SetPlayer(i, player.Data, (Il2CppSystem.Action)(() => onClick(player)));
shapeshifterPanel.NameText.color = flag ? player.Data.Role.NameColor : Color.white;
potentialVictims.Add(shapeshifterPanel);
list2.Add(shapeshifterPanel.Button);
+3 -3
View File
@@ -122,7 +122,7 @@ public static class TaskAdderPatches
[HarmonyPrefix]
[HarmonyPatch(nameof(TaskAdderGame.PopulateRoot))]
private static bool PopulateRootPrefix(TaskAdderGame __instance, TaskAdderGame.FolderType folderType, TaskFolder rootFolder, Il2CppSystem.Collections.Generic.Dictionary<string, TaskFolder> folders, Il2CppReferenceArray<NormalPlayerTask> taskList)
private static bool PopulateRootPrefix(TaskAdderGame __instance, TaskAdderGame.FolderType folderType, TaskFolder rootFolder, CppCollections.Dictionary<string, TaskFolder> folders, Il2CppReferenceArray<NormalPlayerTask> taskList)
{
if (folderType != TaskAdderGame.FolderType.Tasks)
{
@@ -143,8 +143,8 @@ public static class TaskAdderPatches
impFolder.FolderName = ImpostorName;
rootFolder.SubFolders.Insert(0, crewFolder);
rootFolder.SubFolders.Insert(0, impFolder);
Il2CppSystem.Collections.Generic.List<RoleBehaviour> impRoles = new();
Il2CppSystem.Collections.Generic.List<RoleBehaviour> crewRoles = new();
CppCollections.List<RoleBehaviour> impRoles = new();
CppCollections.List<RoleBehaviour> crewRoles = new();
foreach (var role in RoleManager.Instance.AllRoles)
{
if (role.Role != RoleTypes.ImpostorGhost && role.Role != RoleTypes.CrewmateGhost && !role.IsCustomRole())
+1 -1
View File
@@ -7,7 +7,7 @@ namespace MiraAPI.Patches.GameModes;
[HarmonyPatch(typeof(IntroCutscene), nameof(IntroCutscene.CoBegin))]
internal static class BodyTypePatch
{
public static bool Prefix(IntroCutscene __instance, ref Il2CppSystem.Collections.IEnumerator __result)
public static bool Prefix(IntroCutscene __instance, ref CppIEnumerator __result)
{
if (CustomGameModeManager.ActiveMode?.ShowGameModeIntroCutscene != true) return true;
__result = CustomGameModeManager.ActiveMode.IntroCutscene(__instance).WrapToIl2Cpp();
@@ -7,7 +7,7 @@ namespace MiraAPI.Patches.GameModes;
[HarmonyPatch(typeof(IntroCutscene), nameof(IntroCutscene.CoBegin))]
internal static class IntroCutscenePatch
{
public static bool Prefix(IntroCutscene __instance, ref Il2CppSystem.Collections.IEnumerator __result)
public static bool Prefix(IntroCutscene __instance, ref CppIEnumerator __result)
{
if (CustomGameModeManager.ActiveMode?.ShowGameModeIntroCutscene != true) return true;
__result = CustomGameModeManager.ActiveMode.IntroCutscene(__instance).WrapToIl2Cpp();
+1 -1
View File
@@ -67,7 +67,7 @@ public static class IntroCutscenePatches
[HarmonyPrefix]
[HarmonyPatch(nameof(IntroCutscene.BeginImpostor))]
[HarmonyPatch(nameof(IntroCutscene.BeginCrewmate))]
public static bool BeginPrefix(IntroCutscene __instance, [HarmonyArgument(0)] ref Il2CppSystem.Collections.Generic.List<PlayerControl> yourTeam)
public static bool BeginPrefix(IntroCutscene __instance, [HarmonyArgument(0)] ref CppCollections.List<PlayerControl> yourTeam)
{
return PlayerControl.LocalPlayer.Data.Role is not ICustomRole customRole || customRole.SetupIntroTeam(__instance, ref yourTeam);
}
@@ -98,7 +98,7 @@ public static class RoleSettingMenuPatches
foreach (var r in roleOptionSettings)
{
roleMenu.roleChances.Add(r);
roleMenu.QuotaTabSelectables.AddRange(new Il2CppSystem.Collections.Generic.IEnumerable<UiElement>(r.ControllerSelectable.Pointer));
roleMenu.QuotaTabSelectables.AddRange(new CppCollections.IEnumerable<UiElement>(r.ControllerSelectable.Pointer));
}
Info($"Already created role options for {MenuState.Instance.CurrentModIdx}");
@@ -387,7 +387,7 @@ public static class RoleSettingMenuPatches
if (controllerSelected)
{
__instance.ControllerSelectable.AddRange(
new Il2CppSystem.Collections.Generic.IEnumerable<UiElement>(
new CppCollections.IEnumerable<UiElement>(
__instance.QuotaTabSelectables.Pointer));
}
+1 -1
View File
@@ -41,7 +41,7 @@ public static class SelectRolesPatch
{
return true;
}
Il2CppSystem.Collections.Generic.List<ClientData> list = new();
CppCollections.List<ClientData> list = new();
AmongUsClient.Instance.GetAllClients(list);
List<NetworkedPlayerInfo> list2 = [.. list.ToArray()
.Where(c => c.Character != null && c.Character.Data != null && !c.Character.Data.Disconnected &&
+2 -2
View File
@@ -16,7 +16,7 @@ using UnityEngine;
namespace MiraAPI.Patches.Voting;
[HarmonyPatch(typeof(MeetingHud))]
[SuppressMessage("ReSharper", "InconsistentNaming", Justification = "Harmony Convention.")]
[SuppressMessage("ReSharper", "InconsistentNaming", Justification = "Harmony convention.")]
internal static class MeetingHudPatches
{
[HarmonyPrefix]
@@ -55,7 +55,7 @@ internal static class MeetingHudPatches
var startPos = __instance.AnimateButtonsFromLeft ? 0.2f : 1.95f;
Il2CppSystem.Collections.Generic.List<UiElement> selectableElements = new();
CppCollections.List<UiElement> selectableElements = new();
foreach (var btn in __instance.Buttons.GetComponentsInChildren<PassiveButton>())
{
selectableElements.Add(btn);
+1 -1
View File
@@ -53,7 +53,7 @@ public static class CustomRoleManager
internal static readonly Dictionary<ushort, RoleBehaviour> CustomRoles = [];
internal static readonly Dictionary<Type, ushort> RoleIds = [];
private static Il2CppSystem.Collections.Generic.List<BaseGameSetting>? _emptySettings;
private static CppCollections.List<BaseGameSetting>? _emptySettings;
private static Il2CppReferenceArray<OverlayKillAnimation>? _emptyKillAnimations;
private static ushort _roleId = 100;
+2 -2
View File
@@ -249,11 +249,11 @@ public interface ICustomRole : IOptionable
/// <param name="instance">The intro cutscene instance.</param>
/// <param name="yourTeam">The reference to the list of player in the team.</param>
/// <returns><see langword="true"/> to use the original team intro code, <see langword="false"/> to skip.</returns>
bool SetupIntroTeam(IntroCutscene instance, ref Il2CppSystem.Collections.Generic.List<PlayerControl> yourTeam)
bool SetupIntroTeam(IntroCutscene instance, ref CppCollections.List<PlayerControl> yourTeam)
{
if (Team == ModdedRoleTeams.Custom)
{
var team = new Il2CppSystem.Collections.Generic.List<PlayerControl>();
var team = new CppCollections.List<PlayerControl>();
team.Add(PlayerControl.LocalPlayer);
+6
View File
@@ -352,6 +352,12 @@ public static class MiraLocaleManager
}
}
/// <summary>
/// Parses the provided xml file into translation keys and values and registers them to the locale manager.
/// </summary>
/// <param name="xmlContent">The xml file being parsed.</param>
/// <param name="language">The language that the xml file corresponds to.</param>
/// <param name="loadingInternal">Flag that indicates if the xml being parsed is internal or not.</param>
public static void ParseXmlFile(string xmlContent, MiraLanguage language, bool loadingInternal)
{
var dict = Locale[language];
@@ -216,7 +216,7 @@ public static class AddressablesLoader
{
var allLocations = Addressables.LoadResourceLocationsAsync(tag).WaitForCompletion();
var assets = Addressables.LoadAssetsAsync<T>(allLocations, null, false).WaitForCompletion();
var array = new Il2CppSystem.Collections.Generic.List<T>(assets.Pointer);
var array = new CppCollections.List<T>(assets.Pointer);
behaviours.AddRange(array.ToArray());
}
catch
@@ -237,7 +237,7 @@ public static class AddressablesLoader
{
var allLocations = Addressables.LoadResourceLocationsAsync(tag.Tag).WaitForCompletion();
var assets = Addressables.LoadAssetsAsync<T>(allLocations, null, false).WaitForCompletion();
var array = new Il2CppSystem.Collections.Generic.List<T>(assets.Pointer);
var array = new CppCollections.List<T>(assets.Pointer);
behaviours.AddRange(array.ToArray().Select(x => (tag.Category, x)));
}
catch
@@ -53,7 +53,7 @@ public class LoadableAddressableAssets<T>(string key) where T : UnityEngine.Obje
throw new InvalidOperationException($"INVALID ASSET/s: {key}");
}
var assetsList = new Il2CppSystem.Collections.Generic.List<T>(assetsIList.Pointer);
var assetsList = new CppCollections.List<T>(assetsIList.Pointer);
LoadedAssets = assetsList.ToArray().ToList();
_gcAction?.Invoke(this);
+1 -1
View File
@@ -78,7 +78,7 @@ public static class TmpSpriteUtils
material.SetFloat(ShaderUtilities.ShaderTag_CullMode, 0);
spriteAsset.material = material;
spriteAsset.spriteInfoList = new Il2CppSystem.Collections.Generic.List<TMP_Sprite>();
spriteAsset.spriteInfoList = new CppCollections.List<TMP_Sprite>();
AddSpriteToAsset(spriteAsset, rect, assetName, scale);
+3 -3
View File
@@ -185,15 +185,15 @@ public static class Extensions
}
/// <summary>
/// Used to convert a <see cref="List{T}"/> to <see cref="Il2CppSystem.Collections.Generic.List{T}"/>.
/// Used to convert a <see cref="List{T}"/> to <see cref="CppCollections.List{T}"/>.
/// </summary>
/// <param name="systemList">The <see cref="List{T}"/>.</param>
/// <typeparam name="T">The type in the list.</typeparam>
/// <returns>The converted list.</returns>
public static Il2CppSystem.Collections.Generic.List<T> ToIl2CppList<T>(this List<T> systemList)
public static CppCollections.List<T> ToIl2CppList<T>(this List<T> systemList)
{
// ReSharper disable once InconsistentNaming (Justification: Acronym.)
var il2cppList = new Il2CppSystem.Collections.Generic.List<T>();
var il2cppList = new CppCollections.List<T>();
foreach (var item in systemList)
{
+2 -2
View File
@@ -277,7 +277,7 @@ public static class Helpers
/// <returns>A <see cref="List{T}"/> of <see cref="DeadBody"/>s.</returns>
public static List<DeadBody> GetNearestDeadBodies(Vector2 source, float radius, ContactFilter2D filter)
{
var results = new Il2CppSystem.Collections.Generic.List<Collider2D>();
var results = new CppCollections.List<Collider2D>();
Physics2D.OverlapCircle(source, radius, filter, results);
return [.. results.ToArray()
.Where(collider2D => collider2D.CompareTag("DeadBody"))
@@ -296,7 +296,7 @@ public static class Helpers
public static List<T> GetNearestObjectsOfType<T>(Vector2 source, float radius, ContactFilter2D filter, string? colliderTag = null)
where T : Component
{
var results = new Il2CppSystem.Collections.Generic.List<Collider2D>();
var results = new CppCollections.List<Collider2D>();
Physics2D.OverlapCircle(source, radius, filter, results);
return [.. results.ToArray()
.Where(collider2D => colliderTag == null || collider2D.CompareTag(colliderTag))