2018-07-08 04:31:41 +00:00
|
|
|
using System;
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
namespace PKHeX.Core;
|
|
|
|
|
|
|
|
public sealed class PokeBlock3
|
2018-07-08 04:31:41 +00:00
|
|
|
{
|
2022-09-22 18:57:58 +00:00
|
|
|
public const int SIZE = 8;
|
2022-06-18 18:04:24 +00:00
|
|
|
private readonly byte[] Data;
|
|
|
|
public PokeBlock3(byte[] data) => Data = data;
|
2018-07-08 04:31:41 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public PokeBlock3Color Color { get => (PokeBlock3Color)Data[0]; set => Data[0] = (byte)value; }
|
2022-09-22 18:57:58 +00:00
|
|
|
public byte Spicy { get => Data[1]; set => Data[1] = value; }
|
|
|
|
public byte Dry { get => Data[2]; set => Data[2] = value; }
|
|
|
|
public byte Sweet { get => Data[3]; set => Data[3] = value; }
|
|
|
|
public byte Bitter { get => Data[4]; set => Data[4] = value; }
|
|
|
|
public byte Sour { get => Data[5]; set => Data[5] = value; }
|
|
|
|
public byte Feel { get => Data[6]; set => Data[6] = value; }
|
|
|
|
// 7 unused alignment byte
|
2018-07-08 04:31:41 +00:00
|
|
|
|
2022-09-22 18:57:58 +00:00
|
|
|
public void Delete() => Data.AsSpan().Clear();
|
2018-07-08 04:31:41 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public void Maximize(bool create = false)
|
|
|
|
{
|
|
|
|
if (Color == 0 && !create)
|
|
|
|
return;
|
|
|
|
Spicy = Dry = Sweet = Bitter = Sour = Feel = 255;
|
|
|
|
Color = PokeBlock3Color.Gold;
|
|
|
|
}
|
2018-07-08 04:31:41 +00:00
|
|
|
|
2023-01-22 04:02:33 +00:00
|
|
|
public void SetBlock(Span<byte> data) => Data.CopyTo(data);
|
2018-09-15 05:37:47 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public static PokeBlock3 GetBlock(ReadOnlySpan<byte> data, int offset)
|
|
|
|
{
|
|
|
|
byte[] result = data.Slice(offset, SIZE).ToArray();
|
|
|
|
return new PokeBlock3(result);
|
2018-07-08 04:31:41 +00:00
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|