private List <IBD_Effect> ParseEffect(int offset) { List <IBD_Effect> effects = new List <IBD_Effect>(); for (int i = 0; i < 3; i++) { effects.Add(new IBD_Effect() { I_00 = BitConverter.ToInt32(rawBytes, offset + 0), I_04 = BitConverter.ToInt32(rawBytes, offset + 4), I_08 = BitConverter.ToInt32(rawBytes, offset + 8), F_12 = BitConverter.ToSingle(rawBytes, offset + 12), F_16 = BitConverter_Ex.ToFloat32Array(rawBytes, offset + 16, 6), I_40 = BitConverter.ToInt32(rawBytes, offset + 40), I_44 = BitConverter.ToInt32(rawBytes, offset + 44), F_48 = BitConverter_Ex.ToFloat32Array(rawBytes, offset + 48, 6), I_72 = BitConverter_Ex.ToInt32Array(rawBytes, offset + 72, 6), F_96 = BitConverter.ToSingle(rawBytes, offset + 96), F_100 = BitConverter.ToSingle(rawBytes, offset + 100), F_104 = BitConverter.ToSingle(rawBytes, offset + 104), F_108 = BitConverter.ToSingle(rawBytes, offset + 108), F_112 = BitConverter.ToSingle(rawBytes, offset + 112), F_116 = BitConverter.ToSingle(rawBytes, offset + 116), F_120 = BitConverter.ToSingle(rawBytes, offset + 120), F_124 = BitConverter.ToSingle(rawBytes, offset + 124), F_128 = BitConverter.ToSingle(rawBytes, offset + 128), F_132 = BitConverter.ToSingle(rawBytes, offset + 132), F_136 = BitConverter.ToSingle(rawBytes, offset + 136), F_140 = BitConverter.ToSingle(rawBytes, offset + 140), F_144 = BitConverter.ToSingle(rawBytes, offset + 144), F_148 = BitConverter.ToSingle(rawBytes, offset + 148), F_152 = BitConverter.ToSingle(rawBytes, offset + 152), F_156 = BitConverter_Ex.ToFloat32Array(rawBytes, offset + 156, 17) }); offset += 224; } return(effects); }
private void ParseBac() { int offset = BitConverter.ToInt32(rawBytes, 16); int count = BitConverter.ToInt32(rawBytes, 8); bacFile.I_20 = BitConverter_Ex.ToInt32Array(rawBytes, 20, 3); bacFile.F_32 = BitConverter_Ex.ToFloat32Array(rawBytes, 32, 12); bacFile.I_80 = BitConverter_Ex.ToInt32Array(rawBytes, 80, 4); bacFile.BacEntries = AsyncObservableCollection <BAC_Entry> .Create(); for (int i = 0; i < count; i++) { int typeListOffset = BitConverter.ToInt32(rawBytes, offset + 8); int typeListCount = BitConverter.ToInt16(rawBytes, offset + 4); bacFile.BacEntries.Add(new BAC_Entry() { Flag = (BAC_Entry.Flags)BitConverter.ToUInt32(rawBytes, offset + 0), Index = i.ToString() }); for (int a = 0; a < typeListCount; a++) { int thisType = BitConverter.ToInt16(rawBytes, typeListOffset + 0); int thisTypeCount = BitConverter.ToInt16(rawBytes, typeListOffset + 2); int thisTypeOffset = BitConverter.ToInt32(rawBytes, typeListOffset + 8); if (thisTypeOffset != 0) { switch (thisType) { case 0: bacFile.BacEntries[i].Type0 = BAC_Type0.Read(rawBytes, bytes, thisTypeOffset, thisTypeCount); break; case 1: bacFile.BacEntries[i].Type1 = BAC_Type1.Read(rawBytes, bytes, thisTypeOffset, thisTypeCount); break; case 2: bacFile.BacEntries[i].Type2 = BAC_Type2.Read(rawBytes, bytes, thisTypeOffset, thisTypeCount); break; case 3: bacFile.BacEntries[i].Type3 = BAC_Type3.Read(rawBytes, bytes, thisTypeOffset, thisTypeCount); break; case 4: bacFile.BacEntries[i].Type4 = BAC_Type4.Read(rawBytes, bytes, thisTypeOffset, thisTypeCount); break; case 5: bacFile.BacEntries[i].Type5 = BAC_Type5.Read(rawBytes, bytes, thisTypeOffset, thisTypeCount); break; case 6: bacFile.BacEntries[i].Type6 = BAC_Type6.Read(rawBytes, bytes, thisTypeOffset, thisTypeCount); break; case 7: bacFile.BacEntries[i].Type7 = BAC_Type7.Read(rawBytes, bytes, thisTypeOffset, thisTypeCount); break; case 8: bacFile.BacEntries[i].Type8 = BAC_Type8.Read(rawBytes, bytes, thisTypeOffset, thisTypeCount); break; case 9: bacFile.BacEntries[i].Type9 = BAC_Type9.Read(rawBytes, bytes, thisTypeOffset, thisTypeCount); break; case 10: bacFile.BacEntries[i].Type10 = BAC_Type10.Read(rawBytes, bytes, thisTypeOffset, thisTypeCount); break; case 11: bacFile.BacEntries[i].Type11 = BAC_Type11.Read(rawBytes, bytes, thisTypeOffset, thisTypeCount); break; case 12: bacFile.BacEntries[i].Type12 = BAC_Type12.Read(rawBytes, bytes, thisTypeOffset, thisTypeCount); break; case 13: bacFile.BacEntries[i].Type13 = BAC_Type13.Read(rawBytes, bytes, thisTypeOffset, thisTypeCount); break; case 14: bacFile.BacEntries[i].Type14 = BAC_Type14.Read(rawBytes, bytes, thisTypeOffset, thisTypeCount); break; case 15: bacFile.BacEntries[i].Type15 = BAC_Type15.Read(rawBytes, bytes, thisTypeOffset, thisTypeCount); break; case 16: bacFile.BacEntries[i].Type16 = BAC_Type16.Read(rawBytes, bytes, thisTypeOffset, thisTypeCount); break; case 17: bacFile.BacEntries[i].Type17 = BAC_Type17.Read(rawBytes, bytes, thisTypeOffset, thisTypeCount, IsType17Small(thisTypeOffset, thisTypeCount, i)); break; case 18: bacFile.BacEntries[i].Type18 = BAC_Type18.Read(rawBytes, bytes, thisTypeOffset, thisTypeCount); break; case 19: bacFile.BacEntries[i].Type19 = BAC_Type19.Read(rawBytes, bytes, thisTypeOffset, thisTypeCount); break; case 20: bacFile.BacEntries[i].Type20 = BAC_Type20.Read(rawBytes, bytes, thisTypeOffset, thisTypeCount); break; case 21: bacFile.BacEntries[i].Type21 = BAC_Type21.Read(rawBytes, bytes, thisTypeOffset, thisTypeCount); break; case 22: bacFile.BacEntries[i].Type22 = BAC_Type22.Read(rawBytes, bytes, thisTypeOffset, thisTypeCount); break; case 23: bacFile.BacEntries[i].Type23 = BAC_Type23.Read(rawBytes, bytes, thisTypeOffset, thisTypeCount); break; case 24: bacFile.BacEntries[i].Type24 = BAC_Type24.Read(rawBytes, bytes, thisTypeOffset, thisTypeCount); break; case 25: bacFile.BacEntries[i].Type25 = BAC_Type25.Read(rawBytes, bytes, thisTypeOffset, thisTypeCount); break; case 26: bacFile.BacEntries[i].Type26 = BAC_Type26.Read(rawBytes, bytes, thisTypeOffset, thisTypeCount); break; case 27: bacFile.BacEntries[i].Type27 = BAC_Type27.Read(rawBytes, bytes, thisTypeOffset, thisTypeCount); break; default: throw new InvalidDataException(String.Format("Parse failed. Unknown BacType encountered ({0})\nOffset: {1}\nCount: {2}.", thisType, thisTypeOffset, thisTypeCount)); } } else { if (bacFile.BacEntries[i].TypeDummy == null) { bacFile.BacEntries[i].TypeDummy = new List <int>(); } bacFile.BacEntries[i].TypeDummy.Add(thisType); } typeListOffset += 16; } offset += 16; } }
private void Parse() { //counts int partsetCount = BitConverter.ToInt16(rawBytes, 12); int partcolorsCount = BitConverter.ToInt16(rawBytes, 14); int bodyCount = BitConverter.ToInt16(rawBytes, 16); //offsets int partsetOffset = BitConverter.ToInt32(rawBytes, 24); int partcolorsOffset = BitConverter.ToInt32(rawBytes, 28); int bodyOffset = BitConverter.ToInt32(rawBytes, 32); int skeleton2Offset = BitConverter.ToInt32(rawBytes, 36); int skeleton1Offset = BitConverter.ToInt32(rawBytes, 40); //Header byte[] _I_44 = rawBytes.GetRange(44, 4); bcsFile.Race = _I_44[0]; bcsFile.Sex = Convert.ToBoolean(_I_44[1]); bcsFile.F_48 = BitConverter_Ex.ToFloat32Array(rawBytes, 48, 7); //PartSets int actualIndex = 0; if (partsetCount > 0) { bcsFile.PartSets = new List <PartSet>(); for (int i = 0; i < partsetCount; i++) { int thisPartsetOffset = BitConverter.ToInt32(rawBytes, partsetOffset); if (thisPartsetOffset != 0) { bcsFile.PartSets.Add(new PartSet() { Index = i.ToString() }); if (BitConverter.ToInt32(rawBytes, thisPartsetOffset + 20) != 10) { throw new Exception(string.Format("Part count mismatch on PartSet {0} (Expected 10, but found {1})\nThis BCS file cannot be parsed.", i, BitConverter.ToInt32(rawBytes, thisPartsetOffset + 20))); } int tableOffset = thisPartsetOffset + BitConverter.ToInt32(rawBytes, thisPartsetOffset + 24); bcsFile.PartSets[actualIndex].FaceBase = ParsePart(BitConverter.ToInt32(rawBytes, tableOffset + 0), thisPartsetOffset); bcsFile.PartSets[actualIndex].FaceForehead = ParsePart(BitConverter.ToInt32(rawBytes, tableOffset + 4), thisPartsetOffset); bcsFile.PartSets[actualIndex].FaceEye = ParsePart(BitConverter.ToInt32(rawBytes, tableOffset + 8), thisPartsetOffset); bcsFile.PartSets[actualIndex].FaceNose = ParsePart(BitConverter.ToInt32(rawBytes, tableOffset + 12), thisPartsetOffset); bcsFile.PartSets[actualIndex].FaceEar = ParsePart(BitConverter.ToInt32(rawBytes, tableOffset + 16), thisPartsetOffset); bcsFile.PartSets[actualIndex].Hair = ParsePart(BitConverter.ToInt32(rawBytes, tableOffset + 20), thisPartsetOffset); bcsFile.PartSets[actualIndex].Bust = ParsePart(BitConverter.ToInt32(rawBytes, tableOffset + 24), thisPartsetOffset); bcsFile.PartSets[actualIndex].Pants = ParsePart(BitConverter.ToInt32(rawBytes, tableOffset + 28), thisPartsetOffset); bcsFile.PartSets[actualIndex].Rist = ParsePart(BitConverter.ToInt32(rawBytes, tableOffset + 32), thisPartsetOffset); bcsFile.PartSets[actualIndex].Boots = ParsePart(BitConverter.ToInt32(rawBytes, tableOffset + 36), thisPartsetOffset); actualIndex++; } partsetOffset += 4; } } //PartColors if (partcolorsCount > 0) { bcsFile.Part_Colors = new List <PartColor>(); for (int i = 0; i < partcolorsCount; i++) { int thisPartColorOffset = BitConverter.ToInt32(rawBytes, partcolorsOffset); if (thisPartColorOffset != 0) { bcsFile.Part_Colors.Add(new PartColor() { Index = i.ToString(), Str_00 = Utils.GetString(bytes, BitConverter.ToInt32(rawBytes, thisPartColorOffset + 0) + thisPartColorOffset), _Colors = ParseColors(BitConverter.ToInt32(rawBytes, thisPartColorOffset + 12) + thisPartColorOffset, BitConverter.ToInt16(rawBytes, thisPartColorOffset + 10)) }); } partcolorsOffset += 4; } } //BodyScales if (bodyCount > 0) { bcsFile.Bodies = new List <Body>(); for (int i = 0; i < bodyCount; i++) { int thisBodyScaleOffset = BitConverter.ToInt32(rawBytes, bodyOffset); if (thisBodyScaleOffset != 0) { bcsFile.Bodies.Add(ParseBody(thisBodyScaleOffset, i)); } bodyOffset += 4; } } if (skeleton1Offset != 0) { bcsFile.SkeletonData1 = ParseSkeleton(BitConverter.ToInt32(rawBytes, skeleton1Offset)); } if (skeleton2Offset != 0) { bcsFile.SkeletonData2 = ParseSkeleton(BitConverter.ToInt32(rawBytes, skeleton2Offset)); } }