From e8ea720ca0680a120f12a202c2c89f94d9523c9c Mon Sep 17 00:00:00 2001 From: Az <56699741+AlchlcDvl@users.noreply.github.com> Date: Mon, 26 Oct 2026 15:41:47 -0400 Subject: [PATCH] always update the backing array --- MiraAPI/GameOptions/ModdedArray.cs | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) 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."); }