diff --git a/MiraAPI/GameOptions/ModdedArray.cs b/MiraAPI/GameOptions/ModdedArray.cs index 4914a787..bbd8027f 100644 --- a/MiraAPI/GameOptions/ModdedArray.cs +++ b/MiraAPI/GameOptions/ModdedArray.cs @@ -75,12 +75,14 @@ public sealed class ModdedArray : IList, IReadOnlyList, IList { get { - if (!ModdedOptionsManager.ListInstanceCache.TryGetValue(this, out var attribute)) - return items[index]; + if (ModdedOptionsManager.ListInstanceCache.TryGetValue(this, out var attribute)) + { + items[index] = attribute is ITypedOptionList typedAttr + ? typedAttr.GetValueUnboxed(index) + : (T)attribute.GetValue(index); + } - return attribute is ITypedOptionList typedAttr - ? typedAttr.GetValueUnboxed(index) - : (T)attribute.GetValue(index); + return items[index]; } set { @@ -90,6 +92,10 @@ public sealed class ModdedArray : IList, IReadOnlyList, IList typedAttr.SetValueUnboxed(index, value); else attribute.SetValue(index, value!); + + items[index] = attribute is ITypedOptionList typedAttr2 + ? typedAttr2.GetValueUnboxed(index) + : (T)attribute.GetValue(index); } else { @@ -192,31 +198,31 @@ public sealed class ModdedArray : IList, IReadOnlyList, IList } /// - public void Insert(int index, T item) + void IList.Insert(int index, T item) { throw new NotSupportedException("ModdedArray is of a fixed size."); } /// - public void RemoveAt(int index) + void IList.RemoveAt(int index) { throw new NotSupportedException("ModdedArray is of a fixed size."); } /// - public void Add(T item) + void ICollection.Add(T item) { throw new NotSupportedException("ModdedArray is of a fixed size."); } /// - public void Clear() + void ICollection.Clear() { throw new NotSupportedException("ModdedArray is of a fixed size."); } /// - public bool Remove(T item) + bool ICollection.Remove(T item) { throw new NotSupportedException("ModdedArray is of a fixed size."); }