protected override Stream UnParse() { Stream s = base.UnParse(); BinaryWriter w = new BinaryWriter(s); if (materialList == null) { materialList = new WallFloorPatternMaterialList(OnResourceChanged); } materialList.UnParse(s); if (common == null) { common = new Common(requestedApiVersion, OnResourceChanged); } common.UnParse(s); w.Write((uint)patternType); w.Write(materialVPXYIndex); w.Write((uint)sortFlags); BigEndianUnicodeString.Write(s, surfaceType); w.Write((uint)terrainType); w.Write(argb); base.UnParse(s); w.Flush(); return(s); }
protected override void Parse(Stream s) { BinaryReader r = new BinaryReader(s); base.Parse(s); this.materialList = new WallFloorPatternMaterialList(OnResourceChanged, s); this.common = new Common(requestedApiVersion, OnResourceChanged, s); this.patternType = (Pattern)r.ReadUInt32(); this.materialVPXYIndex = r.ReadUInt32(); this.sortFlags = (SortFlagsType)r.ReadUInt32(); this.surfaceType = BigEndianUnicodeString.Read(s); this.terrainType = (Terrain)r.ReadUInt32(); this.argb = r.ReadUInt32(); list = new TGIBlockList(OnResourceChanged, s, tgiPosn, tgiSize); if (checking) { if (this.GetType().Equals(typeof(WallFloorPatternCatalogResource)) && s.Position != s.Length) { throw new InvalidDataException(String.Format("Data stream length 0x{0:X8} is {1:X8} bytes longer than expected at {2:X8}", s.Length, s.Length - s.Position, s.Position)); } } }
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(); colorCode = r.ReadByte(); unknown1 = r.ReadByte(); outfitGroup = r.ReadUInt32(); unknown2 = new DataBlobHandler(recommendedApiVersion, OnResourceChanged, r.ReadBytes(17)); flagList = new FlagList(OnResourceChanged, s); this.unknown3 = r.ReadByte(); this.swatchIndex = r.ReadByte(); unknown4 = new DataBlobHandler(1, null, r.ReadBytes(2 * 3 * 4 + 1)); byte count2 = r.ReadByte(); swatchColorCode = new uint[count2]; for (byte i = 0; i < count2; i++) { swatchColorCode[i] = r.ReadUInt32(); } unknown5 = new DataBlobHandler(1, null, r.ReadBytes(2 * 4)); // TGI block list long currentPosition = r.BaseStream.Position; r.BaseStream.Position = tgiOffset; tgiList = new TGIBlockList(null); byte count4 = r.ReadByte(); for (int i = 0; i < count4; i++) { tgiList.Add(new TGIBlock(1, null, "IGT", s)); } r.BaseStream.Position = currentPosition; unknown6 = new UnknownClassList(null, s, tgiList); unknown7 = new DataBlobHandler(1, null, r.ReadBytes(10)); }
void Parse(Stream s) { int tgiPosn; BinaryReader r = new BinaryReader(s); version = r.ReadUInt32(); tgiPosn = r.ReadInt32() + 8; presets = new PresetList(OnResourceChanged, s); unknown1 = BigEndianUnicodeString.Read(s); sortPriority = r.ReadSingle(); unknown2 = r.ReadByte(); clothing = (ClothingType)r.ReadUInt32(); dataType = (DataTypeFlags)r.ReadUInt32(); ageGender = new AgeGenderFlags(0, OnResourceChanged, s); clothingCategory = (ClothingCategoryFlags)r.ReadUInt32(); casPart1Index = r.ReadByte(); casPart2Index = r.ReadByte(); blendInfoFatIndex = r.ReadByte(); blendInfoFitIndex = r.ReadByte(); blendInfoThinIndex = r.ReadByte(); blendInfoSpecialIndex = r.ReadByte(); overlayPriority = r.ReadUInt32(); vpxyIndexes = new ByteIndexList(OnResourceChanged, s, ReadByte, WriteByte); lodInfo = new LODInfoEntryList(OnResourceChanged, s); diffuse1Indexes = new ByteIndexList(OnResourceChanged, s, ReadByte, WriteByte); specular1Indexes = new ByteIndexList(OnResourceChanged, s, ReadByte, WriteByte); diffuse2Indexes = new ByteIndexList(OnResourceChanged, s, ReadByte, WriteByte); specular2Indexes = new ByteIndexList(OnResourceChanged, s, ReadByte, WriteByte); bondIndexes = new ByteIndexList(OnResourceChanged, s, ReadByte, WriteByte); unknown4 = BigEndianUnicodeString.Read(s); if (checking) { if (tgiPosn != s.Position) { throw new InvalidDataException(String.Format("Position of TGIBlock read: 0x{0:X8}, actual: 0x{1:X8}", tgiPosn, s.Position)); } } byte count = r.ReadByte(); tgiBlocks = new CountedTGIBlockList(OnResourceChanged, "IGT", count, s); vpxyIndexes.ParentTGIBlocks = diffuse1Indexes.ParentTGIBlocks = specular1Indexes.ParentTGIBlocks = diffuse2Indexes.ParentTGIBlocks = specular2Indexes.ParentTGIBlocks = bondIndexes.ParentTGIBlocks = tgiBlocks; }
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(colorCode); w.Write(unknown1); w.Write(outfitGroup); unknown2.UnParse(s); flagList.UnParse(s); w.Write(this.unknown3); w.Write(this.swatchIndex); unknown4.UnParse(s); w.Write((byte)swatchColorCode.Length); foreach (var value in swatchColorCode) { w.Write(value); } unknown5.UnParse(s); unknown6.UnParse(s); unknown7.UnParse(s); long tgiPosition = w.BaseStream.Position; w.BaseStream.Position = 4; w.Write(tgiPosition - 8); w.BaseStream.Position = tgiPosition; w.Write((byte)tgiList.Count); foreach (var tgi in tgiList) { tgi.UnParse(s); } return(s); }
protected override Stream UnParse() { long posn; MemoryStream s = new MemoryStream(); BinaryWriter w = new BinaryWriter(s); w.Write(version); posn = s.Position; w.Write((uint)0); w.Write((uint)0); BigEndianUnicodeString.Write(s, partName); w.Write(unknown1); if (version >= 8) { if (blendGeometry == null) { blendGeometry = new TGIBlock(requestedApiVersion, OnResourceChanged); } blendGeometry.UnParse(s); } if (tgiBlocks == null) { tgiBlocks = new TGIBlockList(OnResourceChanged, true); } if (casEntries == null) { casEntries = new CASEntryList(OnResourceChanged, tgiBlocks); } casEntries.UnParse(s); tgiBlocks.UnParse(s, posn); s.Flush(); return(s); }
void Parse(Stream s) { long tgiPosn, tgiSize; BinaryReader r = new BinaryReader(s); version = r.ReadUInt32(); tgiPosn = r.ReadUInt32() + s.Position; tgiSize = r.ReadUInt32(); partName = BigEndianUnicodeString.Read(s); unknown1 = r.ReadUInt32(); if (version >= 8) { blendGeometry = new TGIBlock(requestedApiVersion, OnResourceChanged, s); } casEntries = new CASEntryList(OnResourceChanged, s); tgiBlocks = new TGIBlockList(OnResourceChanged, s, tgiPosn, tgiSize, addEight: version >= 8); casEntries.ParentTGIBlocks = tgiBlocks; }
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() { 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); }
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(excludePartFlags); w.Write(excludeModifierRegionFlags); flagList.UnParse(s); w.Write(simlolencePrice); w.Write(partTitleKey); w.Write(partDesptionKey); w.Write(uniqueTextureSpace); w.Write(bodyType); w.Write(unused1); w.Write(ageGender); w.Write(unused2); w.Write(unused3); swatchColorCode.UnParse(s); w.Write(buffResKey); w.Write(varientThumbnailKey); w.Write(nakedKey); w.Write(parentKey); w.Write(sortLayer); lodBlockList.UnParse(s); w.Write((byte)this.slotKey.Length); foreach (var b in this.slotKey) { w.Write(b); } w.Write(difussShadowKey); w.Write(shadowKey); w.Write(compositionMethod); w.Write(regionMapKey); w.Write(overrides); w.Write(normalMapKey); w.Write(specularMapKey); long tgiPosition = w.BaseStream.Position; w.BaseStream.Position = 4; w.Write(tgiPosition - 8); w.BaseStream.Position = tgiPosition; w.Write((byte)tgiList.Count); foreach (var tgi in tgiList) { tgi.UnParse(s); } return(s); }
protected override Stream UnParse() { long posn, tgiPosn, end; MemoryStream s = new MemoryStream(); BinaryWriter w = new BinaryWriter(s); w.Write(version); posn = s.Position; w.Write((int)0); //offset if (presets == null) { presets = new PresetList(OnResourceChanged); } presets.UnParse(s); BigEndianUnicodeString.Write(s, unknown1); w.Write(sortPriority); w.Write(unknown2); w.Write((uint)clothing); w.Write((uint)dataType); if (ageGender == null) { ageGender = new AgeGenderFlags(0, OnResourceChanged); } ageGender.UnParse(s); w.Write((uint)clothingCategory); w.Write(casPart1Index); w.Write(casPart2Index); w.Write(blendInfoFatIndex); w.Write(blendInfoFitIndex); w.Write(blendInfoThinIndex); w.Write(blendInfoSpecialIndex); w.Write(overlayPriority); if (tgiBlocks == null) { tgiBlocks = new CountedTGIBlockList(OnResourceChanged, "IGT"); } if (vpxyIndexes == null) { vpxyIndexes = new ByteIndexList(OnResourceChanged, ReadByte, WriteByte, byte.MaxValue, tgiBlocks); } vpxyIndexes.UnParse(s); if (lodInfo == null) { lodInfo = new LODInfoEntryList(OnResourceChanged); } lodInfo.UnParse(s); if (diffuse1Indexes == null) { diffuse1Indexes = new ByteIndexList(OnResourceChanged, ReadByte, WriteByte, byte.MaxValue, tgiBlocks); } diffuse1Indexes.UnParse(s); if (specular1Indexes == null) { specular1Indexes = new ByteIndexList(OnResourceChanged, ReadByte, WriteByte, byte.MaxValue, tgiBlocks); } specular1Indexes.UnParse(s); if (diffuse2Indexes == null) { diffuse2Indexes = new ByteIndexList(OnResourceChanged, ReadByte, WriteByte, byte.MaxValue, tgiBlocks); } diffuse2Indexes.UnParse(s); if (specular2Indexes == null) { specular2Indexes = new ByteIndexList(OnResourceChanged, ReadByte, WriteByte, byte.MaxValue, tgiBlocks); } specular2Indexes.UnParse(s); if (bondIndexes == null) { bondIndexes = new ByteIndexList(OnResourceChanged, ReadByte, WriteByte, byte.MaxValue, tgiBlocks); } bondIndexes.UnParse(s); BigEndianUnicodeString.Write(s, unknown4); tgiPosn = s.Position; w.Write((byte)tgiBlocks.Count); tgiBlocks.UnParse(s); end = s.Position; s.Position = posn; w.Write((int)(tgiPosn - posn - sizeof(int))); s.Position = end; vpxyIndexes.ParentTGIBlocks = diffuse1Indexes.ParentTGIBlocks = specular1Indexes.ParentTGIBlocks = diffuse2Indexes.ParentTGIBlocks = specular2Indexes.ParentTGIBlocks = bondIndexes.ParentTGIBlocks = tgiBlocks; s.Flush(); return(s); }
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); }
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(); } }