//Utility private int BsaTypeCount(BSA_Entry bsaEntry) { int count = 0; if (bsaEntry.Type0 != null) { count++; } if (bsaEntry.Type1 != null) { count++; } if (bsaEntry.Type2 != null) { count++; } if (bsaEntry.Type3 != null) { count++; } if (bsaEntry.Type4 != null) { count++; } if (bsaEntry.Type6 != null) { count++; } if (bsaEntry.Type7 != null) { count++; } if (bsaEntry.Type8 != null) { count++; } return(count); }
private void WriteTypes(BSA_Entry types, int offsetToFill) { if (BsaTypeCount(types) > 0) { bytes = Utils.ReplaceRange(bytes, BitConverter.GetBytes(bytes.Count() - offsetToFill + 36), offsetToFill); List <int> hdrOffset = new List <int>(); List <int> dataOffset = new List <int>(); List <int> typeList = new List <int>(); //Type Headers if (types.Type0 != null) { var results = WriteTypeHeader(0, types.Type0.Count()); hdrOffset.Add(results[0]); dataOffset.Add(results[1]); typeList.Add(0); } if (types.Type1 != null) { var results = WriteTypeHeader(1, types.Type1.Count()); hdrOffset.Add(results[0]); dataOffset.Add(results[1]); typeList.Add(1); } if (types.Type2 != null) { var results = WriteTypeHeader(2, types.Type2.Count()); hdrOffset.Add(results[0]); dataOffset.Add(results[1]); typeList.Add(2); } if (types.Type3 != null) { var results = WriteTypeHeader(3, types.Type3.Count()); hdrOffset.Add(results[0]); dataOffset.Add(results[1]); typeList.Add(3); } if (types.Type4 != null) { var results = WriteTypeHeader(4, types.Type4.Count()); hdrOffset.Add(results[0]); dataOffset.Add(results[1]); typeList.Add(4); } if (types.Type6 != null) { var results = WriteTypeHeader(6, types.Type6.Count()); hdrOffset.Add(results[0]); dataOffset.Add(results[1]); typeList.Add(6); } if (types.Type7 != null) { var results = WriteTypeHeader(7, types.Type7.Count()); hdrOffset.Add(results[0]); dataOffset.Add(results[1]); typeList.Add(7); } if (types.Type8 != null) { var results = WriteTypeHeader(8, types.Type8.Count()); hdrOffset.Add(results[0]); dataOffset.Add(results[1]); typeList.Add(8); } //Type Data for (int i = 0; i < typeList.Count(); i++) { switch (typeList[i]) { case 0: WriteType0(types.Type0, hdrOffset[i], dataOffset[i]); break; case 1: WriteType1(types.Type1, hdrOffset[i], dataOffset[i]); break; case 2: WriteType2(types.Type2, hdrOffset[i], dataOffset[i]); break; case 3: WriteType3(types.Type3, hdrOffset[i], dataOffset[i]); break; case 4: WriteType4(types.Type4, hdrOffset[i], dataOffset[i]); break; case 6: WriteType6(types.Type6, hdrOffset[i], dataOffset[i]); break; case 7: WriteType7(types.Type7, hdrOffset[i], dataOffset[i]); break; case 8: WriteType8(types.Type8, hdrOffset[i], dataOffset[i]); break; } } } }