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 AmongUs.GameOptions;
|
||||||
using System;
|
using System;
|
||||||
|
using Il2CppInterop.Runtime.Attributes;
|
||||||
using MiraAPI.Patches.Freeplay;
|
using MiraAPI.Patches.Freeplay;
|
||||||
using MiraAPI.Utilities.Assets;
|
using MiraAPI.Utilities.Assets;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@@ -77,16 +78,19 @@ public record struct CustomRoleConfiguration
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the Sprite used for the Role Options menu screenshot.
|
/// Gets or sets the Sprite used for the Role Options menu screenshot.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[HideFromIl2Cpp]
|
||||||
public LoadableAsset<Sprite>? OptionsScreenshot { get; set; } = null;
|
public LoadableAsset<Sprite>? OptionsScreenshot { get; set; } = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the Sprite used for the Role Icon.
|
/// Gets or sets the Sprite used for the Role Icon.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[HideFromIl2Cpp]
|
||||||
public LoadableAsset<Sprite>? Icon { get; set; } = null;
|
public LoadableAsset<Sprite>? Icon { get; set; } = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the Intro sound for the Role.
|
/// Gets or sets the Intro sound for the Role.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[HideFromIl2Cpp]
|
||||||
public LoadableAsset<AudioClip>? IntroSound { get; set; } = null;
|
public LoadableAsset<AudioClip>? IntroSound { get; set; } = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -89,15 +89,22 @@ public static class CustomRoleManager
|
|||||||
|
|
||||||
foreach (var roleType in roles)
|
foreach (var roleType in roles)
|
||||||
{
|
{
|
||||||
ClassInjector.RegisterTypeInIl2Cpp(roleType);
|
try
|
||||||
|
|
||||||
var role = RegisterRole(roleType, pluginInfo);
|
|
||||||
if (role is null)
|
|
||||||
{
|
{
|
||||||
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();
|
pluginInfo.PluginConfig.Save();
|
||||||
|
|||||||
Reference in new issue
Block a user