fix most non-documentation warnings

This commit is contained in:
XtraCube committed 2024-09-02 15:19:32 -04:00
1 parent 74055b8a17
commit 0e56a30c5c
35 files changed
+102 -125

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
[*.{cs,vb}]
dotnet_diagnostic.CA1707.severity = none
+2 -2
View File
@@ -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");
}
}
+3 -3
View File
@@ -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));
}
}
+7 -11
View File
@@ -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<ModifierTimerExample>();
}
if (GUILayout.Button("Remove modifier"))
{
//PlayerControl.LocalPlayer.RemoveModifier<ModifierTimerExample>();
}
})
})
{
Enabled = true,
};
+9 -9
View File
@@ -6,12 +6,12 @@ using System.Linq;
namespace MiraAPI.GameModes;
/// <summary>
/// Manages custom gamemodes
/// Manages custom gamemodes.
/// </summary>
public static class CustomGameModeManager
{
/// <summary>
/// List of registered gamemodes
/// List of registered gamemodes.
/// </summary>
internal static readonly Dictionary<int, CustomGameMode> GameModes = [];
@@ -21,14 +21,14 @@ public static class CustomGameModeManager
}
/// <summary>
/// Current gamemode
/// Current gamemode.
/// </summary>
public static CustomGameMode? ActiveMode { get; internal set; } = new DefaultMode();
/// <summary>
/// Set current gamemode
/// Set current gamemode.
/// </summary>
/// <param name="id">gamemode ID</param>
/// <param name="id">gamemode ID.</param>
public static void SetGameMode(int id)
{
if (GameModes.TryGetValue(id, out var gameMode))
@@ -41,9 +41,9 @@ public static class CustomGameModeManager
}
/// <summary>
/// Register gamemode from type
/// Register gamemode from type.
/// </summary>
/// <param name="gameModeType">Type of gamemode class, should inherit from <see cref="CustomGameMode"/></param>
/// <param name="gameModeType">Type of gamemode class, should inherit from <see cref="CustomGameMode"/>.</param>
internal static void RegisterGameMode(Type gameModeType)
{
if (!typeof(CustomGameMode).IsAssignableFrom(gameModeType))
@@ -59,7 +59,7 @@ public static class CustomGameModeManager
Logger<MiraApiPlugin>.Error($"Failed to create instance of {gameModeType.Name}");
return;
}
if (GameModes.Any(x => x.Key == gameMode.Id))
{
Logger<MiraApiPlugin>.Error($"ID for gamemode {gameMode.Name} already exists!");
@@ -68,4 +68,4 @@ public static class CustomGameModeManager
GameModes.Add(gameMode.Id, gameMode);
}
}
}
+1 -1
View File
@@ -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;
}
}
@@ -25,4 +25,4 @@ public class RegisterGameModeAttribute : Attribute
}
}
}
}
}
@@ -13,5 +13,7 @@ public static class OptionGroupSingleton<T> where T : AbstractOptionGroup
/// <summary>
/// Gets the instance of the option group.
/// </summary>
#pragma warning disable CA1000
public static T Instance => _instance ??= ModdedOptionsManager.Groups.OfType<T>().Single();
#pragma warning restore CA1000
}
+2
View File
@@ -13,5 +13,7 @@ public static class CustomButtonSingleton<T> where T : CustomActionButton
/// <summary>
/// Gets the instance of the button.
/// </summary>
#pragma warning disable CA1000
public static T Instance => _instance ??= CustomButtonManager.CustomButtons.OfType<T>().Single();
#pragma warning restore CA1000
}
+1 -1
View File
@@ -6,4 +6,4 @@ namespace MiraAPI.Hud;
/// Attribute to register a button in the HUD. Necessary for the button to be recognized by Mira.
/// </summary>
[AttributeUsage(AttributeTargets.Class)]
public class RegisterButtonAttribute : Attribute;
public class RegisterButtonAttribute : Attribute;
+3 -3
View File
@@ -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()
{
+1 -1
View File
@@ -18,7 +18,7 @@ namespace MiraAPI.Modifiers;
/// The component for handling modifiers.
/// </summary>
[RegisterInIl2Cpp]
public class ModifierComponent(IntPtr ptr) : MonoBehaviour(ptr)
public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
{
/// <summary>
/// Gets the active modifiers on the player.
+1 -1
View File
@@ -6,7 +6,7 @@ using Reactor.Networking.Rpc;
namespace MiraAPI.Networking;
[RegisterCustomRpc((uint)MiraRpc.SyncModifiers)]
internal class SyncModifiersRpc(MiraApiPlugin plugin, uint id) : PlayerCustomRpc<MiraApiPlugin, NetData[]>(plugin, id)
internal sealed class SyncModifiersRpc(MiraApiPlugin plugin, uint id) : PlayerCustomRpc<MiraApiPlugin, NetData[]>(plugin, id)
{
public override RpcLocalHandling LocalHandling => RpcLocalHandling.None;
+1 -1
View File
@@ -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<MiraApiPlugin, NetData[]>(plugin, id)
internal sealed class SyncOptionsRpc(MiraApiPlugin plugin, uint id) : PlayerCustomRpc<MiraApiPlugin, NetData[]>(plugin, id)
{
public override RpcLocalHandling LocalHandling => RpcLocalHandling.None;
+1 -1
View File
@@ -6,7 +6,7 @@ using Reactor.Networking.Rpc;
namespace MiraAPI.Networking;
[RegisterCustomRpc((uint)MiraRpc.SyncRoleOptions)]
internal class SyncRoleOptionsRpc(MiraApiPlugin plugin, uint id) : PlayerCustomRpc<MiraApiPlugin, NetData[]>(plugin, id)
internal sealed class SyncRoleOptionsRpc(MiraApiPlugin plugin, uint id) : PlayerCustomRpc<MiraApiPlugin, NetData[]>(plugin, id)
{
public override RpcLocalHandling LocalHandling => RpcLocalHandling.None;
@@ -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;
/// <summary>
/// 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();
}
}
}
+2 -3
View File
@@ -1,5 +1,4 @@
/*
/*
[HarmonyPatch]
public static class ConsolePatches
{
@@ -69,4 +68,4 @@ public static class ConsolePatches
canUse = couldUse = true;
return true;
}
}*/
}*/
+2 -4
View File
@@ -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);
}
}*/
}*/
@@ -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;
}
}*/
}*/
@@ -1,6 +1,4 @@
/*
/*
/// <summary>
/// Allow Impostors to kill each other if can kill is enabled in gamemode or friendly fire is toggled on
/// </summary>
@@ -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;
}
}*/
}*/
@@ -1,6 +1,4 @@
/*
/*
[HarmonyPatch(typeof(MapBehaviour))]
public static class MapBehaviourPatch
{
@@ -17,4 +15,4 @@ public static class MapBehaviourPatch
return true;
}
}*/
}*/
+2 -4
View File
@@ -1,6 +1,4 @@
/*
/*
[HarmonyPatch(typeof(KillAnimation))]
public static class OnDeathPatch
{
@@ -10,4 +8,4 @@ public static class OnDeathPatch
{
CustomGameModeManager.ActiveMode?.OnDeath(target);
}
}*/
}*/
+2 -6
View File
@@ -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;
}
}*/
}*/
+1 -1
View File
@@ -42,4 +42,4 @@ public static class VentPatches
}
__result = num;
}
}
}
@@ -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();
+2 -2
View File
@@ -7,9 +7,9 @@ namespace MiraAPI.Patches.Roles;
public static class TaskPanelPatch
{
/// <summary>
/// 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.
/// </summary>
[HarmonyPrefix]
[HarmonyPatch(nameof(TaskPanelBehaviour.Update))]
+1 -1
View File
@@ -6,4 +6,4 @@ public interface IMiraPlugin
{
string OptionsTitleText { get; }
public ConfigFile GetConfigFile();
}
}
+1 -1
View File
@@ -15,7 +15,7 @@ using Reactor.Utilities;
namespace MiraAPI.PluginLoading;
internal class MiraPluginManager
internal sealed class MiraPluginManager
{
private readonly Dictionary<Assembly, MiraPluginInfo> _registeredPlugins = [];
+2 -2
View File
@@ -4,5 +4,5 @@ public enum ModdedRoleTeams
{
Crewmate,
Impostor,
Neutral
}
Neutral,
}
+1 -1
View File
@@ -3,4 +3,4 @@
namespace MiraAPI.Roles;
[AttributeUsage(AttributeTargets.Class)]
public class RegisterCustomRoleAttribute : Attribute;
public class RegisterCustomRoleAttribute : Attribute;
+2 -2
View File
@@ -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;
}
}
}
+2 -4
View File
@@ -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);
}
public static readonly Color32 AcceptedTeal = new(43, 233, 198, 255);
}
+9 -15
View File
@@ -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;
/// </summary>
public static class SpriteTools
{
/// <summary>
/// Delegate for LoadImage.
/// </summary>
public delegate bool DLoadImage(IntPtr tex, IntPtr data, bool markNonReadable);
private delegate bool DLoadImage(IntPtr tex, IntPtr data, bool markNonReadable);
/// <summary>
/// The ICall for LoadImage.
/// </summary>
public static DLoadImage? ICallLoadImage;
private static DLoadImage? _iCallLoadImage;
/// <summary>
/// Load an image into a texture.
@@ -32,18 +26,18 @@ public static class SpriteTools
/// <returns>True if succeeded.</returns>
public static bool LoadImage(Texture2D tex, byte[] data, bool markNonReadable)
{
ICallLoadImage ??= IL2CPP.ResolveICall<DLoadImage>("UnityEngine.ImageConversion::LoadImage");
_iCallLoadImage ??= IL2CPP.ResolveICall<DLoadImage>("UnityEngine.ImageConversion::LoadImage");
var il2CPPArray = (Il2CppStructArray<byte>)data;
return ICallLoadImage.Invoke(tex.Pointer, il2CPPArray.Pointer, markNonReadable);
return _iCallLoadImage.Invoke(tex.Pointer, il2CPPArray.Pointer, markNonReadable);
}
/// <summary>
/// Load a sprite from a resource path.
/// </summary>
/// <param name="resourcePath">The path to the resource.</param>
/// <returns>A sprite made from the resource</returns>
/// <returns>A sprite made from the resource.</returns>
/// <exception cref="Exception">The resource cannot be found.</exception>
public static Sprite LoadSpriteFromPath(string resourcePath, Assembly assembly)
{
+2 -2
View File
@@ -4,5 +4,5 @@ public enum MiraNumberSuffixes
None,
Multiplier,
Seconds,
Percent
}
Percent,
}
+22 -23
View File
@@ -5,8 +5,8 @@ namespace MiraAPI.Utilities;
public static class ShaderID
{
private static readonly Dictionary<string, int> Cache = new();
private static readonly Dictionary<string, int> 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");
}
}