Simplified property setters and getter

This commit is contained in:
David Higueros committed 2026-06-20 01:27:01 -06:00
1 parent 93d5ebf15a
commit ad6ca6fa3e
1 file changed
+6 -8
@@ -15,8 +15,6 @@ namespace MiraAPI.GameOptions.OptionTypes;
/// <typeparam name="T">The value type.</typeparam>
public abstract class ModdedOption<T> : IModdedOption
{
private IMiraPlugin? _parentMod;
/// <inheritdoc />
public uint Id { get; }
@@ -32,13 +30,13 @@ public abstract class ModdedOption<T> : IModdedOption
/// <inheritdoc />
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<T> : IModdedOption
public T DefaultValue { get; }
/// <summary>
/// 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.
/// </summary>
public Action<T>? ChangedEvent { get; set; }
public Action<T>? ChangedEvent { get; init; }
/// <inheritdoc />
public Func<bool> Visible { get; set; }