mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 01:46:15 +00:00
Look up role parent mods by type instead of scanning IL2CPP objects
This commit is contained in:
1 parent
c4a5c638f7
commit
f0650a9841
1 file changed
+5
-1
@@ -57,6 +57,7 @@ public static class CustomRoleManager
|
|||||||
|
|
||||||
internal static readonly Dictionary<ushort, RoleBehaviour> CustomRoles = [];
|
internal static readonly Dictionary<ushort, RoleBehaviour> CustomRoles = [];
|
||||||
internal static readonly Dictionary<Type, ushort> RoleIds = [];
|
internal static readonly Dictionary<Type, ushort> RoleIds = [];
|
||||||
|
internal static readonly Dictionary<Type, MiraPluginInfo> RoleParentMods = [];
|
||||||
|
|
||||||
private static CppCollections.List<BaseGameSetting>? _emptySettings;
|
private static CppCollections.List<BaseGameSetting>? _emptySettings;
|
||||||
private static Il2CppReferenceArray<OverlayKillAnimation>? _emptyKillAnimations;
|
private static Il2CppReferenceArray<OverlayKillAnimation>? _emptyKillAnimations;
|
||||||
@@ -105,6 +106,7 @@ public static class CustomRoleManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
pluginInfo.InternalRoles.Add((ushort)role.Role, role);
|
pluginInfo.InternalRoles.Add((ushort)role.Role, role);
|
||||||
|
RoleParentMods[roleType] = pluginInfo;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
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>
|
/// <returns>A <see cref="MiraPluginInfo"/> object representing the parent mod of the role.</returns>
|
||||||
public static MiraPluginInfo FindParentMod(ICustomRole role)
|
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>
|
/// <summary>
|
||||||
|
|||||||
Reference in new issue
Block a user