mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-19 15:51:48 +00:00
add exception handling around role registration
This commit is contained in:
1 parent
067859b9fd
commit
5c2e95376d
2 files changed
+18
-7
No files matched your search
@@ -1,5 +1,6 @@
|
||||
using AmongUs.GameOptions;
|
||||
using System;
|
||||
using Il2CppInterop.Runtime.Attributes;
|
||||
using MiraAPI.Patches.Freeplay;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using UnityEngine;
|
||||
@@ -77,16 +78,19 @@ public record struct CustomRoleConfiguration
|
||||
/// <summary>
|
||||
/// Gets or sets the Sprite used for the Role Options menu screenshot.
|
||||
/// </summary>
|
||||
[HideFromIl2Cpp]
|
||||
public LoadableAsset<Sprite>? OptionsScreenshot { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Sprite used for the Role Icon.
|
||||
/// </summary>
|
||||
[HideFromIl2Cpp]
|
||||
public LoadableAsset<Sprite>? Icon { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Intro sound for the Role.
|
||||
/// </summary>
|
||||
[HideFromIl2Cpp]
|
||||
public LoadableAsset<AudioClip>? IntroSound { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -89,15 +89,22 @@ public static class CustomRoleManager
|
||||
|
||||
foreach (var roleType in roles)
|
||||
{
|
||||
ClassInjector.RegisterTypeInIl2Cpp(roleType);
|
||||
|
||||
var role = RegisterRole(roleType, pluginInfo);
|
||||
if (role is null)
|
||||
try
|
||||
{
|
||||
continue;
|
||||
}
|
||||
ClassInjector.RegisterTypeInIl2Cpp(roleType);
|
||||
|
||||
pluginInfo.InternalRoles.Add((ushort)role.Role, role);
|
||||
var role = RegisterRole(roleType, pluginInfo);
|
||||
if (role is null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
pluginInfo.InternalRoles.Add((ushort)role.Role, role);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Error($"Failed to register role type {roleType.Name}: {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
pluginInfo.PluginConfig.Save();
|
||||
|
||||
Reference in new issue
Block a user