fix warnings

scav you have committed a war crime. C# =/= python
This commit is contained in:
Az committed 2026-09-27 16:59:17 -04:00
1 parent 041c39d7ff
commit 5fb60a7082
10 files changed
+36 -17

No files matched your search

+1 -2
View File
@@ -1,5 +1,4 @@
using System.Diagnostics.CodeAnalysis; using System.Globalization;
using System.Globalization;
using System.Linq; using System.Linq;
using MiraAPI.Events; using MiraAPI.Events;
using MiraAPI.Events.Mira; using MiraAPI.Events.Mira;
+3 -2
View File
@@ -217,7 +217,7 @@ public abstract class CustomActionButton
{ {
ActiveInputManager.InputType.Keyboard when Keybind.CurrentKey != KeyboardKeyCode.None => Keybind.CurrentKey.ToString(), ActiveInputManager.InputType.Keyboard when Keybind.CurrentKey != KeyboardKeyCode.None => Keybind.CurrentKey.ToString(),
ActiveInputManager.InputType.Joystick => Keybind.CurrentControllerButton, ActiveInputManager.InputType.Joystick => Keybind.CurrentControllerButton,
_ => string.Empty _ => string.Empty,
}; };
KeybindText.text = text; KeybindText.text = text;
@@ -516,7 +516,8 @@ public abstract class CustomActionButton
/// Custom action button that has a target <typeparamref name="T"/>. /// Custom action button that has a target <typeparamref name="T"/>.
/// </summary> /// </summary>
/// <typeparam name="T">The type of the target object.</typeparam> /// <typeparam name="T">The type of the target object.</typeparam>
public abstract class CustomActionButton<T> : CustomActionButton where T : MonoBehaviour public abstract class CustomActionButton<T> : CustomActionButton
where T : MonoBehaviour
{ {
/// <summary> /// <summary>
/// Gets or sets the target <typeparamref name="T"/> of the button. /// Gets or sets the target <typeparamref name="T"/> of the button.
+5 -2
View File
@@ -17,7 +17,8 @@ public static class KeybindManager
/// </summary> /// </summary>
public static List<MiraKeybind> Keybinds { get; } = []; public static List<MiraKeybind> Keybinds { get; } = [];
[HideFromIl2Cpp] internal static Dictionary<Type, VanillaKeybind> VanillaKeybinds { get; set; } = []; [HideFromIl2Cpp]
internal static Dictionary<Type, VanillaKeybind> VanillaKeybinds { get; set; } = [];
internal static void RewiredInit() internal static void RewiredInit()
{ {
@@ -63,7 +64,7 @@ public static class KeybindManager
_elementIdentifierId = elementId, _elementIdentifierId = elementId,
_elementType = elementType, _elementType = elementType,
_axisRange = AxisRange.Positive, _axisRange = AxisRange.Positive,
_axisContribution = Pole.Positive _axisContribution = Pole.Positive,
}); });
} }
} }
@@ -154,8 +155,10 @@ public static class KeybindManager
{ {
var all = new List<MiraKeybind>(); var all = new List<MiraKeybind>();
foreach (var keybind in Keybinds) foreach (var keybind in Keybinds)
{
if (keybind.CurrentKey == keyCode && (keybind.Exclusive || !exclusiveCheck)) if (keybind.CurrentKey == keyCode && (keybind.Exclusive || !exclusiveCheck))
all.Add(keybind); all.Add(keybind);
}
return [.. all]; return [.. all];
} }
+1 -1
View File
@@ -40,7 +40,7 @@ public static class KeybindUtils
"square" => "□", "square" => "□",
"circle" => "○", "circle" => "○",
"triangle" => "△", "triangle" => "△",
_ => name _ => name,
}; };
} }
+2 -1
View File
@@ -49,7 +49,8 @@ public class MiraKeybind(string name, KeyboardKeyCode? defaultKeycode, ModifierK
/// <param name="defaultControllerButton">The default controller button.</param> /// <param name="defaultControllerButton">The default controller button.</param>
/// <param name="modifierKeys">Up to 3 optional <see cref="ModifierKey"/>s for the keyboard binding.</param> /// <param name="modifierKeys">Up to 3 optional <see cref="ModifierKey"/>s for the keyboard binding.</param>
/// <param name="exclusive">Is exclusive.</param> /// <param name="exclusive">Is exclusive.</param>
public MiraKeybind(string name, KeyboardKeyCode? defaultKeycode, ControllerButton defaultControllerButton, ModifierKey[]? modifierKeys = null, bool exclusive = true) : this(name, defaultKeycode, modifierKeys, exclusive) public MiraKeybind(string name, KeyboardKeyCode? defaultKeycode, ControllerButton defaultControllerButton, ModifierKey[]? modifierKeys = null, bool exclusive = true)
: this(name, defaultKeycode, modifierKeys, exclusive)
{ {
DefaultControllerButton = defaultControllerButton; DefaultControllerButton = defaultControllerButton;
} }
+2 -1
View File
@@ -6,7 +6,8 @@ namespace MiraAPI.Keybinds;
/// Singleton for getting a <see cref="VanillaKeybind"/> by <see cref="ActionButton"/>. /// Singleton for getting a <see cref="VanillaKeybind"/> by <see cref="ActionButton"/>.
/// </summary> /// </summary>
/// <typeparam name="T"><see cref="ActionButton"/> type.</typeparam> /// <typeparam name="T"><see cref="ActionButton"/> type.</typeparam>
public static class VanillaKeybinding<T> where T : ActionButton public static class VanillaKeybinding<T>
where T : ActionButton
{ {
[SuppressMessage("Major Code Smell", "S2743:Static fields should not be used in generic types", Justification = "The instance holds a reference to the button that defines the class's type parameter.")] [SuppressMessage("Major Code Smell", "S2743:Static fields should not be used in generic types", Justification = "The instance holds a reference to the button that defines the class's type parameter.")]
private static VanillaKeybind? _instance; private static VanillaKeybind? _instance;
+10 -3
View File
@@ -1,6 +1,5 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using HarmonyLib; using HarmonyLib;
using MiraAPI.Hud; using MiraAPI.Hud;
using MiraAPI.Keybinds; using MiraAPI.Keybinds;
@@ -43,6 +42,7 @@ public static class HudManagerPatches
if (!_storedButtonsParent) _storedButtonsParent = HudManager.Instance.transform.FindChild("Buttons"); if (!_storedButtonsParent) _storedButtonsParent = HudManager.Instance.transform.FindChild("Buttons");
if (_storedButtonsParent) if (_storedButtonsParent)
{
foreach (var aspect in _storedButtonsParent.GetComponentsInChildren<AspectPosition>(true)) foreach (var aspect in _storedButtonsParent.GetComponentsInChildren<AspectPosition>(true))
{ {
if (!aspect.gameObject) continue; if (!aspect.gameObject) continue;
@@ -55,6 +55,7 @@ public static class HudManagerPatches
aspect.DistanceFromEdge *= new Vector2(scaleFactor, scaleFactor); aspect.DistanceFromEdge *= new Vector2(scaleFactor, scaleFactor);
aspect.gameObject.SetActive(!aspect.isActiveAndEnabled); aspect.gameObject.SetActive(!aspect.isActiveAndEnabled);
} }
}
foreach (var button in HudManager.Instance.GetComponentsInChildren<ActionButton>(true)) foreach (var button in HudManager.Instance.GetComponentsInChildren<ActionButton>(true))
{ {
@@ -181,7 +182,7 @@ public static class HudManagerPatches
{ {
ButtonLocation.BottomLeft => BottomLeft.transform, ButtonLocation.BottomLeft => BottomLeft.transform,
ButtonLocation.BottomRight => BottomRight, ButtonLocation.BottomRight => BottomRight,
_ => null _ => null,
}; };
if (location is null) continue; if (location is null) continue;
@@ -212,7 +213,7 @@ public static class HudManagerPatches
{ __instance.ReportButton.gameObject, 7 }, { __instance.ReportButton.gameObject, 7 },
{ __instance.ImpostorVentButton.gameObject, 50 }, { __instance.ImpostorVentButton.gameObject, 50 },
{ __instance.SabotageButton.gameObject, 4 }, { __instance.SabotageButton.gameObject, 4 },
{ __instance.AbilityButton.gameObject, 49 } { __instance.AbilityButton.gameObject, 49 },
}; };
foreach (var kvp in vanillaButtons) foreach (var kvp in vanillaButtons)
@@ -253,6 +254,7 @@ public static class HudManagerPatches
if (localPlayer.Data == null) return; if (localPlayer.Data == null) return;
foreach (var button in CustomButtonManager.CustomButtons) foreach (var button in CustomButtonManager.CustomButtons)
{
try try
{ {
button.SetActive(isActive, role); button.SetActive(isActive, role);
@@ -262,6 +264,7 @@ public static class HudManagerPatches
Error($"Failed to set custom button {button.GetType().Name} active: {e}"); Error($"Failed to set custom button {button.GetType().Name} active: {e}");
} }
} }
}
[HarmonyPatch(nameof(HudManager.Update))] [HarmonyPatch(nameof(HudManager.Update))]
[HarmonyPostfix] [HarmonyPostfix]
@@ -279,11 +282,15 @@ public static class HudManagerPatches
var player = ReInput.players.GetPlayer(0); var player = ReInput.players.GetPlayer(0);
foreach (var entry in KeybindManager.Keybinds) foreach (var entry in KeybindManager.Keybinds)
{
if (entry.RewiredInputAction != null && player.GetButtonDown(entry.RewiredInputAction.id)) if (entry.RewiredInputAction != null && player.GetButtonDown(entry.RewiredInputAction.id))
entry.Invoke(); entry.Invoke();
}
foreach (var entry in KeybindManager.VanillaKeybinds.Values) foreach (var entry in KeybindManager.VanillaKeybinds.Values)
{
if (player.GetButtonDown(entry.Id)) if (player.GetButtonDown(entry.Id))
entry.Invoke(); entry.Invoke();
} }
} }
}
@@ -66,7 +66,7 @@ public static class ControlMapperPatches
{ {
ControllerType.Keyboard => conflicts.ContainsKey(map.keyboardKeyCode), ControllerType.Keyboard => conflicts.ContainsKey(map.keyboardKeyCode),
ControllerType.Joystick => controllerConflicts.Any(x => x.controllerMap.id == map.controllerMap.id && x.id == map.id), ControllerType.Joystick => controllerConflicts.Any(x => x.controllerMap.id == map.controllerMap.id && x.id == map.id),
_ => false _ => false,
}; };
if (hasConflict) if (hasConflict)
{ {
+1 -1
View File
@@ -30,7 +30,7 @@ public static class KeybindMenuPatch
{ typeof(ReportButton), new VanillaKeybind(7) }, { typeof(ReportButton), new VanillaKeybind(7) },
{ typeof(VentButton), new VanillaKeybind(50) }, { typeof(VentButton), new VanillaKeybind(50) },
{ typeof(SabotageButton), new VanillaKeybind(4) }, { typeof(SabotageButton), new VanillaKeybind(4) },
{ typeof(AbilityButton), new VanillaKeybind(49) } { typeof(AbilityButton), new VanillaKeybind(49) },
}; };
} }
} }
+10 -3
View File
@@ -316,9 +316,11 @@ public static class Extensions
try try
{ {
foreach (var mat in renderer.materials) foreach (var mat in renderer.materials)
{
if (mat != null) if (mat != null)
UnityEngine.Object.Destroy(mat); UnityEngine.Object.Destroy(mat);
} }
}
catch catch
{ {
// ignored // ignored
@@ -437,6 +439,7 @@ public static class Extensions
tie = true; tie = true;
var result = new KeyValuePair<byte, int>(byte.MaxValue, int.MinValue); var result = new KeyValuePair<byte, int>(byte.MaxValue, int.MinValue);
foreach (var keyValuePair in self) foreach (var keyValuePair in self)
{
if (keyValuePair.Value > result.Value) if (keyValuePair.Value > result.Value)
{ {
result = keyValuePair; result = keyValuePair;
@@ -446,6 +449,7 @@ public static class Extensions
{ {
tie = true; tie = true;
} }
}
return result; return result;
} }
@@ -461,6 +465,7 @@ public static class Extensions
tie = true; tie = true;
var result = new KeyValuePair<byte, float>(byte.MaxValue, int.MinValue); var result = new KeyValuePair<byte, float>(byte.MaxValue, int.MinValue);
foreach (var keyValuePair in self) foreach (var keyValuePair in self)
{
if (keyValuePair.Value > result.Value) if (keyValuePair.Value > result.Value)
{ {
result = keyValuePair; result = keyValuePair;
@@ -470,6 +475,7 @@ public static class Extensions
{ {
tie = true; tie = true;
} }
}
return result; return result;
} }
@@ -687,7 +693,8 @@ public static class Extensions
/// <param name="predicate">Optional predicate to test if the <typeparamref name="T"/> is valid.</param> /// <param name="predicate">Optional predicate to test if the <typeparamref name="T"/> is valid.</param>
/// <typeparam name="T">The type of the object.</typeparam> /// <typeparam name="T">The type of the object.</typeparam>
/// <returns>The <typeparamref name="T"/> if it was found, or <see langword="null"/> if there is none within the radius.</returns> /// <returns>The <typeparamref name="T"/> if it was found, or <see langword="null"/> if there is none within the radius.</returns>
public static T? GetNearestObjectOfType<T>(this PlayerControl playerControl, float radius, ContactFilter2D filter, string? colliderTag = null, Predicate<T>? predicate = null) where T : Component public static T? GetNearestObjectOfType<T>(this PlayerControl playerControl, float radius, ContactFilter2D filter, string? colliderTag = null, Predicate<T>? predicate = null)
where T : Component
{ {
return Helpers.GetNearestObjectsOfType<T>(playerControl.GetTruePosition(), radius, filter, colliderTag).Find(predicate ?? (component => component)); return Helpers.GetNearestObjectsOfType<T>(playerControl.GetTruePosition(), radius, filter, colliderTag).Find(predicate ?? (component => component));
} }
@@ -709,7 +716,7 @@ public static class Extensions
} }
/// <summary> /// <summary>
/// Fixed version of <see cref="Reactor.Utilities.Extensions.UnityExtensions.SetOutline(Renderer, Color?)"/>. /// Fixed version of <see cref="UnityExtensions.SetOutline(Renderer, Color?)"/>.
/// </summary> /// </summary>
/// <param name="renderer">The <see cref="Renderer"/> you want to update the outline for.</param> /// <param name="renderer">The <see cref="Renderer"/> you want to update the outline for.</param>
/// <param name="color">The outline <see cref="Color"/>.</param> /// <param name="color">The outline <see cref="Color"/>.</param>
@@ -752,7 +759,7 @@ public static class Extensions
_actionId = action.id, _actionId = action.id,
_elementType = ControllerElementType.Button, _elementType = ControllerElementType.Button,
_axisContribution = Pole.Positive, _axisContribution = Pole.Positive,
_keyboardKeyCode = key _keyboardKeyCode = key,
}; };
if (modifiers != null) if (modifiers != null)