From 0c0157fed2ce0fafdcfdfe050d52e7fffda40ea6 Mon Sep 17 00:00:00 2001 From: Atony <75191600+AtonyGit@users.noreply.github.com> Date: Mon, 4 May 2026 07:43:53 -0500 Subject: [PATCH] Add soft-support for Corsac Cosmetics --- MiraAPI/Patches/Menu/HatsTabPatches.cs | 8 +++++++ MiraAPI/Patches/Menu/NameplatesTabPatches.cs | 9 +++++++ MiraAPI/Patches/Menu/SkinsTabPatches.cs | 9 +++++++ MiraAPI/Patches/Menu/VisorsTabPatches.cs | 9 +++++++ .../Utilities/Assets/AddressablesLoader.cs | 24 +++++++++++++++++++ 5 files changed, 59 insertions(+) diff --git a/MiraAPI/Patches/Menu/HatsTabPatches.cs b/MiraAPI/Patches/Menu/HatsTabPatches.cs index 8cd2bfd7..5f07cfdf 100644 --- a/MiraAPI/Patches/Menu/HatsTabPatches.cs +++ b/MiraAPI/Patches/Menu/HatsTabPatches.cs @@ -41,6 +41,10 @@ public static class HatsTabPatches [HarmonyPrefix] public static bool OnEnablePrefix(HatsTab __instance) { + if (!AddressablesLoader.AddressableHatsExist) + { + return true; + } __instance.currentHat = HatManager.Instance.GetHatById(DataManager.Player.Customization.Hat); var allHats = HatManager.Instance.GetUnlockedHats().ToImmutableList(); @@ -66,6 +70,10 @@ public static class HatsTabPatches [HarmonyPrefix] public static void UpdatePrefix(HatsTab __instance) { + if (!AddressablesLoader.AddressableHatsExist) + { + return; + } if (sortedHats.Count == 0) return; if (Input.GetKeyDown(KeyCode.LeftControl) || Input.GetKeyDown(KeyCode.RightControl) || Input.GetKeyDown(KeyCode.LeftArrow)) diff --git a/MiraAPI/Patches/Menu/NameplatesTabPatches.cs b/MiraAPI/Patches/Menu/NameplatesTabPatches.cs index 0b7acfe8..1526cce1 100644 --- a/MiraAPI/Patches/Menu/NameplatesTabPatches.cs +++ b/MiraAPI/Patches/Menu/NameplatesTabPatches.cs @@ -6,6 +6,7 @@ using Reactor.Utilities.Extensions; using System; using System.Collections.Generic; using System.Linq; +using MiraAPI.Utilities.Assets; using TMPro; using UnityEngine; using Object = UnityEngine.Object; @@ -44,6 +45,10 @@ public static class NameplatesTabPatches [HarmonyPrefix] public static bool OnEnablePrefix(NameplatesTab __instance) { + if (!AddressablesLoader.AddressableNameplatesExist) + { + return true; + } __instance.plateId = HatManager.Instance.GetNamePlateById(DataManager.Player.Customization.namePlate).ProdId; if (!SortedNameplates.ContainsKey("Vanilla")) AddRange(DestroyableSingleton.Instance.GetUnlockedNamePlates().Select(x => ("Vanilla", x))); @@ -60,6 +65,10 @@ public static class NameplatesTabPatches public static void UpdatePrefix(NameplatesTab __instance) { + if (!AddressablesLoader.AddressableNameplatesExist) + { + return; + } if (Input.GetKeyDown(KeyCode.LeftControl) || Input.GetKeyDown(KeyCode.RightControl) || Input.GetKeyDown(KeyCode.LeftArrow)) { PreviousPage(__instance); diff --git a/MiraAPI/Patches/Menu/SkinsTabPatches.cs b/MiraAPI/Patches/Menu/SkinsTabPatches.cs index b5ea7d79..8e99bf2c 100644 --- a/MiraAPI/Patches/Menu/SkinsTabPatches.cs +++ b/MiraAPI/Patches/Menu/SkinsTabPatches.cs @@ -6,6 +6,7 @@ using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; +using MiraAPI.Utilities.Assets; using TMPro; using UnityEngine; using Object = UnityEngine.Object; @@ -36,6 +37,10 @@ public static class SkinsTabPatches [HarmonyPrefix] public static bool OnEnablePrefix(SkinsTab __instance) { + if (!AddressablesLoader.AddressableSkinsExist) + { + return true; + } __instance.skinId = HatManager.Instance.GetSkinById(DataManager.Player.Customization.Skin).ProdId; var allSkins = HatManager.Instance.GetUnlockedSkins().ToImmutableList(); @@ -62,6 +67,10 @@ public static class SkinsTabPatches public static void UpdatePrefix(SkinsTab __instance) { + if (!AddressablesLoader.AddressableSkinsExist) + { + return; + } if (Input.GetKeyDown(KeyCode.LeftControl) || Input.GetKeyDown(KeyCode.RightControl) || Input.GetKeyDown(KeyCode.LeftArrow)) { PreviousPage(__instance); diff --git a/MiraAPI/Patches/Menu/VisorsTabPatches.cs b/MiraAPI/Patches/Menu/VisorsTabPatches.cs index e801c1a7..c543a94b 100644 --- a/MiraAPI/Patches/Menu/VisorsTabPatches.cs +++ b/MiraAPI/Patches/Menu/VisorsTabPatches.cs @@ -5,6 +5,7 @@ using Reactor.Utilities.Extensions; using System; using System.Collections.Generic; using System.Linq; +using MiraAPI.Utilities.Assets; using TMPro; using UnityEngine; using Object = UnityEngine.Object; @@ -44,6 +45,10 @@ public static class VisorsTabPatches [HarmonyPrefix] public static bool OnEnablePrefix(VisorsTab __instance) { + if (!AddressablesLoader.AddressableVisorsExist) + { + return true; + } __instance.visorId = HatManager.Instance.GetVisorById(DataManager.Player.Customization.Visor).ProdId; if (!SortedVisors.ContainsKey("Vanilla")) AddRange(DestroyableSingleton.Instance.GetUnlockedVisors().Select(x => ("Vanilla", x))); @@ -60,6 +65,10 @@ public static class VisorsTabPatches public static void UpdatePrefix(VisorsTab __instance) { + if (!AddressablesLoader.AddressableVisorsExist) + { + return; + } if (Input.GetKeyDown(KeyCode.LeftControl) || Input.GetKeyDown(KeyCode.RightControl) || Input.GetKeyDown(KeyCode.LeftArrow)) { PreviousPage(__instance); diff --git a/MiraAPI/Utilities/Assets/AddressablesLoader.cs b/MiraAPI/Utilities/Assets/AddressablesLoader.cs index 64918804..f1ecddd3 100644 --- a/MiraAPI/Utilities/Assets/AddressablesLoader.cs +++ b/MiraAPI/Utilities/Assets/AddressablesLoader.cs @@ -24,6 +24,26 @@ public static class AddressablesLoader private static readonly List<(string, string)> RegisteredNameplateKeys = []; private static readonly List RegisteredSkinKeys = []; + /// + /// Gets a value indicating whether hats have been loaded by the addressables system. + /// + public static bool AddressableHatsExist { get; private set; } + + /// + /// Gets a value indicating whether visors have been loaded by the addressables system. + /// + public static bool AddressableVisorsExist { get; private set; } + + /// + /// Gets a value indicating whether nameplates have been loaded by the addressables system. + /// + public static bool AddressableNameplatesExist { get; private set; } + + /// + /// Gets a value indicating whether skins have been loaded by the addressables system. + /// + public static bool AddressableSkinsExist { get; private set; } + /// /// Registers a specific addressables package to load asynchronously at the start of the game, when possible. /// @@ -52,6 +72,7 @@ public static class AddressablesLoader return; } + AddressableHatsExist = true; RegisteredHatKeys.Add(addressablesKey); } @@ -67,6 +88,7 @@ public static class AddressablesLoader return; } + AddressableSkinsExist = true; RegisteredSkinKeys.Add(addressablesKey); } @@ -83,6 +105,7 @@ public static class AddressablesLoader return; } + AddressableNameplatesExist = true; RegisteredNameplateKeys.Add((addressablesKey, groupTitle)); } @@ -99,6 +122,7 @@ public static class AddressablesLoader return; } + AddressableVisorsExist = true; RegisteredVisorKeys.Add((addressablesKey, groupTitle)); }