pk3DS/pk3DS.Core/Structures/Gen6/MegaEvolution6.cs
Kurt fa5bdee781 Refactoring
use new randomization objects in other forms
re-standardize namespaces a little
2017-09-09 22:16:55 -07:00

43 lines
1.4 KiB
C#

using System.IO;
namespace pk3DS.Core.Structures
{
public class MegaEvolutions
{
public ushort[] Form, Method, Argument, u6;
public MegaEvolutions(byte[] data)
{
if (data.Length < 0x10 || data.Length % 8 != 0) return;
Form = new ushort[data.Length / 8];
Method = new ushort[data.Length / 8];
Argument = new ushort[data.Length / 8];
u6 = new ushort[data.Length / 8];
using (BinaryReader br = new BinaryReader(new MemoryStream(data)))
for (int i = 0; i < Form.Length; i++)
{
Form[i] = br.ReadUInt16();
Method[i] = br.ReadUInt16();
Argument[i] = br.ReadUInt16();
u6[i] = br.ReadUInt16();
}
}
public byte[] Write()
{
using (MemoryStream ms = new MemoryStream())
using (BinaryWriter bw = new BinaryWriter(ms))
{
for (int i = 0; i < Form.Length; i++)
{
if (Method[i] == 0)
{ Form[i] = Argument[i] = 0; } // No method to evolve, clear information.
bw.Write(Form[i]);
bw.Write(Method[i]);
bw.Write(Argument[i]);
bw.Write(u6[i]);
}
return ms.ToArray();
}
}
}
}