add exception handling around role registration

This commit is contained in:
XtraCube committed 2025-12-31 22:38:01 -05:00
1 parent 067859b9fd
commit 5c2e95376d
2 files changed
+11

No files matched your search

+4
View File
@@ -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>
+7
View File
@@ -88,6 +88,8 @@ public static class CustomRoleManager
pluginInfo.PluginConfig.SaveOnConfigSet = false;
foreach (var roleType in roles)
{
try
{
ClassInjector.RegisterTypeInIl2Cpp(roleType);
@@ -99,6 +101,11 @@ public static class CustomRoleManager
pluginInfo.InternalRoles.Add((ushort)role.Role, role);
}
catch (Exception ex)
{
Error($"Failed to register role type {roleType.Name}: {ex}");
}
}
pluginInfo.PluginConfig.Save();
pluginInfo.PluginConfig.SaveOnConfigSet = oldConfigSetting;