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 MiraAPI.Events;
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.Joystick => Keybind.CurrentControllerButton,
_ => string.Empty
_ => string.Empty,
};
KeybindText.text = text;
@@ -516,7 +516,8 @@ public abstract class CustomActionButton
/// Custom action button that has a target <typeparamref name="T"/>.
/// </summary>
/// <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>
/// Gets or sets the target <typeparamref name="T"/> of the button.
+5 -2
View File
@@ -17,7 +17,8 @@ public static class KeybindManager
/// </summary>
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()
{
@@ -63,7 +64,7 @@ public static class KeybindManager
_elementIdentifierId = elementId,
_elementType = elementType,
_axisRange = AxisRange.Positive,
_axisContribution = Pole.Positive
_axisContribution = Pole.Positive,
});
}
}
@@ -154,8 +155,10 @@ public static class KeybindManager
{
var all = new List<MiraKeybind>();
foreach (var keybind in Keybinds)
{
if (keybind.CurrentKey == keyCode && (keybind.Exclusive || !exclusiveCheck))
all.Add(keybind);
}
return [.. all];
}
+1 -1
View File
@@ -40,7 +40,7 @@ public static class KeybindUtils
"square" => "□",
"circle" => "○",
"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="modifierKeys">Up to 3 optional <see cref="ModifierKey"/>s for the keyboard binding.</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;
}
+2 -1
View File
@@ -6,7 +6,8 @@ namespace MiraAPI.Keybinds;
/// Singleton for getting a <see cref="VanillaKeybind"/> by <see cref="ActionButton"/>.
/// </summary>
/// <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.")]
private static VanillaKeybind? _instance;
+10 -3
View File
@@ -1,6 +1,5 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using HarmonyLib;
using MiraAPI.Hud;
using MiraAPI.Keybinds;
@@ -43,6 +42,7 @@ public static class HudManagerPatches
if (!_storedButtonsParent) _storedButtonsParent = HudManager.Instance.transform.FindChild("Buttons");
if (_storedButtonsParent)
{
foreach (var aspect in _storedButtonsParent.GetComponentsInChildren<AspectPosition>(true))
{
if (!aspect.gameObject) continue;
@@ -55,6 +55,7 @@ public static class HudManagerPatches
aspect.DistanceFromEdge *= new Vector2(scaleFactor, scaleFactor);
aspect.gameObject.SetActive(!aspect.isActiveAndEnabled);
}
}
foreach (var button in HudManager.Instance.GetComponentsInChildren<ActionButton>(true))
{
@@ -181,7 +182,7 @@ public static class HudManagerPatches
{
ButtonLocation.BottomLeft => BottomLeft.transform,
ButtonLocation.BottomRight => BottomRight,
_ => null
_ => null,
};
if (location is null) continue;
@@ -212,7 +213,7 @@ public static class HudManagerPatches
{ __instance.ReportButton.gameObject, 7 },
{ __instance.ImpostorVentButton.gameObject, 50 },
{ __instance.SabotageButton.gameObject, 4 },
{ __instance.AbilityButton.gameObject, 49 }
{ __instance.AbilityButton.gameObject, 49 },
};
foreach (var kvp in vanillaButtons)
@@ -253,6 +254,7 @@ public static class HudManagerPatches
if (localPlayer.Data == null) return;
foreach (var button in CustomButtonManager.CustomButtons)
{
try
{
button.SetActive(isActive, role);
@@ -261,6 +263,7 @@ public static class HudManagerPatches
{
Error($"Failed to set custom button {button.GetType().Name} active: {e}");
}
}
}
[HarmonyPatch(nameof(HudManager.Update))]
@@ -279,11 +282,15 @@ public static class HudManagerPatches
var player = ReInput.players.GetPlayer(0);
foreach (var entry in KeybindManager.Keybinds)
{
if (entry.RewiredInputAction != null && player.GetButtonDown(entry.RewiredInputAction.id))
entry.Invoke();
}
foreach (var entry in KeybindManager.VanillaKeybinds.Values)
{
if (player.GetButtonDown(entry.Id))
entry.Invoke();
}
}
}
@@ -66,7 +66,7 @@ public static class ControlMapperPatches
{
ControllerType.Keyboard => conflicts.ContainsKey(map.keyboardKeyCode),
ControllerType.Joystick => controllerConflicts.Any(x => x.controllerMap.id == map.controllerMap.id && x.id == map.id),
_ => false
_ => false,
};
if (hasConflict)
{
+1 -1
View File
@@ -30,7 +30,7 @@ public static class KeybindMenuPatch
{ typeof(ReportButton), new VanillaKeybind(7) },
{ typeof(VentButton), new VanillaKeybind(50) },
{ typeof(SabotageButton), new VanillaKeybind(4) },
{ typeof(AbilityButton), new VanillaKeybind(49) }
{ typeof(AbilityButton), new VanillaKeybind(49) },
};
}
}
+10 -3
View File
@@ -316,8 +316,10 @@ public static class Extensions
try
{
foreach (var mat in renderer.materials)
{
if (mat != null)
UnityEngine.Object.Destroy(mat);
}
}
catch
{
@@ -437,6 +439,7 @@ public static class Extensions
tie = true;
var result = new KeyValuePair<byte, int>(byte.MaxValue, int.MinValue);
foreach (var keyValuePair in self)
{
if (keyValuePair.Value > result.Value)
{
result = keyValuePair;
@@ -446,6 +449,7 @@ public static class Extensions
{
tie = true;
}
}
return result;
}
@@ -461,6 +465,7 @@ public static class Extensions
tie = true;
var result = new KeyValuePair<byte, float>(byte.MaxValue, int.MinValue);
foreach (var keyValuePair in self)
{
if (keyValuePair.Value > result.Value)
{
result = keyValuePair;
@@ -470,6 +475,7 @@ public static class Extensions
{
tie = true;
}
}
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>
/// <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>
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));
}
@@ -709,7 +716,7 @@ public static class Extensions
}
/// <summary>
/// Fixed version of <see cref="Reactor.Utilities.Extensions.UnityExtensions.SetOutline(Renderer, Color?)"/>.
/// Fixed version of <see cref="UnityExtensions.SetOutline(Renderer, Color?)"/>.
/// </summary>
/// <param name="renderer">The <see cref="Renderer"/> you want to update the outline for.</param>
/// <param name="color">The outline <see cref="Color"/>.</param>
@@ -752,7 +759,7 @@ public static class Extensions
_actionId = action.id,
_elementType = ControllerElementType.Button,
_axisContribution = Pole.Positive,
_keyboardKeyCode = key
_keyboardKeyCode = key,
};
if (modifiers != null)