pkNX/pkNX.Structures/Evolution/EvolutionSet7.cs
Kurt e432370a40 Add Pokémon Legends: Arceus support
.NET5.0 -> .NET6.0

Co-Authored-By: SciresM <8676005+SciresM@users.noreply.github.com>
2022-02-04 18:43:21 -08:00

43 lines
1.3 KiB
C#

using System;
using System.IO;
namespace pkNX.Structures
{
public class EvolutionSet7 : EvolutionSet
{
private const int ENTRY_SIZE = 8;
private const int ENTRY_COUNT = 8;
public const int SIZE = ENTRY_COUNT * ENTRY_SIZE;
public EvolutionSet7(byte[] data)
{
if (data.Length != SIZE)
return;
PossibleEvolutions = data.GetArray(GetEvo, ENTRY_SIZE);
}
private static EvolutionMethod GetEvo(byte[] data, int offset) => new()
{
Method = (EvolutionType)BitConverter.ToUInt16(data, offset + 0),
Argument = BitConverter.ToUInt16(data, offset + 2),
Species = BitConverter.ToUInt16(data, offset + 4),
Form = (sbyte)data[offset + 6],
Level = data[offset + 7],
};
public override byte[] Write()
{
using MemoryStream ms = new();
using BinaryWriter bw = new(ms);
foreach (EvolutionMethod evo in PossibleEvolutions)
{
bw.Write((ushort)evo.Method);
bw.Write((ushort)evo.Argument);
bw.Write((ushort)evo.Species);
bw.Write((sbyte)evo.Form);
bw.Write((byte)evo.Level);
}
return ms.ToArray();
}
}
}