using System.Collections.Generic; namespace pkNX.Structures { /// /// Represents all possible Mega Evolutions for all entries in the . /// public sealed class MegaEvolutionTable { private readonly MegaEvolutionSet[][] Table; public MegaEvolutionTable(IList data) { Table = new MegaEvolutionSet[data.Count][]; for (int i = 0; i < data.Count; i++) { int count = data[i].Length / MegaEvolutionSet.SIZE; Table[i] = new MegaEvolutionSet[count]; for (int j = 0; j < count; j++) Table[i][j] = new MegaEvolutionSet(data[i], j); } } private static byte[] Write(IList entry) { int count = entry.Count; byte[] data = new byte[MegaEvolutionSet.SIZE]; for (int i = 0; i < count; i++) entry[i].Write(data, i); return data; } public MegaEvolutionSet[] this[int index] { get => Table[index]; set => Table[index] = value; } /// /// Removes any restriction for Mega Evolution /// /// /// uses ; not supported in prior games and maybe not future games. /// This might not be useful in the long run. /// public void RemoveRestrictions() { foreach (var t in Table) { foreach (var s in t) s.RemoveRestrictions(); } } /// /// Writes the entire to its component files. /// /// Pack-ready array of files. public byte[][] Write() { byte[][] data = new byte[Table.Length][]; for (int i = 0; i < data.Length; i++) data[i] = Write(Table[i]); return data; } } }