diff --git a/library/Structures/GtsRecord4.cs b/library/Structures/GtsRecord4.cs index 21219ee4..9a6c1a1b 100644 --- a/library/Structures/GtsRecord4.cs +++ b/library/Structures/GtsRecord4.cs @@ -71,13 +71,35 @@ namespace PkmnFoundations.Structures } set { + if (value == null) + { + m_data = null; + m_data_readonly = null; + m_pokemon = null; + return; + } if (value.Length != 0xEC) throw new ArgumentException("PKM length is incorrect"); m_data = value; m_data_readonly = new ReadOnlyCollection(m_data); + m_pokemon = null; } } private byte[] m_data; private ReadOnlyCollection m_data_readonly; + private PokemonParty4 m_pokemon; + + public override PokemonPartyBase Pokemon + { + get + { + if (DataActual == null || m_pokedex == null) + return null; + if (m_pokemon == null) + m_pokemon = new PokemonParty4(m_pokedex, DataActual); + + return m_pokemon; + } + } public byte Unknown1; public byte Unknown2; diff --git a/library/Structures/GtsRecord5.cs b/library/Structures/GtsRecord5.cs index 79ab3f58..ecc38044 100644 --- a/library/Structures/GtsRecord5.cs +++ b/library/Structures/GtsRecord5.cs @@ -71,13 +71,36 @@ namespace PkmnFoundations.Structures } set { + if (value == null) + { + m_data = null; + m_data_readonly = null; + //m_pokemon = null; + return; + } if (value.Length != 0xEC) throw new ArgumentException("PKM length is incorrect"); m_data = value; m_data_readonly = new ReadOnlyCollection(m_data); + //m_pokemon = null; } } private byte[] m_data; private ReadOnlyCollection m_data_readonly; + //private PokemonParty5 m_pokemon; + + public override PokemonPartyBase Pokemon + { + get + { + if (DataActual == null || m_pokedex == null) + return null; + throw new NotImplementedException(); + //if (m_pokemon == null) + // m_pokemon = new PokemonParty4(m_pokedex, DataActual); + + //return m_pokemon; + } + } public byte Unknown1; public byte Unknown2; diff --git a/library/Structures/GtsRecordBase.cs b/library/Structures/GtsRecordBase.cs index 1f0bb665..b4ac34c9 100644 --- a/library/Structures/GtsRecordBase.cs +++ b/library/Structures/GtsRecordBase.cs @@ -25,6 +25,11 @@ namespace PkmnFoundations.Structures } } + public abstract PokemonPartyBase Pokemon + { + get; + } + /// /// National Dex species number ///