code ordering and cleanup

This commit is contained in:
Az committed 2026-10-22 21:15:57 -04:00
1 parent 26541dc07d
commit 1daffd7560
10 files changed
+68 -57

No files matched your search

+3
View File
@@ -104,3 +104,6 @@ dotnet_diagnostic.S1244.severity = none
# S2325: Methods and properties that don't access instance data should be static
dotnet_diagnostic.S2325.severity = none
# IDE0005: Using directive is unnecessary.
dotnet_diagnostic.IDE0005.severity = warning
+2 -2
View File
@@ -31,7 +31,7 @@ public static class ExampleEventHandlers
MiraEventManager.RegisterEventHandler<CompleteTaskEvent>(@event =>
{
Logger<ExamplePlugin>.Info($"{@event.Player.Data.PlayerName} completed {@event.Task.TaskType.ToString()}");
Logger<ExamplePlugin>.Info($"{@event.Player.Data.PlayerName} completed {@event.Task.TaskType}");
});
// You can also unregister event handlers using the handle returned from RegisterEventHandler.
@@ -89,7 +89,7 @@ public static class ExampleEventHandlers
[RegisterEvent]
public static void UpdateSystemEventHandler(UpdateSystemEvent @event)
{
Logger<ExamplePlugin>.Error(@event.SystemType.ToString());
Logger<ExamplePlugin>.Error(@event.SystemType);
}
// Example event handler
+2 -2
View File
@@ -35,7 +35,7 @@ public static class MiraEventManager
}
catch (Exception ex)
{
Error($"Error invoking event handler for {typeof(T).Name}: {ex.ToString()}");
Error($"Error invoking event handler for {typeof(T).Name}: {ex}");
}
}
@@ -65,7 +65,7 @@ public static class MiraEventManager
}
catch (Exception ex)
{
Error($"Error invoking event handler for {type.Name}: {ex.ToString()}");
Error($"Error invoking event handler for {type.Name}: {ex}");
}
}
+4 -4
View File
@@ -77,7 +77,7 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
}
catch (Exception e)
{
Error($"Error while deactivating modifier {modifier.ModifierName}: {e.ToString()}");
Error($"Error while deactivating modifier {modifier.ModifierName}: {e}");
}
Modifiers.Remove(modifier);
@@ -95,7 +95,7 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
}
catch (Exception e)
{
Error($"Error while activating modifier {modifier.ModifierName}: {e.ToString()}");
Error($"Error while activating modifier {modifier.ModifierName}: {e}");
}
if (modifier is TimedModifier { AutoStart: true } timer)
@@ -122,7 +122,7 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
}
catch (Exception e)
{
Error($"Error while (fixed) updating modifier {modifier.ModifierName}: {e.ToString()}");
Error($"Error while (fixed) updating modifier {modifier.ModifierName}: {e}");
}
}
@@ -153,7 +153,7 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
}
catch (Exception e)
{
Error($"Error while updating modifier {modifier.ModifierName}: {e.ToString()}");
Error($"Error while updating modifier {modifier.ModifierName}: {e}");
}
}
}
+1 -2
View File
@@ -1,5 +1,4 @@
using System.Globalization;
using MiraAPI.GameModes;
using MiraAPI.GameModes;
using MiraAPI.PluginLoading;
namespace MiraAPI.Modifiers.Types;
+2 -2
View File
@@ -571,7 +571,7 @@ public static class CustomMurderRpc
}
catch (Exception e)
{
Error($"Error with kill animation: {e.ToString()}");
Error($"Error with kill animation: {e}");
}
}
@@ -705,7 +705,7 @@ public static class CustomMurderRpc
}
catch (Exception e)
{
Error($"Error with kill animation: {e.ToString()}");
Error($"Error with kill animation: {e}");
}
}
+4 -2
View File
@@ -186,9 +186,11 @@ public static class TaskAdderPatches
systemTypes = SystemTypes.UpperEngine;
}
if (!folders.TryGetValue(systemTypes.ToString(), out var taskFolder3))
var systemType = systemTypes.ToString();
if (!folders.TryGetValue(systemType, out var taskFolder3))
{
taskFolder3 = folders[systemTypes.ToString()] = Object.Instantiate(__instance.RootFolderPrefab, __instance.transform);
taskFolder3 = folders[systemType] = Object.Instantiate(__instance.RootFolderPrefab, __instance.transform);
taskFolder3.SetFolderColor(TaskFolder.FolderColor.Tan);
taskFolder3.gameObject.SetActive(false);
taskFolder3.FolderName = systemTypes == SystemTypes.UpperEngine
+33 -39
View File
@@ -25,6 +25,26 @@ public class MiraPluginInfo
PluginId = info.Metadata.GUID;
}
/// <summary>
/// Gets the plugin's ID, as defined in the plugin's BepInEx metadata.
/// </summary>
public string PluginId { get; }
/// <summary>
/// Gets the plugin's instance as an <see cref="IMiraPlugin"/>.
/// </summary>
public IMiraPlugin MiraPlugin { get; }
/// <summary>
/// Gets the plugin's BepInEx metadata.
/// </summary>
public PluginInfo PluginInfo { get; }
/// <summary>
/// Gets the plugin's <see cref="ConfigFile"/>.
/// </summary>
public ConfigFile PluginConfig { get; }
/// <summary>
/// Gets a <see cref="IReadOnlyCollection{T}"/> of this <see cref="IMiraPlugin"/>'s <see cref="BaseModifier"/>s. This is not safe for <see cref="BaseModifier"/>s with constructors.
/// </summary>
@@ -45,15 +65,6 @@ public class MiraPluginInfo
/// </summary>
public ReadOnlyDictionary<ushort, RoleBehaviour> Roles { get; private set; } = null!;
/// <summary>
/// Gets a read only dictionary of Game Mode IDs and the AbstractGameMode object they are associated with.
/// </summary>
/// <returns>Read only dictionary of IDs and Game Modes.</returns>
public ReadOnlyDictionary<uint, AbstractGameMode> GetModes()
{
return new ReadOnlyDictionary<uint, AbstractGameMode>(GameModes);
}
/// <summary>
/// Gets a <see cref="IReadOnlyCollection{T}"/> of this <see cref="IMiraPlugin"/>'s <see cref="CustomActionButton"/>.
/// </summary>
@@ -74,6 +85,15 @@ public class MiraPluginInfo
/// </summary>
public IReadOnlyCollection<OptionPreset> Presets { get; internal set; } = null!;
/// <summary>
/// Gets a read only dictionary of Game Mode IDs and the AbstractGameMode object they are associated with.
/// </summary>
/// <returns>Read only dictionary of IDs and Game Modes.</returns>
public ReadOnlyDictionary<uint, AbstractGameMode> GetModes()
{
return new ReadOnlyDictionary<uint, AbstractGameMode>(GameModes);
}
internal void SavePublicCollections()
{
Presets = [.. InternalPresets];
@@ -87,39 +107,13 @@ public class MiraPluginInfo
}
internal List<OptionPreset> InternalPresets { get; } = [];
internal List<AbstractOptionGroup> InternalOptionGroups { get; } = [];
internal List<IModdedOption> InternalOptions { get; } = [];
internal List<BaseModifier> InternalModifiers { get; } = [];
internal List<CustomActionButton> InternalButtons { get; } = [];
internal List<AbstractOptionGroup> InternalOptionGroups { get; } = [];
internal List<MeetingActionButton> InternalMeetingButtons { get; } = [];
internal List<TargetedMeetingButton> InternalTargetedMeetingButtons { get; } = [];
internal Dictionary<uint, AbstractGameMode> GameModes { get; } = [];
internal Dictionary<ushort, RoleBehaviour> InternalRoles { get; } = [];
internal List<CustomActionButton> InternalButtons { get; } = [];
internal List<TargetedMeetingButton> InternalTargetedMeetingButtons { get; } = [];
internal List<MeetingActionButton> InternalMeetingButtons { get; } = [];
/// <summary>
/// Gets the plugin's ID, as defined in the plugin's BepInEx metadata.
/// </summary>
public string PluginId { get; }
/// <summary>
/// Gets the plugin's instance as an <see cref="IMiraPlugin"/>.
/// </summary>
public IMiraPlugin MiraPlugin { get; }
/// <summary>
/// Gets the plugin's BepInEx metadata.
/// </summary>
public PluginInfo PluginInfo { get; }
/// <summary>
/// Gets the plugin's <see cref="ConfigFile"/>.
/// </summary>
public ConfigFile PluginConfig { get; }
}
+2 -2
View File
@@ -358,7 +358,7 @@ public sealed class MiraPluginManager
}
catch (Exception e)
{
Error($"Failed to register options for {type.Name}: {e.ToString()}");
Error($"Failed to register options for {type.Name}: {e}");
}
return false;
@@ -543,7 +543,7 @@ public sealed class MiraPluginManager
}
catch (Exception e)
{
Error($"Failed to register options for {type.Name}: {e.ToString()}");
Error($"Failed to register options for {type.Name}: {e}");
}
return false;
+15 -2
View File
@@ -492,16 +492,29 @@ public static class Extensions
}
/// <summary>
/// Gets a proper string for an <see cref="Enum"/>. (with spaces).
/// Gets a proper string for an <see cref="Enum"/> (with spaces).
/// </summary>
/// <param name="enum">The <see cref="Enum"/> you would like to change.</param>
/// <returns>A proper string for the <see cref="Enum"/>.</returns>
/// <returns>A proper string for the provided <see cref="Enum"/>.</returns>
public static string ToDisplayString(this Enum @enum)
{
var regex = new Regex(@"([^\^])([A-Z][a-z$])", default, Regex.InfiniteMatchTimeout);
return regex.Replace(@enum.ToString(), m => $"{m.Groups[1].Value} {m.Groups[2].Value}");
}
/// <summary>
/// Gets a proper string for a(n) <typeparamref name="T"/> value (with spaces).
/// </summary>
/// <typeparam name="T">The type of the enum value.</typeparam>
/// <param name="enum">The <typeparamref name="T"/> enum value you would like to change.</param>
/// <returns>A proper string for the provided <typeparamref name="T"/> value.</returns>
public static string ToDisplayString<T>(this T @enum)
where T : struct, Enum
{
var regex = new Regex(@"([^\^])([A-Z][a-z$])", default, Regex.InfiniteMatchTimeout);
return regex.Replace(@enum.ToString(), m => $"{m.Groups[1].Value} {m.Groups[2].Value}");
}
/// <summary>
/// Gets the constructors of a type that match the specified arguments.
/// </summary>