use InstanceExists instead

This commit is contained in:
Pietrodjaowjao committed 2026-10-28 20:49:29 -03:00
1 parent 51397d78a7
commit 890fa065e7
2 files changed
+7 -2

No files matched your search

+1 -1
View File
@@ -38,7 +38,7 @@ public static class CustomRoleManager
/// <summary>
/// Gets the array of all roles from vanilla <see cref="RoleManager"/>.
/// </summary>
public static RoleBehaviour[] AllRoles => RoleManager.Instance.AllRoles.ToArray();
public static RoleBehaviour[] AllRoles => RoleManager.InstanceExists ? RoleManager.Instance.AllRoles.ToArray() : [];
/// <summary>
/// Gets the <see cref="IReadOnlyList{T}"/> of custom roles as <see cref="RoleBehaviour"/> objects.
+6 -1
View File
@@ -136,7 +136,12 @@ public static class CustomRoleUtils
public static LoadableAsset<AudioClip>? GetIntroSound(RoleTypes roleType)
{
var role = CustomRoleManager.AllRoles.FirstOrDefault(role => role.Role == roleType);
return role is ICustomRole customRole ? customRole.Configuration.IntroSound : new PreloadedAsset<AudioClip>(role!.IntroSound);
if (role == null)
{
return null;
}
return role is ICustomRole customRole ? customRole.Configuration.IntroSound : new PreloadedAsset<AudioClip>(role.IntroSound);
}
/// <summary>