Look up role parent mods by type instead of scanning IL2CPP objects

This commit is contained in:
ReAdmin committed 2026-10-08 18:16:13 -07:00
1 parent c4a5c638f7
commit f0650a9841
1 file changed
+5 -1
+5 -1
View File
@@ -57,6 +57,7 @@ public static class CustomRoleManager
internal static readonly Dictionary<ushort, RoleBehaviour> CustomRoles = [];
internal static readonly Dictionary<Type, ushort> RoleIds = [];
internal static readonly Dictionary<Type, MiraPluginInfo> RoleParentMods = [];
private static CppCollections.List<BaseGameSetting>? _emptySettings;
private static Il2CppReferenceArray<OverlayKillAnimation>? _emptyKillAnimations;
@@ -105,6 +106,7 @@ public static class CustomRoleManager
}
pluginInfo.InternalRoles.Add((ushort)role.Role, role);
RoleParentMods[roleType] = pluginInfo;
}
catch (Exception ex)
{
@@ -211,7 +213,9 @@ public static class CustomRoleManager
/// <returns>A <see cref="MiraPluginInfo"/> object representing the parent mod of the role.</returns>
public static MiraPluginInfo FindParentMod(ICustomRole role)
{
return MiraPluginManager.Instance.RegisteredPlugins.First(plugin => plugin.InternalRoles.ContainsValue(role as RoleBehaviour ?? throw new InvalidOperationException()));
return RoleParentMods.TryGetValue(role.GetType(), out var mod)
? mod
: MiraPluginManager.Instance.RegisteredPlugins.First(plugin => plugin.InternalRoles.ContainsValue(role as RoleBehaviour ?? throw new InvalidOperationException()));
}
/// <summary>