From ad6ca6fa3ee1006fcb73b643220587e0c116c315 Mon Sep 17 00:00:00 2001 From: David Higueros <111460331+TheDavSmasher@users.noreply.github.com> Date: Sat, 20 Jun 2026 01:22:44 -0600 Subject: [PATCH] Simplified property setters and getter --- MiraAPI/GameOptions/OptionTypes/ModdedOption.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/MiraAPI/GameOptions/OptionTypes/ModdedOption.cs b/MiraAPI/GameOptions/OptionTypes/ModdedOption.cs index 206894d..644c87c 100644 --- a/MiraAPI/GameOptions/OptionTypes/ModdedOption.cs +++ b/MiraAPI/GameOptions/OptionTypes/ModdedOption.cs @@ -15,8 +15,6 @@ namespace MiraAPI.GameOptions.OptionTypes; /// The value type. public abstract class ModdedOption : IModdedOption { - private IMiraPlugin? _parentMod; - /// public uint Id { get; } @@ -32,13 +30,13 @@ public abstract class ModdedOption : IModdedOption /// public IMiraPlugin? ParentMod { - get => _parentMod; + get; set { - if (_parentMod != null || value == null) return; - _parentMod = value; + if (field != null || value == null) return; + field = value; - var entry = _parentMod.GetConfigFile().Bind(ConfigDefinition, DefaultValue); + var entry = field.GetConfigFile().Bind(ConfigDefinition, DefaultValue); Value = entry.Value; } } @@ -54,9 +52,9 @@ public abstract class ModdedOption : IModdedOption public T DefaultValue { get; } /// - /// Gets or sets the event that is invoked when the value of the option changes. + /// Gets the event that is invoked when the value of the option changes. /// - public Action? ChangedEvent { get; set; } + public Action? ChangedEvent { get; init; } /// public Func Visible { get; set; }