public override void Read(BinaryReader file, uint size) { base.Read(file, size); unk.Read(file, 4); MipsCount.Read(file, 4); // Imported and Cooked xbms have a different file structure. // Imported xbms can be identified by their Sourcedata being not null var SourceData = this.GetVariableByName("sourceData"); if (SourceData != null) { //dbg var ResidentMipIndex = this.GetVariableByName("residentMipIndex"); if (ResidentMipIndex != null) { throw new NotImplementedException(); } for (int i = 0; i < MipsCount.val; i++) { var mipdata = new SMipData(cr2w); mipdata.Read(file, 16); Mipdata.AddVariable(mipdata); var img = new CByteArray(cr2w); //img.SetParent(this); img.Read(file, 0); Mips.AddVariable(img); } unk2.Read(file, 4); } else { //if (ResidentMipIndex == null) //throw new NotImplementedException(); Mipdata.Read(file, size, (int)MipsCount.val); ResidentmipSize.Read(file, 4); unk2.Read(file, 4); //Residentmip.SetParent(this); Residentmip.Read(file, ResidentmipSize.val); } //if (MipsCount.val > 0) // mips.Read(file, size, (int)MipsCount.val); //else // mips.Read(file, size, 1); //ResidentmipSize.Read(file, 4); //unk2.Read(file, 4); //Residentmip.Bytes = file.ReadBytes((int)ResidentmipSize.val); }
public override void Read(BinaryReader file, uint size) { //Read the 8 unknown bytes. Unknown1.Read(file, 4); Unknown2.Read(file, 4); Resources.Read(file, 0); Objects.Read(file, 0); // Read the data block. blocksize.Read(file, 0); for (int i = 0; i < Objects.elements.Count; i++) { CSectorDataObject curobj = (CSectorDataObject)Objects.GetEditableVariables()[i]; ulong curoffset = curobj.offset.val; byte type = curobj.type.val; if (!(type == 0x1 || type == 0x2)) { //System.Diagnostics.Debugger.Break(); //throw new NotImplementedException(); } ulong len; if (i < Objects.elements.Count - 1) { CSectorDataObject nextobj = (CSectorDataObject)Objects.GetEditableVariables()[i + 1]; ulong nextoffset = nextobj.offset.val; len = nextoffset - curoffset; } else { len = (ulong)blocksize.val - curoffset; } var blockdata = new SBlockData(cr2w); blockdata.Read(file, (uint)len); BlockData.AddVariable(blockdata); } }