mirror of
https://github.com/kwsch/pkNX.git
synced 2026-04-16 22:58:33 -05:00
43 lines
1.3 KiB
C#
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();
|
|
}
|
|
}
|
|
} |