mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-19 15:51:48 +00:00
dont use il2cpp lists unless absolutely necessary!
This commit is contained in:
1 parent
f52c5de4cd
commit
79dc3280e8
10 files changed
+33
-42
No files matched your search
@@ -1,5 +1,4 @@
|
|||||||
using Il2CppSystem;
|
using MiraAPI.Example.Roles;
|
||||||
using MiraAPI.Example.Roles;
|
|
||||||
using MiraAPI.Modifiers.Types;
|
using MiraAPI.Modifiers.Types;
|
||||||
using MiraAPI.Translation;
|
using MiraAPI.Translation;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@@ -28,7 +27,7 @@ public class FreezeModifier : TimedModifier
|
|||||||
|
|
||||||
if (Player.AmOwner || PlayerControl.LocalPlayer.Data.Role is FreezerRole)
|
if (Player.AmOwner || PlayerControl.LocalPlayer.Data.Role is FreezerRole)
|
||||||
{
|
{
|
||||||
Player.cosmetics.SetOutline(true, new Nullable<Color>(Palette.LightBlue));
|
Player.cosmetics.SetOutline(true, new Il2CppSystem.Nullable<Color>(Palette.LightBlue));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Il2CppSystem.Collections.Generic;
|
|
||||||
using MiraAPI.Networking;
|
using MiraAPI.Networking;
|
||||||
using MiraAPI.Translation;
|
using MiraAPI.Translation;
|
||||||
using MiraAPI.Utilities;
|
using MiraAPI.Utilities;
|
||||||
@@ -43,7 +43,7 @@ public class ModdedPlayerOption : ModdedOption<int>
|
|||||||
data.Title = StringName;
|
data.Title = StringName;
|
||||||
data.Type = global::OptionTypes.Player;
|
data.Type = global::OptionTypes.Player;
|
||||||
|
|
||||||
Values = new List<NetworkedPlayerInfo>();
|
Values = new();
|
||||||
AllowNone = allowNone;
|
AllowNone = allowNone;
|
||||||
Value = DefaultValue;
|
Value = DefaultValue;
|
||||||
}
|
}
|
||||||
@@ -60,17 +60,16 @@ public class ModdedPlayerOption : ModdedOption<int>
|
|||||||
playerOption.name =
|
playerOption.name =
|
||||||
$"{ParentMod!.OptionsTitleText}.PlayerOption.{TranslationController.Instance.GetString(StringName)}";
|
$"{ParentMod!.OptionsTitleText}.PlayerOption.{TranslationController.Instance.GetString(StringName)}";
|
||||||
|
|
||||||
var filteredList = GetFilteredPlayers();
|
Values = GetFilteredPlayers();
|
||||||
Values = filteredList.ToIl2CppList();
|
|
||||||
|
|
||||||
playerOption.SetUpFromData(Data, 20);
|
playerOption.SetUpFromData(Data, 20);
|
||||||
playerOption.OnValueChanged = (Il2CppSystem.Action<OptionBehaviour>)ValueChanged;
|
playerOption.OnValueChanged = (Il2CppSystem.Action<OptionBehaviour>)ValueChanged;
|
||||||
|
|
||||||
playerOption.Title = StringName;
|
playerOption.Title = StringName;
|
||||||
playerOption.TitleText.text = Title.Translate();
|
playerOption.TitleText.text = Title.Translate();
|
||||||
playerOption.Values = Values;
|
playerOption.Values = Values.ToIl2CppList();
|
||||||
playerOption.Value = Value;
|
playerOption.Value = Value;
|
||||||
playerOption.playerIndex = filteredList.FindIndex(p => p.PlayerId == Value);
|
playerOption.playerIndex = Values.FindIndex(p => p.PlayerId == Value);
|
||||||
|
|
||||||
OptionBehaviour = playerOption;
|
OptionBehaviour = playerOption;
|
||||||
ModdedOptionsManager.CreatedPlayerOptions.TryAdd(playerOption, this);
|
ModdedOptionsManager.CreatedPlayerOptions.TryAdd(playerOption, this);
|
||||||
@@ -85,7 +84,7 @@ public class ModdedPlayerOption : ModdedOption<int>
|
|||||||
/// Returns a player ran through the filter.
|
/// Returns a player ran through the filter.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>A list of filtered players.</returns>
|
/// <returns>A list of filtered players.</returns>
|
||||||
public System.Collections.Generic.List<NetworkedPlayerInfo> GetFilteredPlayers()
|
public List<NetworkedPlayerInfo> GetFilteredPlayers()
|
||||||
{
|
{
|
||||||
return [.. GameData.Instance.AllPlayers.ToArray().Where(x => PlayerFilter?.Invoke(x) ?? true)];
|
return [.. GameData.Instance.AllPlayers.ToArray().Where(x => PlayerFilter?.Invoke(x) ?? true)];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using Il2CppSystem;
|
|
||||||
using MiraAPI.GameModes;
|
using MiraAPI.GameModes;
|
||||||
using MiraAPI.Translation;
|
using MiraAPI.Translation;
|
||||||
using Reactor.Utilities;
|
using Reactor.Utilities;
|
||||||
@@ -16,7 +15,7 @@ internal static class HudPatches
|
|||||||
[HarmonyPostfix, HarmonyPatch(nameof(HudManager.Update))]
|
[HarmonyPostfix, HarmonyPatch(nameof(HudManager.Update))]
|
||||||
public static void HudUpdatePatch(HudManager __instance)
|
public static void HudUpdatePatch(HudManager __instance)
|
||||||
{
|
{
|
||||||
if (GameManager.Instance != null && GameManager.Instance.GameHasStarted &&
|
if (GameManager.Instance && GameManager.Instance.GameHasStarted &&
|
||||||
CustomGameModeManager.ActiveMode != null)
|
CustomGameModeManager.ActiveMode != null)
|
||||||
{
|
{
|
||||||
CustomGameModeManager.ActiveMode.HudUpdate(__instance);
|
CustomGameModeManager.ActiveMode.HudUpdate(__instance);
|
||||||
@@ -32,7 +31,7 @@ internal static class HudPatches
|
|||||||
|
|
||||||
private static IEnumerator CoPostHudStart(HudManager instance)
|
private static IEnumerator CoPostHudStart(HudManager instance)
|
||||||
{
|
{
|
||||||
yield return new WaitUntil((Func<bool>)(() => GameManager.Instance != null));
|
yield return new WaitUntil((Il2CppSystem.Func<bool>)(() => GameManager.Instance != null));
|
||||||
if (GameManager.Instance.IsHideAndSeek())
|
if (GameManager.Instance.IsHideAndSeek())
|
||||||
yield return null;
|
yield return null;
|
||||||
var infoPane = instance.gameObject.transform.FindChild("LobbyInfoPane");
|
var infoPane = instance.gameObject.transform.FindChild("LobbyInfoPane");
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using BepInEx.Unity.IL2CPP.Utils.Collections;
|
using BepInEx.Unity.IL2CPP.Utils.Collections;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using Il2CppInterop.Runtime.InteropTypes.Arrays;
|
using Il2CppInterop.Runtime.InteropTypes.Arrays;
|
||||||
using Il2CppSystem.Collections.Generic;
|
|
||||||
using MiraAPI.GameModes;
|
using MiraAPI.GameModes;
|
||||||
using MiraAPI.GameOptions;
|
using MiraAPI.GameOptions;
|
||||||
using MiraAPI.Modifiers;
|
using MiraAPI.Modifiers;
|
||||||
@@ -28,9 +28,9 @@ internal static class GameOptionsMenuPatch
|
|||||||
private static readonly List<CategoryHeaderMasked> VanillaHeaders = new();
|
private static readonly List<CategoryHeaderMasked> VanillaHeaders = new();
|
||||||
private static readonly List<OptionBehaviour> VanillaOptions = new();
|
private static readonly List<OptionBehaviour> VanillaOptions = new();
|
||||||
private static readonly List<OptionBehaviour> MainOptions = new();
|
private static readonly List<OptionBehaviour> MainOptions = new();
|
||||||
private static readonly System.Collections.Generic.Dictionary<AbstractGameMode, System.Collections.Generic.List<AbstractOptionGroup>> GameModeGroups = [];
|
private static readonly Dictionary<AbstractGameMode, List<AbstractOptionGroup>> GameModeGroups = [];
|
||||||
private static readonly System.Collections.Generic.Dictionary<AbstractGameMode, System.Collections.Generic.List<OptionBehaviour>> GameModeOptions = [];
|
private static readonly Dictionary<AbstractGameMode, List<OptionBehaviour>> GameModeOptions = [];
|
||||||
private static readonly System.Collections.Generic.Dictionary<AbstractGameMode, System.Collections.Generic.List<CategoryHeaderMasked>> GameModeHeaders = [];
|
private static readonly Dictionary<AbstractGameMode, List<CategoryHeaderMasked>> GameModeHeaders = [];
|
||||||
private static TextMeshPro _gamemodeDescription = null!;
|
private static TextMeshPro _gamemodeDescription = null!;
|
||||||
private static SpriteRenderer _modIcon = null!;
|
private static SpriteRenderer _modIcon = null!;
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ internal static class GameOptionsMenuPatch
|
|||||||
[HarmonyPatch(nameof(GameOptionsMenu.Initialize))]
|
[HarmonyPatch(nameof(GameOptionsMenu.Initialize))]
|
||||||
public static bool InitPatch(GameOptionsMenu __instance)
|
public static bool InitPatch(GameOptionsMenu __instance)
|
||||||
{
|
{
|
||||||
__instance.Children ??= new List<OptionBehaviour>();
|
__instance.Children ??= new();
|
||||||
__instance.Children.Clear();
|
__instance.Children.Clear();
|
||||||
|
|
||||||
if (MenuState.Instance.CurrentModIdx == 0)
|
if (MenuState.Instance.CurrentModIdx == 0)
|
||||||
@@ -324,8 +324,8 @@ internal static class GameOptionsMenuPatch
|
|||||||
.ToList();
|
.ToList();
|
||||||
GameModeGroups.Add(mode, [.. filteredGroups]);
|
GameModeGroups.Add(mode, [.. filteredGroups]);
|
||||||
|
|
||||||
var optionBehaviours = new System.Collections.Generic.List<OptionBehaviour>();
|
var optionBehaviours = new List<OptionBehaviour>();
|
||||||
var categoryHeaders = new System.Collections.Generic.List<CategoryHeaderMasked>();
|
var categoryHeaders = new List<CategoryHeaderMasked>();
|
||||||
var newNum = mode.ShowNormalGameSettings ? num : num - additionalVanillaScrollNum;
|
var newNum = mode.ShowNormalGameSettings ? num : num - additionalVanillaScrollNum;
|
||||||
foreach (var group in filteredGroups)
|
foreach (var group in filteredGroups)
|
||||||
{
|
{
|
||||||
@@ -406,7 +406,7 @@ internal static class GameOptionsMenuPatch
|
|||||||
__instance.scrollBar.SetYBoundsMax(-num - 1.65f);
|
__instance.scrollBar.SetYBoundsMax(-num - 1.65f);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void CreateGroup(GameOptionsMenu menu, AbstractOptionGroup group, Transform container, ref float num, ref System.Collections.Generic.List<OptionBehaviour> optionBehaviours, ref System.Collections.Generic.List<CategoryHeaderMasked> categoryHeaders)
|
private static void CreateGroup(GameOptionsMenu menu, AbstractOptionGroup group, Transform container, ref float num, ref List<OptionBehaviour> optionBehaviours, ref List<CategoryHeaderMasked> categoryHeaders)
|
||||||
{
|
{
|
||||||
var categoryHeaderMasked = Object.Instantiate(
|
var categoryHeaderMasked = Object.Instantiate(
|
||||||
menu.categoryHeaderOrigin,
|
menu.categoryHeaderOrigin,
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using Il2CppSystem;
|
|
||||||
using MiraAPI.GameOptions;
|
using MiraAPI.GameOptions;
|
||||||
using MiraAPI.Roles;
|
using MiraAPI.Roles;
|
||||||
using MiraAPI.Translation;
|
using MiraAPI.Translation;
|
||||||
@@ -165,7 +164,7 @@ public static class OptionsPatches
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
__instance.TitleText.text = TranslationController.Instance.GetString(__instance.Title, Array.Empty<Object>()).Translate();
|
__instance.TitleText.text = TranslationController.Instance.GetString(__instance.Title).Translate();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -314,8 +313,8 @@ public static class OptionsPatches
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
__instance.TitleText.text = TranslationController.Instance.GetString(__instance.Title, Array.Empty<Object>()).Translate();
|
__instance.TitleText.text = TranslationController.Instance.GetString(__instance.Title).Translate();
|
||||||
__instance.ValueText.text = TranslationController.Instance.GetString(__instance.Values[__instance.Value], Array.Empty<Object>());
|
__instance.ValueText.text = TranslationController.Instance.GetString(__instance.Values[__instance.Value]);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ public static class PlayerOptionPatches
|
|||||||
{
|
{
|
||||||
filteredPlayers.Sort((a, b) => a.PlayerId.CompareTo(b.PlayerId));
|
filteredPlayers.Sort((a, b) => a.PlayerId.CompareTo(b.PlayerId));
|
||||||
|
|
||||||
|
moddedPlrOpt.Values = filteredPlayers;
|
||||||
__instance.Values = filteredPlayers.ToIl2CppList();
|
__instance.Values = filteredPlayers.ToIl2CppList();
|
||||||
moddedPlrOpt.Values = __instance.Values;
|
|
||||||
__instance.playerIndex = filteredPlayers.FindIndex(p => p.PlayerId == __instance.Value);
|
__instance.playerIndex = filteredPlayers.FindIndex(p => p.PlayerId == __instance.Value);
|
||||||
__instance.SetValueText();
|
__instance.SetValueText();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using Il2CppSystem;
|
|
||||||
using MiraAPI.Networking;
|
using MiraAPI.Networking;
|
||||||
using MiraAPI.Roles;
|
using MiraAPI.Roles;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@@ -31,13 +30,13 @@ public static class KillButtonPatches
|
|||||||
|
|
||||||
if (__instance.currentTarget && __instance.currentTarget != target)
|
if (__instance.currentTarget && __instance.currentTarget != target)
|
||||||
{
|
{
|
||||||
__instance.currentTarget.cosmetics.SetOutline(false, new Nullable<Color>(Color.clear));
|
__instance.currentTarget.cosmetics.SetOutline(false, new Il2CppSystem.Nullable<Color>(Color.clear));
|
||||||
}
|
}
|
||||||
|
|
||||||
__instance.currentTarget = target;
|
__instance.currentTarget = target;
|
||||||
if (__instance.currentTarget)
|
if (__instance.currentTarget)
|
||||||
{
|
{
|
||||||
__instance.currentTarget.cosmetics.SetOutline(true, new Nullable<Color>(customRole.Configuration.KillButtonOutlineColor));
|
__instance.currentTarget.cosmetics.SetOutline(true, new Il2CppSystem.Nullable<Color>(customRole.Configuration.KillButtonOutlineColor));
|
||||||
__instance.SetEnabled();
|
__instance.SetEnabled();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using AmongUs.GameOptions;
|
using AmongUs.GameOptions;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using Il2CppSystem.Collections.Generic;
|
|
||||||
using MiraAPI.Roles;
|
using MiraAPI.Roles;
|
||||||
|
|
||||||
namespace MiraAPI.Patches.Roles;
|
namespace MiraAPI.Patches.Roles;
|
||||||
@@ -14,7 +14,7 @@ public static class LogicRoleSelectionHnsPatch
|
|||||||
[HarmonyPatch(nameof(LogicRoleSelectionHnS.AssignRolesForTeam))]
|
[HarmonyPatch(nameof(LogicRoleSelectionHnS.AssignRolesForTeam))]
|
||||||
public static bool AssignRolesForTeam(
|
public static bool AssignRolesForTeam(
|
||||||
LogicRoleSelectionHnS __instance,
|
LogicRoleSelectionHnS __instance,
|
||||||
List<NetworkedPlayerInfo> players,
|
Il2CppSystem.Collections.Generic.List<NetworkedPlayerInfo> players,
|
||||||
IGameOptions opts,
|
IGameOptions opts,
|
||||||
RoleTeamTypes team,
|
RoleTeamTypes team,
|
||||||
int teamMax,
|
int teamMax,
|
||||||
@@ -58,7 +58,7 @@ public static class LogicRoleSelectionHnsPatch
|
|||||||
|
|
||||||
case RoleTeamTypes.Impostor:
|
case RoleTeamTypes.Impostor:
|
||||||
Info($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: Before Guaranteed Assignment");
|
Info($"MiraAPI.Patches.Roles.LogicRoleSelectionHnsPatch - AssignRolesForTeam: Before Guaranteed Assignment");
|
||||||
var newImpostors = new List<NetworkedPlayerInfo>();
|
var newImpostors = new Il2CppSystem.Collections.Generic.List<NetworkedPlayerInfo>();
|
||||||
|
|
||||||
// Specified Seeker
|
// Specified Seeker
|
||||||
if (__instance.hnsManager.LogicOptionsHnS.HasImpostorPlayerID() &&
|
if (__instance.hnsManager.LogicOptionsHnS.HasImpostorPlayerID() &&
|
||||||
@@ -113,7 +113,7 @@ public static class LogicRoleSelectionHnsPatch
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AssignRolesFromList(List<NetworkedPlayerInfo> players, int teamMax, List<RoleTypes> roleList, ref int rolesAssigned)
|
public static void AssignRolesFromList(Il2CppSystem.Collections.Generic.List<NetworkedPlayerInfo> players, int teamMax, List<RoleTypes> roleList, ref int rolesAssigned)
|
||||||
{
|
{
|
||||||
while (roleList.Count > 0 && players.Count > 0 && rolesAssigned < teamMax)
|
while (roleList.Count > 0 && players.Count > 0 && rolesAssigned < teamMax)
|
||||||
{
|
{
|
||||||
@@ -128,7 +128,7 @@ public static class LogicRoleSelectionHnsPatch
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void AddGuaranteedRoles(
|
private static void AddGuaranteedRoles(
|
||||||
System.Collections.Generic.IEnumerable<RoleBehaviour> guaranteedRoles,
|
IEnumerable<RoleBehaviour> guaranteedRoles,
|
||||||
IGameOptions opts,
|
IGameOptions opts,
|
||||||
List<RoleTypes> list)
|
List<RoleTypes> list)
|
||||||
{
|
{
|
||||||
@@ -146,7 +146,7 @@ public static class LogicRoleSelectionHnsPatch
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AddPotentialRoles(System.Collections.Generic.IEnumerable<RoleBehaviour> source, IGameOptions opts, List<RoleTypes> list)
|
private static void AddPotentialRoles(IEnumerable<RoleBehaviour> source, IGameOptions opts, List<RoleTypes> list)
|
||||||
{
|
{
|
||||||
var roleOptions = opts.RoleOptions;
|
var roleOptions = opts.RoleOptions;
|
||||||
var potentialRoles = source.Where(x => !x.IsDead).Select(role => new RoleManager.RoleAssignmentData(
|
var potentialRoles = source.Where(x => !x.IsDead).Select(role => new RoleManager.RoleAssignmentData(
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using Hazel;
|
using Hazel;
|
||||||
using Il2CppSystem.Text;
|
|
||||||
|
|
||||||
namespace MiraAPI.Patches.Stubs;
|
namespace MiraAPI.Patches.Stubs;
|
||||||
|
|
||||||
@@ -45,9 +44,9 @@ public static class RoleBehaviourStubs
|
|||||||
/// <param name="instance">The <see cref="RoleBehaviour"/> object.</param>
|
/// <param name="instance">The <see cref="RoleBehaviour"/> object.</param>
|
||||||
/// <param name="taskStringBuilder">The <see cref="StringBuilder"/> to append the task hint to.</param>
|
/// <param name="taskStringBuilder">The <see cref="StringBuilder"/> to append the task hint to.</param>
|
||||||
[HarmonyReversePatch]
|
[HarmonyReversePatch]
|
||||||
[HarmonyPatch(typeof(RoleBehaviour), nameof(RoleBehaviour.AppendTaskHint), typeof(StringBuilder))]
|
[HarmonyPatch(typeof(RoleBehaviour), nameof(RoleBehaviour.AppendTaskHint), typeof(Il2CppSystem.Text.StringBuilder))]
|
||||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||||
public static void AppendTaskHint(RoleBehaviour instance, StringBuilder taskStringBuilder)
|
public static void AppendTaskHint(RoleBehaviour instance, Il2CppSystem.Text.StringBuilder taskStringBuilder)
|
||||||
{
|
{
|
||||||
// nothing needed
|
// nothing needed
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -300,10 +300,7 @@ public static class VotingUtils
|
|||||||
// If modified, these will visually change.
|
// If modified, these will visually change.
|
||||||
votes = @event.Votes;
|
votes = @event.Votes;
|
||||||
|
|
||||||
MeetingHud.Instance.TitleText.text =
|
MeetingHud.Instance.TitleText.text = TranslationController.Instance.GetString(StringNames.MeetingVotingResults);
|
||||||
TranslationController.Instance.GetString(
|
|
||||||
StringNames.MeetingVotingResults,
|
|
||||||
Il2CppSystem.Array.Empty<Il2CppSystem.Object>());
|
|
||||||
|
|
||||||
var delays = new Dictionary<byte, int>();
|
var delays = new Dictionary<byte, int>();
|
||||||
var num = 0;
|
var num = 0;
|
||||||
|
|||||||
Reference in new issue
Block a user