diff --git a/MiraAPI/Cosmetics/AbstractCosmeticsGroup.cs b/MiraAPI/Cosmetics/AbstractCosmeticsGroup.cs index 1ea46213..a18be22b 100644 --- a/MiraAPI/Cosmetics/AbstractCosmeticsGroup.cs +++ b/MiraAPI/Cosmetics/AbstractCosmeticsGroup.cs @@ -8,9 +8,25 @@ public abstract class AbstractCosmeticsGroup public List Skins { get; } = []; public List Visors { get; } = []; public List Nameplates { get; } = []; + + /// + /// The name of the group. Visible in options menu. + /// public abstract string GroupName { get; } + + /// + /// A function that returns whether the group should be visible or not. + /// public virtual Func GroupVisible => () => true; + + /// + /// The sorting mode of individual hats within this group. + /// public virtual SortingMode SortingMode { get; } = SortingMode.AlphabeticName; + + /// + /// The priority of a group for sorting groups. + /// public virtual int SortingPriority { get; } = 0; } diff --git a/MiraAPI/Cosmetics/AbstractCosmeticsGroupComparer.cs b/MiraAPI/Cosmetics/AbstractCosmeticsGroupComparer.cs index d81d0e38..cec8967c 100644 --- a/MiraAPI/Cosmetics/AbstractCosmeticsGroupComparer.cs +++ b/MiraAPI/Cosmetics/AbstractCosmeticsGroupComparer.cs @@ -1,8 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace MiraAPI.Cosmetics; internal class AbstractCosmeticsGroupComparer : Comparer diff --git a/MiraAPI/Cosmetics/CustomCosmeticManager.cs b/MiraAPI/Cosmetics/CustomCosmeticManager.cs index dee8c77b..354a0767 100644 --- a/MiraAPI/Cosmetics/CustomCosmeticManager.cs +++ b/MiraAPI/Cosmetics/CustomCosmeticManager.cs @@ -6,8 +6,6 @@ using System; using System.Collections.Generic; using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; namespace MiraAPI.Cosmetics; public static class CustomCosmeticManager diff --git a/MiraAPI/Cosmetics/RegisterCustomCosmeticAttribute.cs b/MiraAPI/Cosmetics/RegisterCustomCosmeticAttribute.cs index 67b59c90..9629ec44 100644 --- a/MiraAPI/Cosmetics/RegisterCustomCosmeticAttribute.cs +++ b/MiraAPI/Cosmetics/RegisterCustomCosmeticAttribute.cs @@ -1,6 +1,4 @@ using System; -using System.Collections; -using System.Collections.Generic; namespace MiraAPI.Cosmetics; diff --git a/MiraAPI/Cosmetics/VanillaCosmeticsGroup.cs b/MiraAPI/Cosmetics/VanillaCosmeticsGroup.cs index f8ea66f9..5ee1034f 100644 --- a/MiraAPI/Cosmetics/VanillaCosmeticsGroup.cs +++ b/MiraAPI/Cosmetics/VanillaCosmeticsGroup.cs @@ -1,9 +1,4 @@ -using Reactor.Utilities; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; namespace MiraAPI.Cosmetics; public class VanillaCosmeticsGroup : AbstractCosmeticsGroup diff --git a/MiraAPI/Patches/Cosmetics/HatManagerPatch.cs b/MiraAPI/Patches/Cosmetics/HatManagerPatch.cs deleted file mode 100644 index 18e26e5a..00000000 --- a/MiraAPI/Patches/Cosmetics/HatManagerPatch.cs +++ /dev/null @@ -1,19 +0,0 @@ -using HarmonyLib; -using MiraAPI.Cosmetics; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace MiraAPI.Patches.Cosmetics; -[HarmonyPatch(typeof(HatManager), nameof(HatManager.GetHatById))] -public static class HatManagerPatch -{ - public static bool Prefix(HatManager __instance, string hatId, ref HatData __result) - { - __result = (HatData)CustomCosmeticManager._cosmeticToGroup.FirstOrDefault(x => string.Equals(x.Key.ProdId, hatId)).Key; - if (__result) return false; - return true; - } -} diff --git a/MiraAPI/Utilities/Assets/Addressable/Catalog.cs b/MiraAPI/Utilities/Assets/Addressable/Catalog.cs index 676e055f..15031ff8 100644 --- a/MiraAPI/Utilities/Assets/Addressable/Catalog.cs +++ b/MiraAPI/Utilities/Assets/Addressable/Catalog.cs @@ -12,13 +12,28 @@ namespace MiraAPI.Utilities.Assets.Addressable; /// public class Catalog(string CatalogPath) { + /// + /// Loads the catalog asynchronously. + /// public void LoadCatalogAsync() { Coroutines.Start(LoadCatalogAsynchronously()); } + + /// + /// Loads the catalog. This must be done before you can call any addressables. + /// public void LoadCatalog() { Addressables.LoadContentCatalog(CatalogPath).WaitForCompletion(); } + + /// + /// Updates the network catalogs. + /// + public void UpdateNetworkCatalog() + { + Coroutines.Start(UpdateCatalog()); + } protected IEnumerator LoadCatalogAsynchronously() { AsyncOperationHandle handle = Addressables.LoadContentCatalogAsync(CatalogPath, true); diff --git a/MiraAPI/Utilities/Assets/Addressable/CatalogTools.cs b/MiraAPI/Utilities/Assets/Addressable/CatalogTools.cs index a316e856..b083e761 100644 --- a/MiraAPI/Utilities/Assets/Addressable/CatalogTools.cs +++ b/MiraAPI/Utilities/Assets/Addressable/CatalogTools.cs @@ -4,18 +4,37 @@ using System.Reflection; using UnityEngine.AddressableAssets; namespace MiraAPI.Utilities.Assets.Addressable; + +/// +/// A utility class for various catalog-related operations. +/// public static class CatalogTools { + /// + /// Converts string filenames to catalog paths within the plugins folder. + /// + /// A string of the catalog file without the extension + /// The path to the catalog file. public static string ToLocalPath(this string fileName) { return Path.GetDirectoryName(Assembly.GetAssembly(typeof(MiraApiPlugin)).Location) + $"\\{fileName}.catalog"; } + /// + /// Finds the resource locations of a specific label. + /// + /// The label of the addressables assets + /// An IList of IResourceLocation public static Il2CppSystem.Collections.Generic.IList GetResourceLocation(string label) { return Addressables.LoadResourceLocationsAsync(label).WaitForCompletion(); } + /// + /// Finds the resource locations of multiple specific labels. + /// + /// The label of the addressables assets + /// An IList of IResourceLocation public static Il2CppSystem.Collections.Generic.IList GetResourceLocations(string[] labels) { var il2cppLabels = new Il2CppSystem.Collections.Generic.IList(labels.WrapToIl2Cpp().Pointer); diff --git a/MiraAPI/Utilities/Assets/Addressable/WaitForAsyncOperationHandleFinish.cs b/MiraAPI/Utilities/Assets/Addressable/WaitForAsyncOperationHandleFinish.cs index cf434604..4ce9638c 100644 --- a/MiraAPI/Utilities/Assets/Addressable/WaitForAsyncOperationHandleFinish.cs +++ b/MiraAPI/Utilities/Assets/Addressable/WaitForAsyncOperationHandleFinish.cs @@ -2,14 +2,13 @@ using UnityEngine.ResourceManagement.AsyncOperations; namespace MiraAPI.Utilities.Assets.Addressable; -public class WaitForAsyncOperationHandleFinish : IEnumerator -{ - internal AsyncOperationHandle handle; - public WaitForAsyncOperationHandleFinish(AsyncOperationHandle handle) - { - this.handle = handle; - } +/// +/// An IEnumerator for awaiting an AsyncOperationHandle +/// +/// The AsyncOperationHandle being awaited +public class WaitForAsyncOperationHandleFinish(AsyncOperationHandle handle) : IEnumerator +{ public object Current => null; public bool MoveNext() { diff --git a/MiraAPI/Utilities/Assets/LoadableAddressableAsset.cs b/MiraAPI/Utilities/Assets/LoadableAddressableAsset.cs index 5fe2a19d..918c8207 100644 --- a/MiraAPI/Utilities/Assets/LoadableAddressableAsset.cs +++ b/MiraAPI/Utilities/Assets/LoadableAddressableAsset.cs @@ -3,8 +3,18 @@ using UnityEngine.AddressableAssets; namespace MiraAPI.Utilities.Assets; +/// +/// A utility class for loading assets from the addressables api. +/// +/// The name/identifier of the asset +/// The type of the asset to be loaded public class LoadableAddressableAsset(string name) : LoadableAsset where T : UnityEngine.Object { + /// + /// Loads the asset from the addressables api. + /// + /// The asset + /// The asset did not load properly. public override T LoadAsset() { if (LoadedAsset) diff --git a/MiraAPI/Utilities/Assets/LoadableAddressablesGroupAsset.cs b/MiraAPI/Utilities/Assets/LoadableAddressablesGroupAsset.cs index f311e7aa..09450d45 100644 --- a/MiraAPI/Utilities/Assets/LoadableAddressablesGroupAsset.cs +++ b/MiraAPI/Utilities/Assets/LoadableAddressablesGroupAsset.cs @@ -4,9 +4,22 @@ using UnityEngine.AddressableAssets; namespace MiraAPI.Utilities.Assets; +/// +/// A utility class for loading multiple assets from the addressables api. +/// +/// A list of IResourceLocations that locate the assets. +/// The type of the assets to be loaded public class LoadableAddressableGroupAsset(Il2CppSystem.Collections.Generic.IList locations) where T : UnityEngine.Object { + /// + /// A reference to the loaded assets. Intended to be used for caching purposes. + /// protected List LoadedAsset = new(); + /// + /// Loads the assets from the addressables api. + /// + /// The assets + /// The asset did not load properly. public List LoadAsset() { if (LoadedAsset.Count != 0)