mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 01:46:15 +00:00
fix new warnings (thanks tony)
This commit is contained in:
4 files changed
+32
-25
No files matched your search
@@ -21,16 +21,14 @@ public static class CustomButtonManager
|
||||
/// <summary>
|
||||
/// Gets a list of all registered button-specific <see cref="MiraButtonClickEvent"/>s.
|
||||
/// </summary>
|
||||
public static ReadOnlyDictionary<Type, Type> EventTypes { get; internal set; } = new(
|
||||
new Dictionary<Type, Type>
|
||||
{ });
|
||||
public static ReadOnlyDictionary<Type, Type> EventTypes { get; internal set; } = new(new Dictionary<Type, Type>
|
||||
{ });
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of all registered button-specific <see cref="MiraButtonCancelledEvent"/>s.
|
||||
/// </summary>
|
||||
public static ReadOnlyDictionary<Type, Type> CancelledEventTypes { get; internal set; } = new(
|
||||
new Dictionary<Type, Type>
|
||||
{ });
|
||||
public static ReadOnlyDictionary<Type, Type> CancelledEventTypes { get; internal set; } = new(new Dictionary<Type, Type>
|
||||
{ });
|
||||
|
||||
internal static readonly List<CustomActionButton> CustomButtons = [];
|
||||
internal static readonly Dictionary<Type, Type> ButtonEventTypes = [];
|
||||
|
||||
@@ -141,18 +141,13 @@ public static class CustomRoleManager
|
||||
roleBehaviour.CanVent = customRole.Configuration.CanUseVent || customRole.Configuration.GetsVentData;
|
||||
roleBehaviour.DefaultGhostRole = customRole.Configuration.GhostRole;
|
||||
roleBehaviour.MaxCount = customRole.Configuration.MaxRoleCount;
|
||||
if (customRole.Configuration.OptionsScreenshot != null)
|
||||
{
|
||||
roleBehaviour.RoleScreenshot = customRole.Configuration.OptionsScreenshot.LoadAsset();
|
||||
}
|
||||
else
|
||||
{
|
||||
roleBehaviour.RoleScreenshot = Sprite.Create(
|
||||
roleBehaviour.RoleScreenshot = customRole.Configuration.OptionsScreenshot != null
|
||||
? customRole.Configuration.OptionsScreenshot.LoadAsset()
|
||||
: Sprite.Create(
|
||||
null,
|
||||
new Rect(0, 0, 370, 230),
|
||||
Vector2.one / 2,
|
||||
100);
|
||||
}
|
||||
|
||||
_emptySettings ??= new(0);
|
||||
_emptyKillAnimations ??= new(0);
|
||||
|
||||
@@ -27,11 +27,12 @@ public class LoadableBundleSubAsset(string name, LoadableBundleSubAssetHolder as
|
||||
|
||||
var loadedAsset = assetHolder.SubSprites.FirstOrDefault(x => x.name == name);
|
||||
|
||||
if (loadedAsset == null)
|
||||
if (!loadedAsset)
|
||||
{
|
||||
throw new InvalidOperationException($"INVALID ASSETS: {name}");
|
||||
}
|
||||
LoadedAsset = loadedAsset;
|
||||
|
||||
LoadedAsset = loadedAsset!;
|
||||
return LoadedAsset;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using HarmonyLib;
|
||||
using Il2CppInterop.Runtime;
|
||||
@@ -12,6 +13,14 @@ namespace MiraAPI.Utilities.Assets;
|
||||
/// </summary>
|
||||
public class LoadableBundleSubAssetHolder
|
||||
{
|
||||
private readonly string[] spriteNames;
|
||||
private readonly AssetBundle bundle;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sprites contained within the asset.
|
||||
/// </summary>
|
||||
public Sprite[] SubSprites { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LoadableBundleSubAssetHolder"/> class.
|
||||
/// </summary>
|
||||
@@ -19,8 +28,8 @@ public class LoadableBundleSubAssetHolder
|
||||
/// <param name="bundle">The <see cref="AssetBundle"/> that contains the assets.</param>
|
||||
public LoadableBundleSubAssetHolder(string[] names, AssetBundle bundle)
|
||||
{
|
||||
Bundle = bundle;
|
||||
SpriteNames = names;
|
||||
this.bundle = bundle;
|
||||
spriteNames = names;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -30,26 +39,30 @@ public class LoadableBundleSubAssetHolder
|
||||
/// <param name="bundle">The <see cref="AssetBundle"/> that contains the assets.</param>
|
||||
public LoadableBundleSubAssetHolder(string name, AssetBundle bundle)
|
||||
{
|
||||
Bundle = bundle;
|
||||
SpriteNames = [name];
|
||||
this.bundle = bundle;
|
||||
spriteNames = [name];
|
||||
}
|
||||
internal string[] SpriteNames = [];
|
||||
internal AssetBundle Bundle;
|
||||
public Sprite[] SubSprites = [];
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to load all of the sprite assets within the sprite sheet.
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidOperationException">Thrown if the asset is not actually a sprite sheet.</exception>
|
||||
[SuppressMessage("Style", "IDE0270:Use coalesce expression", Justification = "Null coalescing bypasses Unity lifetime checks.")]
|
||||
public void TryInit()
|
||||
{
|
||||
if (SubSprites.Length == 0)
|
||||
{
|
||||
var newSprites = Array.Empty<Sprite>();
|
||||
foreach (var name in SpriteNames)
|
||||
|
||||
foreach (var name in spriteNames)
|
||||
{
|
||||
var loadedAssets = Bundle.LoadAssetWithSubAssets(name, Il2CppType.From(typeof(Sprite))).ToArray();
|
||||
var loadedAssets = bundle.LoadAssetWithSubAssets(name, Il2CppType.From(typeof(Sprite))).ToArray();
|
||||
|
||||
if (loadedAssets == null)
|
||||
{
|
||||
throw new InvalidOperationException($"INVALID ASSETS: {name}");
|
||||
}
|
||||
|
||||
foreach (var obj in loadedAssets)
|
||||
{
|
||||
var img = obj.TryCast<Sprite>();
|
||||
|
||||
Reference in new issue
Block a user