mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-04-27 02:57:06 -05:00
move declaration to derived class, can return specific type now don't use AbilityType directly, use the ability permission computed property for legality checks. probably can remove this explicit MG method in the future.
34 lines
898 B
C#
34 lines
898 B
C#
using System;
|
|
|
|
namespace PKHeX.Core;
|
|
|
|
/// <summary>
|
|
/// Mystery Gift backed by serialized fields from ROM/SAV data, rather than observed specifications.
|
|
/// </summary>
|
|
public abstract class DataMysteryGift(Memory<byte> Raw) : MysteryGift
|
|
{
|
|
public Span<byte> Data => Raw.Span;
|
|
|
|
/// <summary>
|
|
/// Returns an array for exporting outside the program (to disk, etc.).
|
|
/// </summary>
|
|
public virtual ReadOnlySpan<byte> Write() => Data;
|
|
|
|
public sealed override int GetHashCode()
|
|
{
|
|
int hash = 17;
|
|
foreach (var b in Data)
|
|
hash = (hash * 31) + b;
|
|
return hash;
|
|
}
|
|
|
|
public sealed override bool IsEmpty => !Data.ContainsAnyExcept<byte>(0);
|
|
|
|
public void Clear() => Data.Clear();
|
|
|
|
/// <summary>
|
|
/// Creates a deep copy of the <see cref="MysteryGift"/> object data.
|
|
/// </summary>
|
|
public abstract DataMysteryGift Clone();
|
|
}
|