private void loadFromStream(Stream input) { BinaryReader reader = new BinaryReader(input); this.offsize.offset = (uint)input.Position; this.magic = MadScience.StreamHelpers.ReadStringASCII(input, 4); this.version = reader.ReadUInt32(); this.keytable.offset = reader.ReadUInt32(); this.keytable.size = reader.ReadUInt32(); byte typeZero = 0; byte entryCount = reader.ReadByte(); for (int i = 0; i < entryCount; i++) { VPXYEntry entry = new VPXYEntry(input); if (entry.type == 0) { if (typeZero == 0) { this.numTypeZero = (uint)entry.typeZero; } linkEntries.Add(entry); typeZero++; } if (entry.type == 1) { seprEntries.Add(entry); } entry = null; } byte boundBox = reader.ReadByte(); if (boundBox == 2) { this.boundingbox = new MadScience.Wrappers.BoundingBox(input); } this.unk1 = reader.ReadUInt32(); this.hasFTPT = reader.ReadByte(); if (this.hasFTPT == 1) { this.ftptIndex = reader.ReadUInt32(); } this.keytable.Load(input); // Now that we have the keytable, lets load the TGIs into the linked and seperate entries. This is to // make editing easier if (this.keytable.keys.Count > 0) { for (int i = 0; i < seprEntries.Count; i++) { this.seprEntries[i].tgiList.Add(this.keytable.keys[(int)this.seprEntries[i].tgiIndex[0]]); } for (int i = 0; i < linkEntries.Count; i++) { for (int j = 0; j < this.linkEntries[i].tgiIndex.Count; j++) { this.linkEntries[i].tgiList.Add(this.keytable.keys[(int)this.linkEntries[i].tgiIndex[j]]); } } } this.offsize.size = (uint)input.Position - this.offsize.offset; reader = null; }
private void loadFromStream(Stream input) { BinaryReader reader = new BinaryReader(input); this.offsize.offset = (uint)input.Position; this.magic = MadScience.StreamHelpers.ReadStringASCII(input, 4); this.version = reader.ReadUInt32(); this.keytable.offset = reader.ReadUInt32(); this.keytable.size = reader.ReadUInt32(); byte typeZero = 0; byte entryCount = reader.ReadByte(); for (int i = 0; i < entryCount; i++) { VPXYEntry entry = new VPXYEntry(input); if (entry.type == 0) { if (typeZero == 0) this.numTypeZero = (uint)entry.typeZero; linkEntries.Add(entry); typeZero++; } if (entry.type == 1) { seprEntries.Add(entry); } entry = null; } byte boundBox = reader.ReadByte(); if (boundBox == 2) { this.boundingbox = new MadScience.Wrappers.BoundingBox(input); } this.unk1 = reader.ReadUInt32(); this.hasFTPT = reader.ReadByte(); if (this.hasFTPT == 1) { this.ftptIndex = reader.ReadUInt32(); } this.keytable.Load(input); // Now that we have the keytable, lets load the TGIs into the linked and seperate entries. This is to // make editing easier if (this.keytable.keys.Count > 0) { for (int i = 0; i < seprEntries.Count; i++) { this.seprEntries[i].tgiList.Add(this.keytable.keys[(int)this.seprEntries[i].tgiIndex[0]]); } for (int i = 0; i < linkEntries.Count; i++) { for (int j = 0; j < this.linkEntries[i].tgiIndex.Count; j++) { this.linkEntries[i].tgiList.Add(this.keytable.keys[(int)this.linkEntries[i].tgiIndex[j]]); } } } this.offsize.size = (uint)input.Position - this.offsize.offset; reader = null; }