using System; namespace PKHeX.Core; /// /// Mystery Gift backed by serialized fields from ROM/SAV data, rather than observed specifications. /// public abstract class DataMysteryGift(byte[] Data) : MysteryGift { public readonly byte[] Data = Data; /// /// Returns an array for exporting outside the program (to disk, etc.). /// public virtual byte[] Write() => Data; public override int GetHashCode() { int hash = 17; foreach (var b in Data) hash = (hash * 31) + b; return hash; } /// /// Creates a deep copy of the object data. /// public override MysteryGift Clone() { byte[] data = (byte[])Data.Clone(); var result = GetMysteryGift(data); ArgumentNullException.ThrowIfNull(result); return result; } public override bool Empty => !Data.AsSpan().ContainsAnyExcept(0); }