void Parse(Stream s) { s.Position = 0; BinaryReader r = new BinaryReader(s); version = r.ReadUInt32(); tgiOffset = r.ReadUInt32() + 8; presetCount = r.ReadUInt32(); if (presetCount != 0) { throw new Exception("Found non-zero one"); } name = BigEndianUnicodeString.Read(s); sortPriority = r.ReadSingle(); this.secondarySortIndex = r.ReadUInt16(); propertyID = r.ReadUInt32(); this.auralMaterialHash = r.ReadUInt32(); this.parmFlags = (ParmFlag)r.ReadByte(); this.excludePartFlags = (ExcludePartFlag)r.ReadUInt64(); this.excludeModifierRegionFlags = r.ReadUInt32(); flagList = new FlagList(OnResourceChanged, s); this.simlolencePrice = r.ReadUInt32(); this.partTitleKey = r.ReadUInt32(); this.partDesptionKey = r.ReadUInt32(); this.uniqueTextureSpace = r.ReadByte(); this.bodyType = r.ReadInt32(); this.unused1 = r.ReadInt32(); this.ageGender = (AgeGenderFlags)r.ReadUInt32(); this.unused2 = r.ReadByte(); this.unused3 = r.ReadByte(); swatchColorCode = new SwatchColorList(OnResourceChanged, s); this.buffResKey = r.ReadByte(); this.varientThumbnailKey = r.ReadByte(); if (this.version >= 0x1C) { this.voiceEffectHash = r.ReadUInt64(); } this.nakedKey = r.ReadByte(); this.parentKey = r.ReadByte(); this.sortLayer = r.ReadInt32(); // Don't move any of this before the ----- // TGI block list long currentPosition = r.BaseStream.Position; r.BaseStream.Position = tgiOffset; byte count4 = r.ReadByte(); tgiList = new CountedTGIBlockList(OnResourceChanged, "IGT", count4, s); r.BaseStream.Position = currentPosition; lodBlockList = new LODBlockList(null, s, tgiList); //------------- byte count = r.ReadByte(); this.slotKey = new SimpleList <byte>(null); for (byte i = 0; i < count; i++) { this.slotKey.Add(r.ReadByte()); } this.diffuseShadowKey = r.ReadByte(); this.shadowKey = r.ReadByte(); this.compositionMethod = r.ReadByte(); this.regionMapKey = r.ReadByte(); this.overrides = r.ReadByte(); this.normalMapKey = r.ReadByte(); this.specularMapKey = r.ReadByte(); if (this.version >= 0x1B) { this.sharedUVMapSpace = r.ReadUInt32(); } }
protected override Stream UnParse() { var s = new MemoryStream(); var w = new BinaryWriter(s); w.Write(this.version); w.Write(0); // tgi offset w.Write(this.presetCount); BigEndianUnicodeString.Write(s, this.name); w.Write(this.sortPriority); w.Write(this.secondarySortIndex); w.Write(this.propertyID); w.Write(this.auralMaterialHash); w.Write((byte)this.parmFlags); w.Write((ulong)this.excludePartFlags); if (this.version >= 36) { w.Write(this.excludeModifierRegionFlags); } else { w.Write((uint)this.excludeModifierRegionFlags); } this.flagList = this.flagList ?? new FlagList(this.OnResourceChanged); if (this.version >= 37) { this.flagList.UnParse(s); } else { this.flagList.WriteUInt16Flags(s); } w.Write(this.deprecatedPrice); w.Write(this.partTitleKey); w.Write(this.partDesptionKey); w.Write(this.uniqueTextureSpace); w.Write((uint)this.bodyType); w.Write(this.bodySubType); w.Write((uint)this.ageGender); if (this.version >= 0x20) { w.Write(this.reserved1); } if (this.version >= 34) { w.Write(this.packID); w.Write((byte)this.packFlags); if (this.reserved2 == null) { this.reserved2 = new byte[9]; } w.Write(this.reserved2); } else { w.Write(this.unused2); if (this.unused2 > 0) { w.Write(this.unused3); } } if (this.swatchColorCode == null) { this.swatchColorCode = new SwatchColorList(this.OnResourceChanged); } this.swatchColorCode.UnParse(s); w.Write(this.buffResKey); w.Write(this.varientThumbnailKey); if (this.version >= 0x1C) { w.Write(this.voiceEffectHash); } if (this.version >= 0x1E) { w.Write(this.usedMaterialCount); if (this.usedMaterialCount > 0) { w.Write(this.materialSetUpperBodyHash); w.Write(this.materialSetLowerBodyHash); w.Write(this.materialSetShoesHash); } } if (this.version >= 0x1F) { w.Write((uint)this.hideForOccultFlags); } w.Write(this.nakedKey); w.Write(this.parentKey); w.Write(this.sortLayer); if (this.lodBlockList == null) { this.lodBlockList = new LODBlockList(this.OnResourceChanged); } this.lodBlockList.UnParse(s); if (this.slotKey == null) { this.slotKey = new SimpleList <byte>(this.OnResourceChanged); } w.Write((byte)this.slotKey.Count); foreach (var b in this.slotKey) { w.Write(b); } w.Write(this.diffuseShadowKey); w.Write(this.shadowKey); w.Write(this.compositionMethod); w.Write(this.regionMapKey); if (this.overrides == null) { this.overrides = new OverrideList(this.OnResourceChanged); } this.overrides.UnParse(s); w.Write(this.normalMapKey); w.Write(this.specularMapKey); if (this.version >= 0x1B) { w.Write(this.sharedUVMapSpace); } if (this.version >= 0x1E) { w.Write(this.emissionMapKey); } var tgiPosition = w.BaseStream.Position; w.BaseStream.Position = 4; w.Write(tgiPosition - 8); w.BaseStream.Position = tgiPosition; if (this.tgiList == null) { this.tgiList = new CountedTGIBlockList(this.OnResourceChanged); } w.Write((byte)this.tgiList.Count); foreach (var tgi in this.tgiList) { tgi.UnParse(s); } return(s); }
protected override Stream UnParse() { MemoryStream s = new MemoryStream(); BinaryWriter w = new BinaryWriter(s); w.Write(this.version); w.Write(0); // tgi offset w.Write(presetCount); BigEndianUnicodeString.Write(s, name); w.Write(sortPriority); w.Write(secondarySortIndex); w.Write(propertyID); w.Write(auralMaterialHash); w.Write((byte)parmFlags); w.Write((ulong)excludePartFlags); w.Write(excludeModifierRegionFlags); if (this.flagList == null) { this.flagList = new FlagList(OnResourceChanged); } flagList.UnParse(s); w.Write(simlolencePrice); w.Write(partTitleKey); w.Write(partDesptionKey); w.Write(uniqueTextureSpace); w.Write(bodyType); w.Write(unused1); w.Write((uint)ageGender); w.Write(unused2); w.Write(unused3); if (this.swatchColorCode == null) { this.swatchColorCode = new SwatchColorList(OnResourceChanged); } swatchColorCode.UnParse(s); w.Write(buffResKey); w.Write(varientThumbnailKey); if (this.version >= 0x1C) { w.Write(voiceEffectHash); } w.Write(nakedKey); w.Write(parentKey); w.Write(sortLayer); if (this.lodBlockList == null) { this.lodBlockList = new LODBlockList(OnResourceChanged); } lodBlockList.UnParse(s); if (this.slotKey == null) { this.slotKey = new SimpleList <byte>(OnResourceChanged); } w.Write((byte)this.slotKey.Count); foreach (var b in this.slotKey) { w.Write(b); } w.Write(diffuseShadowKey); w.Write(shadowKey); w.Write(compositionMethod); w.Write(regionMapKey); w.Write(overrides); w.Write(normalMapKey); w.Write(specularMapKey); if (this.version >= 0x1B) { w.Write(sharedUVMapSpace); } long tgiPosition = w.BaseStream.Position; w.BaseStream.Position = 4; w.Write(tgiPosition - 8); w.BaseStream.Position = tgiPosition; if (this.tgiList == null) { this.tgiList = new CountedTGIBlockList(OnResourceChanged); } w.Write((byte)tgiList.Count); foreach (var tgi in tgiList) { tgi.UnParse(s); } return(s); }
private void Parse(Stream s) { s.Position = 0; var r = new BinaryReader(s); this.version = r.ReadUInt32(); this.TGIoffset = r.ReadUInt32() + 8; this.presetCount = r.ReadUInt32(); if (this.presetCount != 0) { throw new Exception("Found non-zero one"); } this.name = BigEndianUnicodeString.Read(s); this.sortPriority = r.ReadSingle(); this.secondarySortIndex = r.ReadUInt16(); this.propertyID = r.ReadUInt32(); this.auralMaterialHash = r.ReadUInt32(); this.parmFlags = (ParmFlag)r.ReadByte(); this.excludePartFlags = (ExcludePartFlag)r.ReadUInt64(); if (this.version >= 36) { this.excludeModifierRegionFlags = r.ReadUInt64(); } else { this.excludeModifierRegionFlags = r.ReadUInt32(); } if (this.version >= 37) { this.flagList = new FlagList(this.OnResourceChanged, s); } else { this.flagList = FlagList.CreateWithUInt16Flags(this.OnResourceChanged, s, recommendedApiVersion); } this.deprecatedPrice = r.ReadUInt32(); this.partTitleKey = r.ReadUInt32(); this.partDesptionKey = r.ReadUInt32(); this.uniqueTextureSpace = r.ReadByte(); this.bodyType = (BodyType)r.ReadInt32(); this.bodySubType = r.ReadInt32(); this.ageGender = (AgeGenderFlags)r.ReadUInt32(); if (this.version >= 0x20) { this.reserved1 = r.ReadUInt32(); } if (this.version >= 34) { this.packID = r.ReadInt16(); this.packFlags = (PackFlag)r.ReadByte(); this.reserved2 = r.ReadBytes(9); } else { this.packID = 0; this.unused2 = r.ReadByte(); if (this.unused2 > 0) { this.unused3 = r.ReadByte(); } } this.swatchColorCode = new SwatchColorList(this.OnResourceChanged, s); this.buffResKey = r.ReadByte(); this.varientThumbnailKey = r.ReadByte(); if (this.version >= 0x1C) { this.voiceEffectHash = r.ReadUInt64(); } if (this.version >= 0x1E) { this.usedMaterialCount = r.ReadByte(); if (this.usedMaterialCount > 0) { this.materialSetUpperBodyHash = r.ReadUInt32(); this.materialSetLowerBodyHash = r.ReadUInt32(); this.materialSetShoesHash = r.ReadUInt32(); } } if (this.version >= 0x1F) { this.hideForOccultFlags = (OccultTypesDisabled)r.ReadUInt32(); } this.nakedKey = r.ReadByte(); this.parentKey = r.ReadByte(); this.sortLayer = r.ReadInt32(); // Don't move any of this before the ----- // TGI block list var currentPosition = r.BaseStream.Position; r.BaseStream.Position = this.TGIoffset; var count4 = r.ReadByte(); this.tgiList = new CountedTGIBlockList(this.OnResourceChanged, "IGT", count4, s); r.BaseStream.Position = currentPosition; this.lodBlockList = new LODBlockList(null, s, this.tgiList); //------------- var count = r.ReadByte(); this.slotKey = new SimpleList <byte>(null); for (byte i = 0; i < count; i++) { this.slotKey.Add(r.ReadByte()); } this.diffuseShadowKey = r.ReadByte(); this.shadowKey = r.ReadByte(); this.compositionMethod = r.ReadByte(); this.regionMapKey = r.ReadByte(); this.overrides = new OverrideList(null, s); this.normalMapKey = r.ReadByte(); this.specularMapKey = r.ReadByte(); if (this.version >= 0x1B) { this.sharedUVMapSpace = r.ReadUInt32(); } if (this.version >= 0x1E) { this.emissionMapKey = r.ReadByte(); } }