public PBEPkmnSwitchInPacket_Hidden(PBEPkmnSwitchInPacket other) { if (other == null) { throw new ArgumentNullException(nameof(other)); } using (var ms = new MemoryStream()) using (var w = new EndianBinaryWriter(ms, encoding: EncodingType.UTF16)) { w.Write(Code); w.Write((Trainer = other.Trainer).Id); var switchIns = new PBEPkmnSwitchInInfo[other.SwitchIns.Count]; for (int i = 0; i < switchIns.Length; i++) { switchIns[i] = new PBEPkmnSwitchInInfo(other.SwitchIns[i]); } byte count = (byte)(SwitchIns = new ReadOnlyCollection <PBEPkmnSwitchInInfo>(switchIns)).Count; w.Write(count); for (int i = 0; i < count; i++) { SwitchIns[i].ToBytes(w); } w.Write(Forced = other.Forced); if (Forced) { w.Write((ForcedByPokemonTrainer = other.ForcedByPokemonTrainer).Id); w.Write(ForcedByPokemon = other.ForcedByPokemon); } Data = new ReadOnlyCollection <byte>(ms.GetBuffer()); } }
internal PBEPkmnSwitchInPacket_Hidden(byte[] data, EndianBinaryReader r, PBEBattle battle) { Data = new ReadOnlyCollection <byte>(data); Trainer = battle.Trainers[r.ReadByte()]; var switches = new PBEPkmnSwitchInInfo[r.ReadByte()]; for (int i = 0; i < switches.Length; i++) { switches[i] = new PBEPkmnSwitchInInfo(r); } SwitchIns = new ReadOnlyCollection <PBEPkmnSwitchInInfo>(switches); Forced = r.ReadBoolean(); if (Forced) { ForcedByPokemonTrainer = battle.Trainers[r.ReadByte()]; ForcedByPokemon = r.ReadEnum <PBEFieldPosition>(); } }