public PsoFile GetPso() { PsoFile pso = new PsoFile(); pso.SchemaSection = new PsoSchemaSection(); var schEntries = new List <PsoElementInfo>(); foreach (var structInfo in StructureInfos.Values) { schEntries.Add(structInfo); } foreach (var enumInfo in EnumInfos.Values) { schEntries.Add(enumInfo); } pso.SchemaSection.Entries = schEntries.ToArray(); pso.SchemaSection.EntriesIdx = new PsoElementIndexInfo[schEntries.Count]; for (int i = 0; i < schEntries.Count; i++) { pso.SchemaSection.EntriesIdx[i] = new PsoElementIndexInfo(); pso.SchemaSection.EntriesIdx[i].NameHash = schEntries[i].IndexInfo.NameHash; } if (STRFStrings.Count > 0) { pso.STRFSection = new PsoSTRFSection(); pso.STRFSection.Strings = STRFStrings.ToArray(); } if (STRSStrings.Count > 0) { pso.STRSSection = new PsoSTRSSection(); pso.STRSSection.Strings = STRSStrings.ToArray(); } pso.DataSection = new PsoDataSection(); pso.DataSection.Data = GetData(); pso.DataMapSection = new PsoDataMapSection(); pso.DataMapSection.Entries = new PsoDataMappingEntry[Blocks.Count]; pso.DataMapSection.RootId = RootPointer.BlockID; var offset = 16; for (int i = 0; i < Blocks.Count; i++) { var b = Blocks[i]; var e = new PsoDataMappingEntry(); e.NameHash = b.StructureNameHash; e.Length = b.TotalSize; e.Offset = offset; offset += b.TotalSize; pso.DataMapSection.Entries[i] = e; } return(pso); }
public void Read(DataReader reader) { Ident = reader.ReadInt32(); Length = reader.ReadInt32(); RootId = reader.ReadInt32(); EntriesCount = reader.ReadInt16(); Unknown_Eh = reader.ReadInt16(); Entries = new PsoDataMappingEntry[EntriesCount]; for (int i = 0; i < EntriesCount; i++) { var entry = new PsoDataMappingEntry(); entry.Read(reader); Entries[i] = entry; } }
public PsoDataMappingEntry GetBlock(int id) { if (DataMapSection == null) { return(null); } if (DataMapSection.Entries == null) { return(null); } PsoDataMappingEntry block = null; var ind = id - 1; var blocks = DataMapSection.Entries; if ((ind >= 0) && (ind < blocks.Length)) { block = blocks[ind]; } return(block); }
public void Read(DataReader reader) { Ident = reader.ReadInt32(); Length = reader.ReadInt32(); RootId = reader.ReadInt32(); EntriesCount = reader.ReadInt16(); Unknown_Eh = reader.ReadInt16(); if (EntriesCount <= 0) //any other way to know which version? { EntriesCount = reader.ReadInt16(); var unk1 = reader.ReadInt16(); var unk2 = reader.ReadInt16(); var unk3 = reader.ReadInt16(); } Entries = new PsoDataMappingEntry[EntriesCount]; for (int i = 0; i < EntriesCount; i++) { var entry = new PsoDataMappingEntry(); entry.Read(reader); Entries[i] = entry; } }