PKHeX/PKHeX.Core/Saves/Substructures/Gen3/PokeBlock3Case.cs
Kurt 95eb008125 Misc tweaks
no functional change
2024-03-20 09:42:28 -05:00

41 lines
968 B
C#

using System;
namespace PKHeX.Core;
public sealed class PokeBlock3Case
{
private const int Count = 40;
public readonly PokeBlock3[] Blocks;
public PokeBlock3Case(ReadOnlySpan<byte> data, int offset)
{
Blocks = new PokeBlock3[Count];
for (int i = 0; i < Blocks.Length; i++)
Blocks[i] = PokeBlock3.GetBlock(data, offset + (i * PokeBlock3.SIZE));
}
public byte[] Write()
{
byte[] result = new byte[Count*PokeBlock3.SIZE];
Write(result);
return result;
}
public void Write(Span<byte> result)
{
for (int i = 0; i < Blocks.Length; i++)
Blocks[i].SetBlock(result.Slice(i * PokeBlock3.SIZE, PokeBlock3.SIZE));
}
public void DeleteAll()
{
foreach (var b in Blocks)
b.Delete();
}
public void MaximizeAll(bool createMissing = false)
{
foreach (var b in Blocks)
b.Maximize(createMissing);
}
}