diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..017cd3a --- /dev/null +++ b/.editorconfig @@ -0,0 +1,2 @@ +[*.{cs,vb}] +dotnet_diagnostic.CA1707.severity = none \ No newline at end of file diff --git a/MiraAPI.Example/ExampleAssets.cs b/MiraAPI.Example/ExampleAssets.cs index a96dfc8..732d9f7 100644 --- a/MiraAPI.Example/ExampleAssets.cs +++ b/MiraAPI.Example/ExampleAssets.cs @@ -6,7 +6,7 @@ public static class ExampleAssets { public static LoadableResourceAsset ExampleButton { get; } = new("MiraAPI.Example.Resources.ExampleButton.png"); - // Credit to EpicHorrors for the teleport button asset. + // Credit to EpicHorrors for the teleport button asset. public static LoadableResourceAsset TeleportButton { get; } = new("MiraAPI.Example.Resources.TeleportButton.png"); public static LoadableResourceAsset Banner { get; } = new("MiraAPI.Example.Resources.FortniteBanner.jpeg"); -} \ No newline at end of file +} diff --git a/MiraAPI.Example/ExampleColors.cs b/MiraAPI.Example/ExampleColors.cs index 3212093..6833d3c 100644 --- a/MiraAPI.Example/ExampleColors.cs +++ b/MiraAPI.Example/ExampleColors.cs @@ -6,9 +6,9 @@ namespace MiraAPI.Example; [RegisterCustomColors] public static class ExampleColors { - public static CustomColor Cerulean { get; } = new("Cerulean", new Color(0.0f, 0.48f, 0.65f)); + public static CustomColor Cerulean { get; } = new("Cerulean", new Color(0.0f, 0.48f, 0.65f)); public static CustomColor Rose { get; } = new("Rose", new Color(0.98f, 0.26f, 0.62f)); - + public static CustomColor Gold { get; } = new("Gold", new Color(1.0f, 0.84f, 0.0f)); -} \ No newline at end of file +} diff --git a/MiraAPI.Example/MiraDebugWindow.cs b/MiraAPI.Example/MiraDebugWindow.cs index 9b0fa7e..13a41d4 100644 --- a/MiraAPI.Example/MiraDebugWindow.cs +++ b/MiraAPI.Example/MiraDebugWindow.cs @@ -4,20 +4,16 @@ using System; using UnityEngine; namespace MiraAPI.Example; + [RegisterInIl2Cpp] -public class MiraDebugWindow(IntPtr ptr) : MonoBehaviour(ptr) +public class MiraDebugWindow(IntPtr cppPtr) : MonoBehaviour(cppPtr) { - public readonly DragWindow DebuggingWindow = new(new Rect(10, 10, 0, 0), "MIRA API DEBUGGING", () => - { - if (GUILayout.Button("Test modifier")) + public DragWindow DebuggingWindow { get; } = new( + new Rect(10, 10, 0, 0), + "MIRA API DEBUGGING", + () => { - //PlayerControl.LocalPlayer.AddModifier(); - } - if (GUILayout.Button("Remove modifier")) - { - //PlayerControl.LocalPlayer.RemoveModifier(); - } - }) + }) { Enabled = true, }; diff --git a/MiraAPI/GameModes/CustomGameModeManager.cs b/MiraAPI/GameModes/CustomGameModeManager.cs index 028eb94..388eb5d 100644 --- a/MiraAPI/GameModes/CustomGameModeManager.cs +++ b/MiraAPI/GameModes/CustomGameModeManager.cs @@ -6,12 +6,12 @@ using System.Linq; namespace MiraAPI.GameModes; /// -/// Manages custom gamemodes +/// Manages custom gamemodes. /// public static class CustomGameModeManager { /// - /// List of registered gamemodes + /// List of registered gamemodes. /// internal static readonly Dictionary GameModes = []; @@ -21,14 +21,14 @@ public static class CustomGameModeManager } /// - /// Current gamemode + /// Current gamemode. /// public static CustomGameMode? ActiveMode { get; internal set; } = new DefaultMode(); /// - /// Set current gamemode + /// Set current gamemode. /// - /// gamemode ID + /// gamemode ID. public static void SetGameMode(int id) { if (GameModes.TryGetValue(id, out var gameMode)) @@ -41,9 +41,9 @@ public static class CustomGameModeManager } /// - /// Register gamemode from type + /// Register gamemode from type. /// - /// Type of gamemode class, should inherit from + /// Type of gamemode class, should inherit from . internal static void RegisterGameMode(Type gameModeType) { if (!typeof(CustomGameMode).IsAssignableFrom(gameModeType)) @@ -59,7 +59,7 @@ public static class CustomGameModeManager Logger.Error($"Failed to create instance of {gameModeType.Name}"); return; } - + if (GameModes.Any(x => x.Key == gameMode.Id)) { Logger.Error($"ID for gamemode {gameMode.Name} already exists!"); @@ -68,4 +68,4 @@ public static class CustomGameModeManager GameModes.Add(gameMode.Id, gameMode); } -} \ No newline at end of file +} diff --git a/MiraAPI/GameModes/DefaultMode.cs b/MiraAPI/GameModes/DefaultMode.cs index 2e7fcb0..73c4ca8 100644 --- a/MiraAPI/GameModes/DefaultMode.cs +++ b/MiraAPI/GameModes/DefaultMode.cs @@ -6,4 +6,4 @@ public class DefaultMode : CustomGameMode public override string Name => "Default"; public override string Description => "Default Among Us GameMode"; public override int Id => 0; -} \ No newline at end of file +} diff --git a/MiraAPI/GameModes/RegisterGameModeAttribute.cs b/MiraAPI/GameModes/RegisterGameModeAttribute.cs index b329d53..4c66c35 100644 --- a/MiraAPI/GameModes/RegisterGameModeAttribute.cs +++ b/MiraAPI/GameModes/RegisterGameModeAttribute.cs @@ -25,4 +25,4 @@ public class RegisterGameModeAttribute : Attribute } } } -} \ No newline at end of file +} diff --git a/MiraAPI/GameOptions/OptionGroupSingleton.cs b/MiraAPI/GameOptions/OptionGroupSingleton.cs index 8c7e2af..53b2029 100644 --- a/MiraAPI/GameOptions/OptionGroupSingleton.cs +++ b/MiraAPI/GameOptions/OptionGroupSingleton.cs @@ -13,5 +13,7 @@ public static class OptionGroupSingleton where T : AbstractOptionGroup /// /// Gets the instance of the option group. /// +#pragma warning disable CA1000 public static T Instance => _instance ??= ModdedOptionsManager.Groups.OfType().Single(); +#pragma warning restore CA1000 } diff --git a/MiraAPI/Hud/CustomButtonSingleton.cs b/MiraAPI/Hud/CustomButtonSingleton.cs index 3e732be..b338e61 100644 --- a/MiraAPI/Hud/CustomButtonSingleton.cs +++ b/MiraAPI/Hud/CustomButtonSingleton.cs @@ -13,5 +13,7 @@ public static class CustomButtonSingleton where T : CustomActionButton /// /// Gets the instance of the button. /// +#pragma warning disable CA1000 public static T Instance => _instance ??= CustomButtonManager.CustomButtons.OfType().Single(); +#pragma warning restore CA1000 } diff --git a/MiraAPI/Hud/RegisterButtonAttribute.cs b/MiraAPI/Hud/RegisterButtonAttribute.cs index feda3a8..82e0ca5 100644 --- a/MiraAPI/Hud/RegisterButtonAttribute.cs +++ b/MiraAPI/Hud/RegisterButtonAttribute.cs @@ -6,4 +6,4 @@ namespace MiraAPI.Hud; /// Attribute to register a button in the HUD. Necessary for the button to be recognized by Mira. /// [AttributeUsage(AttributeTargets.Class)] -public class RegisterButtonAttribute : Attribute; \ No newline at end of file +public class RegisterButtonAttribute : Attribute; diff --git a/MiraAPI/MiraApiPlugin.cs b/MiraAPI/MiraApiPlugin.cs index b928565..cfe314d 100644 --- a/MiraAPI/MiraApiPlugin.cs +++ b/MiraAPI/MiraApiPlugin.cs @@ -16,10 +16,10 @@ namespace MiraAPI; [ReactorModFlags(ModFlags.RequireOnAllClients)] public partial class MiraApiPlugin : BasePlugin { - public Harmony Harmony { get; } = new(Id); - private static MiraPluginManager PluginManager { get; set; } + private static MiraPluginManager? PluginManager { get; set; } - public static Color MiraColor = new Color32(238, 154, 112, 255); + public Harmony Harmony { get; } = new(Id); + public static Color MiraColor { get; } = new Color32(238, 154, 112, 255); public override void Load() { diff --git a/MiraAPI/Modifiers/ModifierComponent.cs b/MiraAPI/Modifiers/ModifierComponent.cs index 9517711..8b32dc2 100644 --- a/MiraAPI/Modifiers/ModifierComponent.cs +++ b/MiraAPI/Modifiers/ModifierComponent.cs @@ -18,7 +18,7 @@ namespace MiraAPI.Modifiers; /// The component for handling modifiers. /// [RegisterInIl2Cpp] -public class ModifierComponent(IntPtr ptr) : MonoBehaviour(ptr) +public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr) { /// /// Gets the active modifiers on the player. diff --git a/MiraAPI/Networking/SyncModifiersRpc.cs b/MiraAPI/Networking/SyncModifiersRpc.cs index 9598f0f..288e2c1 100644 --- a/MiraAPI/Networking/SyncModifiersRpc.cs +++ b/MiraAPI/Networking/SyncModifiersRpc.cs @@ -6,7 +6,7 @@ using Reactor.Networking.Rpc; namespace MiraAPI.Networking; [RegisterCustomRpc((uint)MiraRpc.SyncModifiers)] -internal class SyncModifiersRpc(MiraApiPlugin plugin, uint id) : PlayerCustomRpc(plugin, id) +internal sealed class SyncModifiersRpc(MiraApiPlugin plugin, uint id) : PlayerCustomRpc(plugin, id) { public override RpcLocalHandling LocalHandling => RpcLocalHandling.None; diff --git a/MiraAPI/Networking/SyncOptionsRpc.cs b/MiraAPI/Networking/SyncOptionsRpc.cs index 288c690..a80ace3 100644 --- a/MiraAPI/Networking/SyncOptionsRpc.cs +++ b/MiraAPI/Networking/SyncOptionsRpc.cs @@ -7,7 +7,7 @@ namespace MiraAPI.Networking; // METHOD RPC DOESNT WORK WITH THE ARRAYS AND STUFF SO THIS IS HOW WE WILL DO IT FOR NOW [RegisterCustomRpc((uint)MiraRpc.SyncGameOptions)] -internal class SyncOptionsRpc(MiraApiPlugin plugin, uint id) : PlayerCustomRpc(plugin, id) +internal sealed class SyncOptionsRpc(MiraApiPlugin plugin, uint id) : PlayerCustomRpc(plugin, id) { public override RpcLocalHandling LocalHandling => RpcLocalHandling.None; diff --git a/MiraAPI/Networking/SyncRoleOptionsRpc.cs b/MiraAPI/Networking/SyncRoleOptionsRpc.cs index 290fc0f..adfe537 100644 --- a/MiraAPI/Networking/SyncRoleOptionsRpc.cs +++ b/MiraAPI/Networking/SyncRoleOptionsRpc.cs @@ -6,7 +6,7 @@ using Reactor.Networking.Rpc; namespace MiraAPI.Networking; [RegisterCustomRpc((uint)MiraRpc.SyncRoleOptions)] -internal class SyncRoleOptionsRpc(MiraApiPlugin plugin, uint id) : PlayerCustomRpc(plugin, id) +internal sealed class SyncRoleOptionsRpc(MiraApiPlugin plugin, uint id) : PlayerCustomRpc(plugin, id) { public override RpcLocalHandling LocalHandling => RpcLocalHandling.None; diff --git a/MiraAPI/Patches/Colors/ScrollingColorsPatch.cs b/MiraAPI/Patches/Colors/ScrollingColorsPatch.cs index 9fdc6d4..e89de23 100644 --- a/MiraAPI/Patches/Colors/ScrollingColorsPatch.cs +++ b/MiraAPI/Patches/Colors/ScrollingColorsPatch.cs @@ -7,8 +7,8 @@ namespace MiraAPI.Patches.Colors; [HarmonyPatch(typeof(PlayerTab))] public static class ScrollingColorsPatch { - /// Collider - private static BoxCollider2D _collider; + // Collider + private static BoxCollider2D? _collider; /// /// Add scrolling to the colors tab @@ -20,7 +20,7 @@ public static class ScrollingColorsPatch { return; } - + var tab = PlayerCustomizationMenu.Instance.Tabs[1].Tab; if (__instance.scroller == null) @@ -31,7 +31,7 @@ public static class ScrollingColorsPatch var maskObj = new GameObject { layer = 5, - name = "SpriteMask" + name = "SpriteMask", }; maskObj.transform.SetParent(__instance.transform); maskObj.transform.localPosition = new Vector3(0, 0, 0); @@ -55,4 +55,4 @@ public static class ScrollingColorsPatch __instance.SetScrollerBounds(); } -} \ No newline at end of file +} diff --git a/MiraAPI/Patches/GameModes/ConsolePatches.cs b/MiraAPI/Patches/GameModes/ConsolePatches.cs index 50248e7..e2f24b2 100644 --- a/MiraAPI/Patches/GameModes/ConsolePatches.cs +++ b/MiraAPI/Patches/GameModes/ConsolePatches.cs @@ -1,5 +1,4 @@ - -/* +/* [HarmonyPatch] public static class ConsolePatches { @@ -69,4 +68,4 @@ public static class ConsolePatches canUse = couldUse = true; return true; } -}*/ \ No newline at end of file +}*/ diff --git a/MiraAPI/Patches/GameModes/DeadBodyPatch.cs b/MiraAPI/Patches/GameModes/DeadBodyPatch.cs index edd4e58..07a2899 100644 --- a/MiraAPI/Patches/GameModes/DeadBodyPatch.cs +++ b/MiraAPI/Patches/GameModes/DeadBodyPatch.cs @@ -1,6 +1,4 @@ - - -/* +/* [HarmonyPatch(typeof(DeadBody))] public static class DeadBodyPatch { @@ -10,4 +8,4 @@ public static class DeadBodyPatch { return CustomGameModeManager.ActiveMode == null || CustomGameModeManager.ActiveMode.CanReport(__instance); } -}*/ \ No newline at end of file +}*/ diff --git a/MiraAPI/Patches/GameModes/GameLogicPatches.cs b/MiraAPI/Patches/GameModes/GameLogicPatches.cs index 77eca63..a62be83 100644 --- a/MiraAPI/Patches/GameModes/GameLogicPatches.cs +++ b/MiraAPI/Patches/GameModes/GameLogicPatches.cs @@ -1,6 +1,4 @@ - - -/* +/* [HarmonyPatch] public static class GameLogicPatches { @@ -19,4 +17,4 @@ public static class GameLogicPatches CustomGameModeManager.ActiveMode?.AssignRoles(out runOriginal, __instance); return runOriginal; } -}*/ \ No newline at end of file +}*/ diff --git a/MiraAPI/Patches/GameModes/ImpostorTargetPatch.cs b/MiraAPI/Patches/GameModes/ImpostorTargetPatch.cs index 58f1187..ad0d9e0 100644 --- a/MiraAPI/Patches/GameModes/ImpostorTargetPatch.cs +++ b/MiraAPI/Patches/GameModes/ImpostorTargetPatch.cs @@ -1,6 +1,4 @@ - - -/* +/* /// /// Allow Impostors to kill each other if can kill is enabled in gamemode or friendly fire is toggled on /// @@ -16,11 +14,11 @@ public static class ImpostorTargetPatch { return true; } - + __result = target is { Disconnected: false, IsDead: false } && target.PlayerId != __instance.Player.PlayerId && !(target.Role == null) && !(target.Object == null) && !target.Object.inVent && !target.Object.inMovingPlat; return false; } -}*/ \ No newline at end of file +}*/ diff --git a/MiraAPI/Patches/GameModes/MapBehaviourPatch.cs b/MiraAPI/Patches/GameModes/MapBehaviourPatch.cs index 8f17b99..9a4bd8b 100644 --- a/MiraAPI/Patches/GameModes/MapBehaviourPatch.cs +++ b/MiraAPI/Patches/GameModes/MapBehaviourPatch.cs @@ -1,6 +1,4 @@ - - -/* +/* [HarmonyPatch(typeof(MapBehaviour))] public static class MapBehaviourPatch { @@ -17,4 +15,4 @@ public static class MapBehaviourPatch return true; } -}*/ \ No newline at end of file +}*/ diff --git a/MiraAPI/Patches/GameModes/OnDeathPatch.cs b/MiraAPI/Patches/GameModes/OnDeathPatch.cs index 275321d..99f9211 100644 --- a/MiraAPI/Patches/GameModes/OnDeathPatch.cs +++ b/MiraAPI/Patches/GameModes/OnDeathPatch.cs @@ -1,6 +1,4 @@ - - -/* +/* [HarmonyPatch(typeof(KillAnimation))] public static class OnDeathPatch { @@ -10,4 +8,4 @@ public static class OnDeathPatch { CustomGameModeManager.ActiveMode?.OnDeath(target); } -}*/ \ No newline at end of file +}*/ diff --git a/MiraAPI/Patches/GameModes/VentPatches.cs b/MiraAPI/Patches/GameModes/VentPatches.cs index a86aa46..597c40a 100644 --- a/MiraAPI/Patches/GameModes/VentPatches.cs +++ b/MiraAPI/Patches/GameModes/VentPatches.cs @@ -1,10 +1,7 @@ - - -/* +/* [HarmonyPatch(typeof(Vent))] public static class VentPatches { - [HarmonyPrefix] [HarmonyPatch(nameof(Vent.CanUse))] public static bool CanUseVentPatch(Vent __instance, ref float __result, [HarmonyArgument(0)] NetworkedPlayerInfo pc, [HarmonyArgument(1)] ref bool canUse, [HarmonyArgument(2)] ref bool couldUse) @@ -47,5 +44,4 @@ public static class VentPatches return false; } - -}*/ \ No newline at end of file +}*/ diff --git a/MiraAPI/Patches/Modifiers/VentPatches.cs b/MiraAPI/Patches/Modifiers/VentPatches.cs index 6646336..8c6c26a 100644 --- a/MiraAPI/Patches/Modifiers/VentPatches.cs +++ b/MiraAPI/Patches/Modifiers/VentPatches.cs @@ -42,4 +42,4 @@ public static class VentPatches } __result = num; } -} \ No newline at end of file +} diff --git a/MiraAPI/Patches/Options/GameSettingMenuPatches.cs b/MiraAPI/Patches/Options/GameSettingMenuPatches.cs index 13c9036..a44b35c 100644 --- a/MiraAPI/Patches/Options/GameSettingMenuPatches.cs +++ b/MiraAPI/Patches/Options/GameSettingMenuPatches.cs @@ -154,7 +154,6 @@ public static class GameSettingMenuPatches } roles.roleChances.Clear(); - roles.roleChances = null; roles.AdvancedRolesSettings.gameObject.SetActive(false); roles.RoleChancesSettings.gameObject.SetActive(true); roles.SetQuotaTab(); diff --git a/MiraAPI/Patches/Roles/TaskPanelPatch.cs b/MiraAPI/Patches/Roles/TaskPanelPatch.cs index 3d4ae14..431d47b 100644 --- a/MiraAPI/Patches/Roles/TaskPanelPatch.cs +++ b/MiraAPI/Patches/Roles/TaskPanelPatch.cs @@ -7,9 +7,9 @@ namespace MiraAPI.Patches.Roles; public static class TaskPanelPatch { /// - /// This patch is to override the automatic updating of the y position on the tab (which is in base game), + /// This patch is to override the automatic updating of the y position on the tab (which is in base game) /// because I can't change the custom tab y pos if it's being overriden every frame. - /// Im sure there is an easier/better way, but this is the fix that worked for me + /// Im sure there is an easier/better way, but this is the fix that worked for me. /// [HarmonyPrefix] [HarmonyPatch(nameof(TaskPanelBehaviour.Update))] diff --git a/MiraAPI/PluginLoading/IMiraPlugin.cs b/MiraAPI/PluginLoading/IMiraPlugin.cs index 9a71645..07928da 100644 --- a/MiraAPI/PluginLoading/IMiraPlugin.cs +++ b/MiraAPI/PluginLoading/IMiraPlugin.cs @@ -6,4 +6,4 @@ public interface IMiraPlugin { string OptionsTitleText { get; } public ConfigFile GetConfigFile(); -} \ No newline at end of file +} diff --git a/MiraAPI/PluginLoading/MiraPluginManager.cs b/MiraAPI/PluginLoading/MiraPluginManager.cs index 794d74e..423cb09 100644 --- a/MiraAPI/PluginLoading/MiraPluginManager.cs +++ b/MiraAPI/PluginLoading/MiraPluginManager.cs @@ -15,7 +15,7 @@ using Reactor.Utilities; namespace MiraAPI.PluginLoading; -internal class MiraPluginManager +internal sealed class MiraPluginManager { private readonly Dictionary _registeredPlugins = []; diff --git a/MiraAPI/Roles/ModdedRoleTeams.cs b/MiraAPI/Roles/ModdedRoleTeams.cs index ca7adad..e599cd7 100644 --- a/MiraAPI/Roles/ModdedRoleTeams.cs +++ b/MiraAPI/Roles/ModdedRoleTeams.cs @@ -4,5 +4,5 @@ public enum ModdedRoleTeams { Crewmate, Impostor, - Neutral -} \ No newline at end of file + Neutral, +} diff --git a/MiraAPI/Roles/RegisterCustomRoleAttribute.cs b/MiraAPI/Roles/RegisterCustomRoleAttribute.cs index db9a0e7..a6352f1 100644 --- a/MiraAPI/Roles/RegisterCustomRoleAttribute.cs +++ b/MiraAPI/Roles/RegisterCustomRoleAttribute.cs @@ -3,4 +3,4 @@ namespace MiraAPI.Roles; [AttributeUsage(AttributeTargets.Class)] -public class RegisterCustomRoleAttribute : Attribute; \ No newline at end of file +public class RegisterCustomRoleAttribute : Attribute; diff --git a/MiraAPI/Roles/RoleId.cs b/MiraAPI/Roles/RoleId.cs index 9970d62..05f9cd0 100644 --- a/MiraAPI/Roles/RoleId.cs +++ b/MiraAPI/Roles/RoleId.cs @@ -13,7 +13,7 @@ public static class RoleId return roleId; } - + public static ushort Get(Type type) { if (!CustomRoleManager.RoleIds.TryGetValue(type, out var roleId)) @@ -23,4 +23,4 @@ public static class RoleId return roleId; } -} \ No newline at end of file +} diff --git a/MiraAPI/Utilities/Assets/MiraAssets.cs b/MiraAPI/Utilities/Assets/MiraAssets.cs index 527fadb..514bd25 100644 --- a/MiraAPI/Utilities/Assets/MiraAssets.cs +++ b/MiraAPI/Utilities/Assets/MiraAssets.cs @@ -11,7 +11,5 @@ public static class MiraAssets public static readonly LoadableResourceAsset Cog = new("MiraAPI.Resources.Cog.png"); public static readonly LoadableResourceAsset Checkmark = new("MiraAPI.Resources.Checkmark.png"); public static readonly LoadableResourceAsset CheckmarkBox = new("MiraAPI.Resources.CheckMarkBox.png"); - - - public static readonly Color32 AcceptedTeal = new Color32(43, 233, 198, 255); -} \ No newline at end of file + public static readonly Color32 AcceptedTeal = new(43, 233, 198, 255); +} diff --git a/MiraAPI/Utilities/Assets/SpriteTools.cs b/MiraAPI/Utilities/Assets/SpriteTools.cs index d086a9e..bf79182 100644 --- a/MiraAPI/Utilities/Assets/SpriteTools.cs +++ b/MiraAPI/Utilities/Assets/SpriteTools.cs @@ -1,9 +1,9 @@ -using Il2CppInterop.Runtime; -using Il2CppInterop.Runtime.InteropTypes.Arrays; -using Reactor.Utilities.Extensions; -using System; +using System; using System.Reflection; +using Il2CppInterop.Runtime; +using Il2CppInterop.Runtime.InteropTypes.Arrays; using Reactor.Utilities; +using Reactor.Utilities.Extensions; using UnityEngine; namespace MiraAPI.Utilities.Assets; @@ -13,15 +13,9 @@ namespace MiraAPI.Utilities.Assets; /// public static class SpriteTools { - /// - /// Delegate for LoadImage. - /// - public delegate bool DLoadImage(IntPtr tex, IntPtr data, bool markNonReadable); + private delegate bool DLoadImage(IntPtr tex, IntPtr data, bool markNonReadable); - /// - /// The ICall for LoadImage. - /// - public static DLoadImage? ICallLoadImage; + private static DLoadImage? _iCallLoadImage; /// /// Load an image into a texture. @@ -32,18 +26,18 @@ public static class SpriteTools /// True if succeeded. public static bool LoadImage(Texture2D tex, byte[] data, bool markNonReadable) { - ICallLoadImage ??= IL2CPP.ResolveICall("UnityEngine.ImageConversion::LoadImage"); + _iCallLoadImage ??= IL2CPP.ResolveICall("UnityEngine.ImageConversion::LoadImage"); var il2CPPArray = (Il2CppStructArray)data; - return ICallLoadImage.Invoke(tex.Pointer, il2CPPArray.Pointer, markNonReadable); + return _iCallLoadImage.Invoke(tex.Pointer, il2CPPArray.Pointer, markNonReadable); } /// /// Load a sprite from a resource path. /// /// The path to the resource. - /// A sprite made from the resource + /// A sprite made from the resource. /// The resource cannot be found. public static Sprite LoadSpriteFromPath(string resourcePath, Assembly assembly) { diff --git a/MiraAPI/Utilities/MiraNumberSuffixes.cs b/MiraAPI/Utilities/MiraNumberSuffixes.cs index 3682e2b..20ed21c 100644 --- a/MiraAPI/Utilities/MiraNumberSuffixes.cs +++ b/MiraAPI/Utilities/MiraNumberSuffixes.cs @@ -4,5 +4,5 @@ public enum MiraNumberSuffixes None, Multiplier, Seconds, - Percent -} \ No newline at end of file + Percent, +} diff --git a/MiraAPI/Utilities/ShaderID.cs b/MiraAPI/Utilities/ShaderID.cs index 08775bf..d250336 100644 --- a/MiraAPI/Utilities/ShaderID.cs +++ b/MiraAPI/Utilities/ShaderID.cs @@ -5,8 +5,8 @@ namespace MiraAPI.Utilities; public static class ShaderID { - private static readonly Dictionary Cache = new(); - + private static readonly Dictionary Cache = []; + public static int Get(string name) { if (Cache.TryGetValue(name, out var id)) @@ -18,74 +18,74 @@ public static class ShaderID Cache[name] = id; return id; } - + // For player shader public static readonly int BodyColor = Shader.PropertyToID("_BodyColor"); public static readonly int BackColor = Shader.PropertyToID("_BackColor"); public static readonly int VisorColor = Shader.PropertyToID("_VisorColor"); - + // Main texture, very obviously used in any shader with a texture public static readonly int MainTex = Shader.PropertyToID("_MainTex"); - + // Any masking stuff, like MeetingHud bubbles public static readonly int Mask = Shader.PropertyToID("_Mask"); public static readonly int MaskComp = Shader.PropertyToID("_MaskComp"); public static readonly int MaskLayer = Shader.PropertyToID("_MaskLayer"); public static readonly int Stencil = Shader.PropertyToID("_Stencil"); public static readonly int StencilComp = Shader.PropertyToID("_StencilComp"); - + // Used in many tasks public static readonly int Color = Shader.PropertyToID("_Color"); - + // Has 2 uses in the game, provided for convenience public static readonly int Opacity = Shader.PropertyToID("_Opacity"); - + // Used once in CooldownHelpers, once in PowerBarMining public static readonly int NormalizedUvs = Shader.PropertyToID("_NormalizedUvs"); - + // Used in many consoles public static readonly int Outline = Shader.PropertyToID("_Outline"); public static readonly int OutlineColor = Shader.PropertyToID("_OutlineColor"); - + // Used in some consoles public static readonly int AddColor = Shader.PropertyToID("_AddColor"); - + // Has some uses in various locations public static readonly int Percent = Shader.PropertyToID("_Percent"); public static readonly int PercentY = Shader.PropertyToID("_PercentY"); public static readonly int Desat = Shader.PropertyToID("_Desat"); - + // Used in LightSource public static readonly int PlayerRadius = Shader.PropertyToID("_PlayerRadius"); public static readonly int LightRadius = Shader.PropertyToID("_LightRadius"); public static readonly int LightOffset = Shader.PropertyToID("_LightOffset"); public static readonly int FlashlightSize = Shader.PropertyToID("_FlashlightSize"); public static readonly int FlashlightAngle = Shader.PropertyToID("_FlashlightAngle"); - + // Used once for LightSourceGpuRenderer public static readonly int DepthCompressionValue = Shader.PropertyToID("_DepthCompressionValue"); - + // Used in ProgressTracker public static readonly int Buckets = Shader.PropertyToID("_Buckets"); public static readonly int FullBuckets = Shader.PropertyToID("_FullBuckets"); - + // Used once in IntroCutscene and EndGameManager public static readonly int Rad = Shader.PropertyToID("_Rad"); - + // Used only once for Quick Chat public static readonly int FaceColor = Shader.PropertyToID("_FaceColor"); - + // Used for NavigationMinigame public static readonly int CrossHair = Shader.PropertyToID("_CrossHair"); public static readonly int CrossColor = Shader.PropertyToID("_CrossColor"); - + // Used for both SurveillanceMinigame (Planet and Normal) public static readonly int Center = Shader.PropertyToID("_Center"); public static readonly int Color2 = Shader.PropertyToID("_Color2"); - + // Used in ReactorShipRoom public static readonly int Speed = Shader.PropertyToID("_Speed"); - + // Used only once in CourseMinigame public static readonly int AltTex = Shader.PropertyToID("_AltTex"); public static readonly int Perc = Shader.PropertyToID("_Perc"); @@ -93,8 +93,7 @@ public static class ShaderID // Used once in TextMarquee public static readonly int VertexOffsetX = Shader.PropertyToID("_VertexOffsetX"); public static readonly int VertexOffsetY = Shader.PropertyToID("_VertexOffsetY"); - + // Used in VertLineBehaviour public static readonly int Fade = Shader.PropertyToID("_Fade"); - -} \ No newline at end of file +}