using System; namespace PKHeX.Core; public interface IEventFlagArray { int EventFlagCount { get; } bool GetEventFlag(int flagNumber); void SetEventFlag(int flagNumber, bool value); } public interface IEventFlag37 : IEventFlagArray, IEventWorkArray { } public static class EventFlagArrayExtensions { /// All Event Flag values for the savegame public static bool[] GetEventFlags(this IEventFlagArray source) { var result = new bool[source.EventFlagCount]; for (int i = 0; i < result.Length; i++) result[i] = source.GetEventFlag(i); return result; } /// All Event Flag values for the savegame public static void SetEventFlags(this IEventFlagArray source, ReadOnlySpan value) { if (value.Length != source.EventFlagCount) return; for (int i = 0; i < value.Length; i++) source.SetEventFlag(i, value[i]); } } public interface IEventWorkArray where T : unmanaged { public int EventWorkCount { get; } public T GetWork(int index); public void SetWork(int index, T value = default); } public static class EventWorkArrayExtensions { /// All Event Constant values for the savegame public static T[] GetAllEventWork(this IEventWorkArray source) where T : unmanaged { var result = new T[source.EventWorkCount]; for (int i = 0; i < result.Length; i++) result[i] = source.GetWork(i); return result; } /// All Event Constant values for the savegame public static void SetAllEventWork(this IEventWorkArray source, ReadOnlySpan value) where T : unmanaged { if (value.Length != source.EventWorkCount) return; for (int i = 0; i < value.Length; i++) source.SetWork(i, value[i]); } }