diff --git a/MiraAPI/GameOptions/OptionTypes/ModdedOptionList.cs b/MiraAPI/GameOptions/OptionTypes/ModdedOptionList.cs index cc7bdfd..a32a727 100644 --- a/MiraAPI/GameOptions/OptionTypes/ModdedOptionList.cs +++ b/MiraAPI/GameOptions/OptionTypes/ModdedOptionList.cs @@ -13,23 +13,21 @@ namespace MiraAPI.GameOptions.OptionTypes; /// The type of options. public class ModdedOptionList : IModdedOptionList, IReadOnlyList where T : IModdedOption { - private IMiraPlugin? _parentMod; - /// public int Count { get; } /// public IMiraPlugin? ParentMod { - get => _parentMod; + get; set { - if (_parentMod != null || value == null) return; - _parentMod = value; + if (field != null || value == null) return; + field = value; foreach (var option in Options) { - option.ParentMod = _parentMod!; + option.ParentMod = value; } } } @@ -40,10 +38,32 @@ public class ModdedOptionList : IModdedOptionList, IReadOnlyList where T : public IReadOnlyList Options { get; } /// - public Func Visible { get; set; } + public Func Visible + { + get; + set + { + field = value; + foreach (var (option, idx) in Options.Select((o, i) => (o, i))) + { + option.Visible = () => value(idx); + } + } + } /// - public bool IncludeInPreset { get; set; } + public bool IncludeInPreset + { + get; + set + { + field = value; + foreach (var option in Options) + { + option.IncludeInPreset = value; + } + } + } /// /// Initializes a new instance of the class.