From 0a4f2f84b1b4ed85d61c70193d42ed7cf9eea290 Mon Sep 17 00:00:00 2001 From: Az <56699741+AlchlcDvl@users.noreply.github.com> Date: Wed, 18 Nov 2026 03:38:46 -0500 Subject: [PATCH] several more options improvements --- MiraAPI/GameModes/HideAndSeekMode.cs | 2 +- .../Attributes/ModdedEnumOptionAttribute.cs | 2 +- .../ModdedEnumOptionListAttribute.cs | 2 +- MiraAPI/GameOptions/ModdedOptionsManager.cs | 4 +- .../OptionTypes/ModdedEnumOption.cs | 4 +- .../OptionTypes/ModdedNumberOption.cs | 2 +- .../GameOptions/OptionTypes/ModdedOption.cs | 39 +++++-- .../OptionTypes/ModdedPlayerOption.cs | 2 +- .../OptionTypes/ModdedStringOption.cs | 2 +- .../OptionTypes/ModdedToggleOption.cs | 2 +- .../HnsReimplemented/HideAndSeekHudHelper.cs | 10 +- MiraAPI/HnsReimplemented/HnsDangerMeter.cs | 2 +- MiraAPI/HnsReimplemented/HnsMusicHandler.cs | 2 +- .../Options/HnsCrewmateOptions.cs | 102 ++++++------------ .../Options/HnsFinalHideOptions.cs | 56 ++++------ .../Options/HnsImpostorOptions.cs | 41 +++---- .../Options/HnsTaskOptions.cs | 42 +++----- MiraAPI/Modifiers/BaseModifier.cs | 1 - MiraAPI/Resources/Locale/en_US.xml | 33 +++++- MiraAPI/Roles/CustomRoleConfiguration.cs | 1 - 20 files changed, 156 insertions(+), 195 deletions(-) diff --git a/MiraAPI/GameModes/HideAndSeekMode.cs b/MiraAPI/GameModes/HideAndSeekMode.cs index 6e0666ac..922e5449 100644 --- a/MiraAPI/GameModes/HideAndSeekMode.cs +++ b/MiraAPI/GameModes/HideAndSeekMode.cs @@ -73,7 +73,7 @@ public class HideAndSeekMode : AbstractGameMode private static int ImpostorPlayerID() { - return OptionGroupSingleton.Instance.SelectedSeeker.Value; + return OptionGroupSingleton.Instance.SelectedSeeker; } private static bool HasImpostorPlayerID() diff --git a/MiraAPI/GameOptions/Attributes/ModdedEnumOptionAttribute.cs b/MiraAPI/GameOptions/Attributes/ModdedEnumOptionAttribute.cs index 71c80288..65fc5366 100644 --- a/MiraAPI/GameOptions/Attributes/ModdedEnumOptionAttribute.cs +++ b/MiraAPI/GameOptions/Attributes/ModdedEnumOptionAttribute.cs @@ -65,7 +65,7 @@ public class ModdedEnumOptionAttribute(string? title, Type enumType, string idPr public override object GetValue() { return HolderOption is ModdedEnumOption opt - ? Enum.ToObject(enumType, opt.Value) + ? Enum.ToObject(enumType, opt.UnderlyingValues[opt.Value]) : throw new InvalidOperationException($"HolderOption for option \"{Title}\" is not a ModdedEnumOption with enum type {enumType.FullName}"); } } diff --git a/MiraAPI/GameOptions/Attributes/OptionList/ModdedEnumOptionListAttribute.cs b/MiraAPI/GameOptions/Attributes/OptionList/ModdedEnumOptionListAttribute.cs index 7ff422a7..3539de35 100644 --- a/MiraAPI/GameOptions/Attributes/OptionList/ModdedEnumOptionListAttribute.cs +++ b/MiraAPI/GameOptions/Attributes/OptionList/ModdedEnumOptionListAttribute.cs @@ -67,7 +67,7 @@ public class ModdedEnumOptionListAttribute(string? title, Type enumType, string public override object GetValue(int idx) { return HolderOptionList?.ElementAt(idx) is ModdedEnumOption opt - ? Enum.ToObject(enumType, opt.Value) + ? Enum.ToObject(enumType, opt.UnderlyingValues[opt.Value]) : throw new InvalidOperationException($"HolderOption for option \"{Titles[idx]}\" is not a ModdedEnumOption with enum type {enumType.FullName}"); } } diff --git a/MiraAPI/GameOptions/ModdedOptionsManager.cs b/MiraAPI/GameOptions/ModdedOptionsManager.cs index c7f607cc..b030c2c8 100644 --- a/MiraAPI/GameOptions/ModdedOptionsManager.cs +++ b/MiraAPI/GameOptions/ModdedOptionsManager.cs @@ -428,7 +428,7 @@ public static class ModdedOptionsManager /// The new object value. [SuppressMessage("ReSharper", "InconsistentNaming", Justification = "Harmony naming convention.")] [SuppressMessage("Naming", "CA1707:Identifiers should not contain underscores", Justification = "Read above.")] - [Obsolete("Use PropertySetterPatch instead. This will be removed in a future version.")] + [Obsolete("Use PropertySetterPatch instead. This will be removed in a future version.", true)] public static void PropertySetterPatch(MethodBase __originalMethod, object value) { if (!SetterLookup.TryGetValue(__originalMethod.MethodHandle, out var attribute)) @@ -470,7 +470,7 @@ public static class ModdedOptionsManager /// so the original getter gets skipped. [SuppressMessage("ReSharper", "InconsistentNaming", Justification = "Harmony naming convention")] [SuppressMessage("Naming", "CA1707:Identifiers should not contain underscores", Justification = "Read above.")] - [Obsolete("Use PropertyGetterPatch instead. This will be removed in a future version.")] + [Obsolete("Use PropertyGetterPatch instead. This will be removed in a future version.", true)] public static bool PropertyGetterPatch(MethodBase __originalMethod, ref object __result) { if (!GetterLookup.TryGetValue(__originalMethod.MethodHandle, out var attribute)) diff --git a/MiraAPI/GameOptions/OptionTypes/ModdedEnumOption.cs b/MiraAPI/GameOptions/OptionTypes/ModdedEnumOption.cs index 0aa2a45f..9d80dac6 100644 --- a/MiraAPI/GameOptions/OptionTypes/ModdedEnumOption.cs +++ b/MiraAPI/GameOptions/OptionTypes/ModdedEnumOption.cs @@ -101,7 +101,7 @@ public class ModdedEnumOption : ModdedBaseEnumOption /// public override NetData GetNetData() { - return new(Id, BitConverter.GetBytes(Value)); + return new(Id, BitConverter.GetBytes(_value)); } /// @@ -186,7 +186,7 @@ public class ModdedEnumOption : ModdedBaseEnumOption public override NetData GetNetData() { var buffer = new byte[Unsafe.SizeOf()]; - Unsafe.WriteUnaligned(ref buffer[0], Value); + Unsafe.WriteUnaligned(ref buffer[0], _value); return new(Id, buffer); } diff --git a/MiraAPI/GameOptions/OptionTypes/ModdedNumberOption.cs b/MiraAPI/GameOptions/OptionTypes/ModdedNumberOption.cs index 532b256b..2361eed7 100644 --- a/MiraAPI/GameOptions/OptionTypes/ModdedNumberOption.cs +++ b/MiraAPI/GameOptions/OptionTypes/ModdedNumberOption.cs @@ -282,7 +282,7 @@ public class ModdedNumberOption : ModdedOption /// public override NetData GetNetData() { - return new NetData(Id, BitConverter.GetBytes(Value)); + return new NetData(Id, BitConverter.GetBytes(_value)); } /// diff --git a/MiraAPI/GameOptions/OptionTypes/ModdedOption.cs b/MiraAPI/GameOptions/OptionTypes/ModdedOption.cs index 2e14f8fa..eb1bcb33 100644 --- a/MiraAPI/GameOptions/OptionTypes/ModdedOption.cs +++ b/MiraAPI/GameOptions/OptionTypes/ModdedOption.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using BepInEx.Configuration; using MiraAPI.Networking; using MiraAPI.PluginLoading; @@ -14,20 +15,16 @@ namespace MiraAPI.GameOptions.OptionTypes; /// Represents a modded option. /// /// The value type. -/// The translation ID prefix of the group containing this option. -/// The option title. -/// The default value. -/// Whether to include the option in the preset. -public abstract class ModdedOption(string groupPrefix, string title, T defaultValue, bool includeInPreset = true) : IModdedOption +public abstract class ModdedOption : IModdedOption { /// public uint Id { get; } = ModdedOptionsManager.NextId; /// - public string Title { get; set; } = groupPrefix + title; + public string Title { get; set; } /// - public StringNames StringName { get; } = MiraLocaleManager.GetOrCreateLocaleString(groupPrefix + title); + public StringNames StringName { get; } /// /// Gets or sets the value of the option. @@ -46,18 +43,23 @@ public abstract class ModdedOption(string groupPrefix, string title, T defaul } } - private T _value = defaultValue; + /// + /// The backing value field. Use only for raw and quick comparisons, otherwise use . + /// + [SuppressMessage("Design", "CA1051:Do not declare visible instance fields", Justification = "Useful for raw checks that do not need modifications upon read or write.")] + [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:Fields should be private", Justification = "Read above.")] + protected T _value; /// /// Gets the default value of the option. /// - public T DefaultValue { get; } = defaultValue; + public T DefaultValue { get; } /// public Func Visible { get; set; } = DelegateUtilities.AlwaysTrue; /// - public bool IncludeInPreset { get; set; } = includeInPreset; + public bool IncludeInPreset { get; set; } /// public bool ShowNotification { get; set; } = true; @@ -121,6 +123,23 @@ public abstract class ModdedOption(string groupPrefix, string title, T defaul /// public virtual OptionNotifConfiguration Configuration => new(ParentGroup); + /// + /// Initializes a new instance of the class. + /// + /// The translation ID prefix of the group containing this option. + /// The option title. + /// The default value. + /// Whether to include the option in the preset. + protected ModdedOption(string groupPrefix, string title, T defaultValue, bool includeInPreset = true) + { + var translationId = groupPrefix + title; + + Title = translationId; + StringName = MiraLocaleManager.GetOrCreateLocaleString(translationId); + DefaultValue = _value = defaultValue; + IncludeInPreset = includeInPreset; + } + /// /// Initializes a new instance of the class. /// diff --git a/MiraAPI/GameOptions/OptionTypes/ModdedPlayerOption.cs b/MiraAPI/GameOptions/OptionTypes/ModdedPlayerOption.cs index f9ec5a00..870826cb 100644 --- a/MiraAPI/GameOptions/OptionTypes/ModdedPlayerOption.cs +++ b/MiraAPI/GameOptions/OptionTypes/ModdedPlayerOption.cs @@ -129,7 +129,7 @@ public class ModdedPlayerOption : ModdedOption /// public override NetData GetNetData() { - return new NetData(Id, BitConverter.GetBytes(Value)); + return new NetData(Id, BitConverter.GetBytes(_value)); } /// diff --git a/MiraAPI/GameOptions/OptionTypes/ModdedStringOption.cs b/MiraAPI/GameOptions/OptionTypes/ModdedStringOption.cs index 868d165b..55932286 100644 --- a/MiraAPI/GameOptions/OptionTypes/ModdedStringOption.cs +++ b/MiraAPI/GameOptions/OptionTypes/ModdedStringOption.cs @@ -98,7 +98,7 @@ public class ModdedStringOption : ModdedBaseStringOption /// public override NetData GetNetData() { - return new NetData(Id, Encoding.Unicode.GetBytes(Value)); + return new NetData(Id, Encoding.Unicode.GetBytes(_value)); } /// diff --git a/MiraAPI/GameOptions/OptionTypes/ModdedToggleOption.cs b/MiraAPI/GameOptions/OptionTypes/ModdedToggleOption.cs index c1089f8f..436dc81e 100644 --- a/MiraAPI/GameOptions/OptionTypes/ModdedToggleOption.cs +++ b/MiraAPI/GameOptions/OptionTypes/ModdedToggleOption.cs @@ -118,7 +118,7 @@ public class ModdedToggleOption : ModdedOption /// public override NetData GetNetData() { - return new NetData(Id, BitConverter.GetBytes(Value)); + return new NetData(Id, BitConverter.GetBytes(_value)); } /// diff --git a/MiraAPI/HnsReimplemented/HideAndSeekHudHelper.cs b/MiraAPI/HnsReimplemented/HideAndSeekHudHelper.cs index 89347e01..8f2aa513 100644 --- a/MiraAPI/HnsReimplemented/HideAndSeekHudHelper.cs +++ b/MiraAPI/HnsReimplemented/HideAndSeekHudHelper.cs @@ -69,7 +69,7 @@ public sealed class HideAndSeekHudHelper(nint cppPtr) : MonoBehaviour(cppPtr) var item = Helpers.GetAlivePlayers().Count(x => !x.Data.Role.IsImpostor); return !player.inVent && player.Data != null && player.Data.Role != null && ((!player.inVent && player.Data.Role.IsImpostor && IsFinalCountdown && - OptionGroupSingleton.Instance.FinalHideSeekMap.Value) || + OptionGroupSingleton.Instance.FinalHideSeekMap) || (player.Data.Role.IsImpostor && item <= (GameData.Instance.PlayerCount - 1) / 3)); @@ -95,8 +95,8 @@ public sealed class HideAndSeekHudHelper(nint cppPtr) : MonoBehaviour(cppPtr) /// The match duration in seconds. public static float GetTotalRoundTime() { - var escapeTime = OptionGroupSingleton.Instance.HidingTime.Value; - var finalCountdownTime = OptionGroupSingleton.Instance.FinalHideTime.Value; + var escapeTime = OptionGroupSingleton.Instance.HidingTime; + var finalCountdownTime = OptionGroupSingleton.Instance.FinalHideTime; return escapeTime + finalCountdownTime; } @@ -120,9 +120,9 @@ public sealed class HideAndSeekHudHelper(nint cppPtr) : MonoBehaviour(cppPtr) private void Start() { - totalHideTime = OptionGroupSingleton.Instance.HidingTime.Value; + totalHideTime = OptionGroupSingleton.Instance.HidingTime; currentHideTime = totalHideTime; - totalFinalHideTime = OptionGroupSingleton.Instance.FinalHideTime.Value; + totalFinalHideTime = OptionGroupSingleton.Instance.FinalHideTime; currentFinalHideTime = totalFinalHideTime; if (timerBar != null) { diff --git a/MiraAPI/HnsReimplemented/HnsDangerMeter.cs b/MiraAPI/HnsReimplemented/HnsDangerMeter.cs index 45de15f8..f831af4d 100644 --- a/MiraAPI/HnsReimplemented/HnsDangerMeter.cs +++ b/MiraAPI/HnsReimplemented/HnsDangerMeter.cs @@ -137,7 +137,7 @@ public sealed class HnsDangerMeter(nint cppPtr) : MonoBehaviour(cppPtr) impostors = [.. Helpers.GetAlivePlayers().Where(x => x.Data.Role.IsImpostor)]; - var baseSpeed = OptionGroupSingleton.Instance.PlayerSpeed.Value; + var baseSpeed = OptionGroupSingleton.Instance.PlayerSpeed; scaryMusicDistance = 55f * baseSpeed; veryScaryMusicDistance = 15f * baseSpeed; if (scaryMusicDistance >= veryScaryMusicDistance) return; diff --git a/MiraAPI/HnsReimplemented/HnsMusicHandler.cs b/MiraAPI/HnsReimplemented/HnsMusicHandler.cs index 76c4a251..cf4524e7 100644 --- a/MiraAPI/HnsReimplemented/HnsMusicHandler.cs +++ b/MiraAPI/HnsReimplemented/HnsMusicHandler.cs @@ -145,7 +145,7 @@ public sealed class HnsMusicHandler(nint cppPtr) : MonoBehaviour(cppPtr) public void StartMusicWithIntro() { if (!PlayerControl.LocalPlayer.Data.Role.IsImpostor) return; - var clip = OptionGroupSingleton.Instance.HidingTime.Value <= 180f + var clip = OptionGroupSingleton.Instance.HidingTime <= 180f ? musicCollection.ImpostorShortMusic : musicCollection.ImpostorLongMusic; if (AprilFoolsMode.ShouldHorseAround()) diff --git a/MiraAPI/HnsReimplemented/Options/HnsCrewmateOptions.cs b/MiraAPI/HnsReimplemented/Options/HnsCrewmateOptions.cs index 2093c545..b9fe3a53 100644 --- a/MiraAPI/HnsReimplemented/Options/HnsCrewmateOptions.cs +++ b/MiraAPI/HnsReimplemented/Options/HnsCrewmateOptions.cs @@ -1,5 +1,6 @@ using MiraAPI.GameModes; using MiraAPI.GameOptions; +using MiraAPI.GameOptions.Attributes; using MiraAPI.GameOptions.OptionTypes; using MiraAPI.Utilities; @@ -9,108 +10,67 @@ namespace MiraAPI.HnsReimplemented.Options; /// Crewmate options for Hide and Seek. /// // ReSharper disable once ClassNeverInstantiated.Global (Justification: Instantiated via Activator.CreateInstance.) +[SearchPrivate] public class HnsCrewmateOptions : AbstractOptionGroup { /// - public override string GroupName => "Crewmates"; + public override string GroupName => "MiraApi.Option.Group.HnsCrewmate"; + + /// + public override string GroupPrefix => "MiraApi.HnsCrewmate.Option."; /// /// Gets the player speed. /// - public ModdedNumberOption PlayerSpeed { get; } = new( - "Player Speed", - 1f, - 0.5f, - 3f, - 0.25f, - "#", - "#", - MiraNumberSuffixes.Multiplier, - "0.00"); + [ModdedNumberOption(0.5f, 3f, 0.25f, "#", "#", MiraNumberSuffixes.Multiplier, "0.00")] + public float PlayerSpeed { get; } = 1f; /// /// Gets the hiding time. /// - public ModdedNumberOption HidingTime { get; } = new( - "Hiding Time", - 200, - 160, - 300, - 20, - "#", - "#", - MiraNumberSuffixes.Seconds); + [ModdedNumberOption(160, 300, 20, "#", "#", MiraNumberSuffixes.Seconds)] + public float HidingTime { get; } = 200f; /// /// Gets the limits of a crewmate's vision. /// - public ModdedNumberOption CrewmateVision { get; } = new( - "Crewmate Vision", - 0.6f, - 0.25f, - 1, - 0.05f, - "#", - "#", - MiraNumberSuffixes.Multiplier, - "0.00"); + [ModdedNumberOption(0.25f, 1, 0.05f, "#", "#", MiraNumberSuffixes.Multiplier, "0.00")] + public float CrewmateVision { get; } = 0.6f; /// - /// Gets a flag that toggles flashlight vision. + /// Gets a value indicating whether flashlight vision is turned on or not. /// - public ModdedToggleOption FlashlightMode { get; } = new( - "Flashlight Mode", - true); + [ModdedToggleOption] + public bool FlashlightMode { get; } = true; /// /// Gets the range of a crewmate's flashlight. /// - public ModdedNumberOption CrewmateFlashlightSize { get; } = new( - "Crewmate Flashlight Size", - 0.35f, - 0.1f, - 0.5f, - 0.05f, - "#", - "#", - MiraNumberSuffixes.Multiplier) - { - Visible = () => OptionGroupSingleton.Instance.FlashlightMode.Value, - }; + [ModdedNumberOption(0.1f, 0.5f, 0.05f, "#", "#", MiraNumberSuffixes.Multiplier)] + [ModdedOptionVisibility(nameof(FlashlightMode))] + public float CrewmateFlashlightSize { get; } = 0.35f; /// /// Gets the maximum number of times a crewmate can vent. /// - public ModdedNumberOption MaxVentUses { get; } = new( - "Max Vent Uses", - 1, - 0, - 5, - 1, - "#", - "#", - MiraNumberSuffixes.None); + [ModdedNumberOption(0, 5, 1, "#", "#", MiraNumberSuffixes.None)] + public int MaxVentUses { get; } = 1; /// /// Gets the maximum amount of time a crewmate can spend inside a vent. /// - public ModdedNumberOption MaxTimeInVent { get; } = new( - "Max Time in Vent", - 3, - 1, - 10, - 1, - "#", - "#", - MiraNumberSuffixes.Seconds) - { - Visible = () => (int)OptionGroupSingleton.Instance.MaxVentUses.Value > 0, - }; + [ModdedNumberOption(1, 10, 1, "#", "#", MiraNumberSuffixes.Seconds)] + [ModdedOptionVisibility(nameof(LimitedVentUses))] + public float MaxTimeInVent { get; } = 3f; /// - /// Gets the visibility of player names. + /// Gets a value indicating whether player names are visible. /// - public ModdedToggleOption ShowNames { get; } = new( - "Show Names", - false); + [ModdedToggleOption] + public bool ShowNames { get; } = false; + + private bool LimitedVentUses() + { + return MaxVentUses > 0; + } } diff --git a/MiraAPI/HnsReimplemented/Options/HnsFinalHideOptions.cs b/MiraAPI/HnsReimplemented/Options/HnsFinalHideOptions.cs index e7739eaa..4d01ecd1 100644 --- a/MiraAPI/HnsReimplemented/Options/HnsFinalHideOptions.cs +++ b/MiraAPI/HnsReimplemented/Options/HnsFinalHideOptions.cs @@ -1,5 +1,6 @@ using MiraAPI.GameModes; using MiraAPI.GameOptions; +using MiraAPI.GameOptions.Attributes; using MiraAPI.GameOptions.OptionTypes; using MiraAPI.Utilities; @@ -9,62 +10,43 @@ namespace MiraAPI.HnsReimplemented.Options; /// Final Hide options for Hide and Seek. /// // ReSharper disable once ClassNeverInstantiated.Global (Justification: Instantiated via Activator.CreateInstance.) +[SearchPrivate] public class HnsFinalHideOptions : AbstractOptionGroup { /// - public override string GroupName => "Final Hide"; + public override string GroupName => "MiraApi.Option.Group.HnsFinalHide"; + + /// + public override string GroupPrefix => "MiraApi.HnsFinalHide.Option."; /// /// Gets the duration of the Final Hide phase. /// - public ModdedNumberOption FinalHideTime { get; } = new( - "Hiding Time", - 50, - 30, - 120, - 5, - "#", - "#", - MiraNumberSuffixes.Seconds); + [ModdedNumberOption(30f, 120f, 5f, "#", "#", MiraNumberSuffixes.Seconds)] + public float FinalHideTime { get; } = 50f; /// /// Gets the Seeker's speed when the Final Hide phase begins. /// - public ModdedNumberOption FinalHideImpostorSpeed { get; } = new( - "Final Hide Impostor Speed", - 1.2f, - 1f, - 3, - 0.05f, - "#", - "#", - MiraNumberSuffixes.Multiplier, - "0.00"); + [ModdedNumberOption(1f, 3f, 0.05f, "#", "#", MiraNumberSuffixes.Multiplier, "0.00")] + public float FinalHideImpostorSpeed { get; } = 1.2f; /// - /// Gets whether the Seeker sees the Final hide player pings. + /// Gets a value indicating whether the Seeker sees the Final hide player pings. /// - public ModdedToggleOption FinalHidePings { get; } = new( - "Final Hide Pings", - true); + [ModdedToggleOption] + public bool FinalHidePings { get; } = true; /// /// Gets the interval between each ping. /// - public ModdedNumberOption PingInterval { get; } = new( - "Ping Interval", - 6, - 3, - 10, - 5, - "#", - "#", - MiraNumberSuffixes.Seconds); + [ModdedNumberOption(3f, 10f, 5f, "#", "#", MiraNumberSuffixes.Seconds)] + [ModdedOptionVisibility(nameof(FinalHidePings))] + public float PingInterval { get; } = 6f; /// - /// Gets whether the Seeker can see players on an admin map. + /// Gets a value indicating whether the Seeker can see players on an admin map. /// - public ModdedToggleOption FinalHideSeekMap { get; } = new( - "Final Hide Seek Map", - true); + [ModdedToggleOption] + public bool FinalHideSeekMap { get; } = true; } diff --git a/MiraAPI/HnsReimplemented/Options/HnsImpostorOptions.cs b/MiraAPI/HnsReimplemented/Options/HnsImpostorOptions.cs index c2df43bc..6e668a48 100644 --- a/MiraAPI/HnsReimplemented/Options/HnsImpostorOptions.cs +++ b/MiraAPI/HnsReimplemented/Options/HnsImpostorOptions.cs @@ -1,5 +1,6 @@ using MiraAPI.GameModes; using MiraAPI.GameOptions; +using MiraAPI.GameOptions.Attributes; using MiraAPI.GameOptions.OptionTypes; using MiraAPI.Utilities; @@ -9,44 +10,36 @@ namespace MiraAPI.HnsReimplemented.Options; /// Seeker settings on Hide and Seek. /// // ReSharper disable once ClassNeverInstantiated.Global (Justification: Instantiated via Activator.CreateInstance.) +[SearchPrivate] public class HnsImpostorOptions : AbstractOptionGroup { /// - public override string GroupName => "Impostors"; + public override string GroupName => "MiraApi.Option.Group.HnsImpostor"; + + /// + public override string GroupPrefix => "MiraApi.HnsImpostor.Option."; /// /// Gets the player who will be the seeker. /// - public ModdedPlayerOption SelectedSeeker { get; } = new( - "Forced Impostor"); + [ModdedPlayerOption] + public int SelectedSeeker { get; } = 0; /// /// Gets the range of a seeker's vision. /// - public ModdedNumberOption ImpostorVision { get; } = new( - "Impostor Vision", - 0.6f, - 0.25f, - 1, - 0.05f, - "#", - "#", - MiraNumberSuffixes.Multiplier, - "0.00"); + [ModdedNumberOption(0.25f, 1f, 0.05f, "#", "#", MiraNumberSuffixes.Multiplier, "0.00")] + public float ImpostorVision { get; } = 0.6f; /// /// Gets the range of a seeker's flashlight. /// - public ModdedNumberOption ImpostorFlashlightSize { get; } = new( - "Impostor Flashlight Size", - 0.35f, - 0.1f, - 0.5f, - 0.05f, - "#", - "#", - MiraNumberSuffixes.Multiplier) + [ModdedNumberOption(0.1f, 0.5f, 0.05f, "#", "#", MiraNumberSuffixes.Multiplier)] + [ModdedOptionVisibility(nameof(IsFlashlightModeEnabled))] + public float ImpostorFlashlightSize { get; } = 0.35f; + + private static bool IsFlashlightModeEnabled() { - Visible = () => OptionGroupSingleton.Instance.FlashlightMode.Value, - }; + return OptionGroupSingleton.Instance.FlashlightMode; + } } diff --git a/MiraAPI/HnsReimplemented/Options/HnsTaskOptions.cs b/MiraAPI/HnsReimplemented/Options/HnsTaskOptions.cs index 723de1ab..c0ccc97b 100644 --- a/MiraAPI/HnsReimplemented/Options/HnsTaskOptions.cs +++ b/MiraAPI/HnsReimplemented/Options/HnsTaskOptions.cs @@ -1,5 +1,6 @@ using MiraAPI.GameModes; using MiraAPI.GameOptions; +using MiraAPI.GameOptions.Attributes; using MiraAPI.GameOptions.OptionTypes; using MiraAPI.Utilities; @@ -9,47 +10,30 @@ namespace MiraAPI.HnsReimplemented.Options; /// Task options for Hide and Seek. /// // ReSharper disable once ClassNeverInstantiated.Global (Justification: Instantiated via Activator.CreateInstance.) +[SearchPrivate] public class HnsTaskOptions : AbstractOptionGroup { /// - public override string GroupName => "Tasks"; + public override string GroupName => "MiraApi.Option.Group.HnsTask"; + + /// + public override string GroupPrefix => "MiraApi.HnsTask.Option."; /// - /// Gets the umber of common tasks. + /// Gets the number of common tasks. /// - public ModdedNumberOption CommonTasks { get; } = new( - "# Common Tasks", - 1, - 0, - 4, - 1, - "#", - "#", - MiraNumberSuffixes.None); + [ModdedNumberOption(0, 4, 1, "#", "#", MiraNumberSuffixes.None)] + public int CommonTasks { get; } = 1; /// /// Gets the number of long tasks. /// - public ModdedNumberOption LongTasks { get; } = new( - "# Long Tasks", - 1, - 0, - 4, - 1, - "#", - "#", - MiraNumberSuffixes.None); + [ModdedNumberOption(0, 4, 1, "#", "#", MiraNumberSuffixes.None)] + public int LongTasks { get; } = 1; /// /// Gets the number of short tasks. /// - public ModdedNumberOption ShortTasks { get; } = new( - "# Short Tasks", - 2, - 0, - 8, - 1, - "#", - "#", - MiraNumberSuffixes.None); + [ModdedNumberOption(0, 8, 1, "#", "#", MiraNumberSuffixes.None)] + public int ShortTasks { get; } = 2; } diff --git a/MiraAPI/Modifiers/BaseModifier.cs b/MiraAPI/Modifiers/BaseModifier.cs index 4a4cac58..a0e4021f 100644 --- a/MiraAPI/Modifiers/BaseModifier.cs +++ b/MiraAPI/Modifiers/BaseModifier.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Globalization; -using Il2CppInterop.Runtime.Attributes; using MiraAPI.GameOptions; using MiraAPI.PluginLoading; using MiraAPI.Roles; diff --git a/MiraAPI/Resources/Locale/en_US.xml b/MiraAPI/Resources/Locale/en_US.xml index a372dde1..7bca2ae2 100644 --- a/MiraAPI/Resources/Locale/en_US.xml +++ b/MiraAPI/Resources/Locale/en_US.xml @@ -26,11 +26,9 @@ Apply game settings for this mod! Gamemode Classic - The classic Among Us experience! -Find the Impostors or deceive the Crew. + The classic Among Us experience![nl]Find the Impostors or deceive the Crew. Hide n Seek - You can run, but you can't hide! -Outlive the timer or eliminate the crew. + You can run, but you can't hide![nl]Outlive the timer or eliminate the crew. Click to close Click to open Select or create a options preset for this game @@ -78,4 +76,31 @@ Outlive the timer or eliminate the crew. Activated Deactivated unit(s) + + Crewmates + Player Speed + Hiding Time + Crewmate Vision + Flashlight Mode + Crewmate Flashlight Size + Max Vent Uses + Max Time In Vent + Show Names + + Final Hide + Hiding Time + Final Hide Impostor Speed + Final Hide Pings + Ping Interval + Final Hide Seek Map + + Impostors + Forced Impostor + Impostor Vision + Impostor Flashlight Size + + Tasks + # Common Tasks + # Long Tasks + # Short Tasks diff --git a/MiraAPI/Roles/CustomRoleConfiguration.cs b/MiraAPI/Roles/CustomRoleConfiguration.cs index 68edebee..2f608de5 100644 --- a/MiraAPI/Roles/CustomRoleConfiguration.cs +++ b/MiraAPI/Roles/CustomRoleConfiguration.cs @@ -1,7 +1,6 @@ using System; using System.Diagnostics.CodeAnalysis; using AmongUs.GameOptions; -using Il2CppInterop.Runtime.Attributes; using MiraAPI.GameModes; using MiraAPI.Patches.Freeplay; using MiraAPI.Utilities.Assets;