public async Task <IEnumerable <EncounterWild> > GetEncounterData(bool edited = false) { var encounterGarc = await this.GetGarc(GarcNames.EncounterData, useLz : true, edited : edited); var zoneDataFileIndex = encounterGarc.Garc.FileCount - this.ZoneDataPositionFromEnd; // All files up until the zone data file are the encounter data var encounterBuffers = (await encounterGarc.GetFiles()).Take(zoneDataFileIndex).ToArray(); var zoneDataBuffer = await encounterGarc.GetFile(zoneDataFileIndex); var zoneData = new ZoneData(this.Version); zoneData.Read(zoneDataBuffer); if (zoneData.Entries.Length > encounterBuffers.Length) { throw new InvalidDataException($"Zone data and encounter data mismatch. Zone data had {zoneData.Entries.Length} entries, but encounter data only had {encounterBuffers.Length}"); } return(encounterBuffers.Zip(zoneData.Entries, (b, e) => { var encounter = EncounterWild.New(this.Version, e.ZoneId); encounter.Read(b); return encounter; })); }
public void Read(BinaryReader br) { Version.Read(br); ushort numZones = br.ReadUInt16(); br.ReadBytes(Padding); Zones.Clear(); for (int i = 0; i < numZones; i++) { ushort id = br.ReadUInt16(); ZoneData zd = new ZoneData(); zd.Read(br); Zones[id] = zd; } }