public PsoStructure(PsoFile pso, PsoStructureInfo structureInfo, PsoElementIndexInfo entryIndexInfo, PsoStructureEntryInfo entryInfo) { this.pso = pso; this.structureInfo = structureInfo; this.entryIndexInfo = entryIndexInfo; this.entryInfo = entryInfo; this.Values = new Dictionary <int, IPsoValue>(); }
public static PsoElementIndexInfo GetStructureIndexInfo(PsoFile meta, int structureKey) { PsoElementIndexInfo info = null; for (int i = 0; i < meta.DefinitionSection.Count; i++) { if (meta.DefinitionSection.EntriesIdx[i].NameHash == structureKey) { info = (PsoElementIndexInfo)meta.DefinitionSection.EntriesIdx[i]; } } return(info); }
public PsoFile GetPso() { var pso = new PsoFile(); pso.DefinitionSection = new PsoDefinitionSection(); pso.DataMappingSection = new PsoDataMappingSection(); pso.DataSection = new PsoDataSection(); // DefinitionSection foreach (var si in this.StructureInfos) { PsoElementIndexInfo indexInfo = new PsoElementIndexInfo(); indexInfo.Offset = 0; indexInfo.NameHash = si.Value.IndexInfo.NameHash; pso.DefinitionSection.EntriesIdx.Add(indexInfo); pso.DefinitionSection.Entries.Add(si.Value); } foreach (var ei in this.EnumInfos) { PsoElementIndexInfo indexInfo = new PsoElementIndexInfo(); indexInfo.Offset = 0; indexInfo.NameHash = ei.Value.IndexInfo.NameHash; pso.DefinitionSection.EntriesIdx.Add(indexInfo); pso.DefinitionSection.Entries.Add(ei.Value); } pso.DefinitionSection.Count = (uint)pso.DefinitionSection.Entries.Count; // DataMappingSection pso.DataMappingSection.Entries = new List <PsoDataMappingEntry>(); MemoryStream memoryStream = new MemoryStream(); memoryStream.Position = 16L; byte[] array2 = new byte[memoryStream.Length]; memoryStream.Position = 0L; memoryStream.Read(array2, 0, array2.Length); pso.DataSection.Data = array2; pso.DataMappingSection.RootIndex = 1; return(pso); }
private void MetaBuildEnumInfos(PsoDefinitionXml xmlInfo) { foreach (var xmlEnumInfo in xmlInfo.Enums) { var idxInfo = new PsoElementIndexInfo(); idxInfo.Offset = 0; idxInfo.NameHash = xmlEnumInfo.NameHash; var info = new PsoEnumInfo(); info.Entries = new List <PsoEnumEntryInfo>(); foreach (var xmlEnumEntryInfo in xmlEnumInfo.Entries) { var enumEntryInfo = new PsoEnumEntryInfo(); enumEntryInfo.EntryNameHash = xmlEnumEntryInfo.NameHash; enumEntryInfo.EntryKey = xmlEnumEntryInfo.Value; info.Entries.Add(enumEntryInfo); } meta.DefinitionSection.EntriesIdx.Add(idxInfo); meta.DefinitionSection.Entries.Add(info); } }
private void MetaBuildStructureInfos(PsoDefinitionXml xmlInfo) { //meta.DefinitionSection.EntriesIdx = new List<PsoElementIndexInfo>(); //meta.DefinitionSection.Entries = new List<PsoElementInfo>(); strList = new List <Tuple <int, PsoStructureInfo> >(); foreach (var xmlStructureInfo in xmlInfo.Structures) { var idxInfo = new PsoElementIndexInfo(); idxInfo.Offset = 0; idxInfo.NameHash = xmlStructureInfo.NameHash; var structureInfo = new PsoStructureInfo(); structureInfo.Type = 1; structureInfo.Unk = (byte)xmlStructureInfo.Unknown; structureInfo.StructureLength = xmlStructureInfo.Length; structureInfo.Entries = new List <PsoStructureEntryInfo>(); foreach (var xmlStructureEntryInfo in xmlStructureInfo.Entries) { var xmlArrayTypeStack = new Stack <PsoStructureEntryXml>(); var xmlArrayType = xmlStructureEntryInfo.ArrayType; while (xmlArrayType != null) { xmlArrayTypeStack.Push(xmlArrayType); xmlArrayType = xmlArrayType.ArrayType; } while (xmlArrayTypeStack.Count > 0) { xmlArrayType = xmlArrayTypeStack.Pop(); var arrayStructureEntryInfo = new PsoStructureEntryInfo(); arrayStructureEntryInfo.EntryNameHash = xmlArrayType.NameHash; arrayStructureEntryInfo.Type = (DataType)xmlArrayType.Type; arrayStructureEntryInfo.Unk_5h = (byte)xmlArrayType.Unknown; arrayStructureEntryInfo.DataOffset = (short)xmlArrayType.Offset; if (arrayStructureEntryInfo.Type == DataType.Array) { arrayStructureEntryInfo.ReferenceKey = (short)(structureInfo.Entries.Count - 1); } else { arrayStructureEntryInfo.ReferenceKey = 0; } arrayStructureEntryInfo.ReferenceKey = xmlArrayType.TypeHash; structureInfo.Entries.Add(arrayStructureEntryInfo); } var structureEntryInfo = new PsoStructureEntryInfo(); structureEntryInfo.EntryNameHash = xmlStructureEntryInfo.NameHash; structureEntryInfo.Type = (DataType)xmlStructureEntryInfo.Type; structureEntryInfo.Unk_5h = (byte)xmlStructureEntryInfo.Unknown; structureEntryInfo.DataOffset = (short)xmlStructureEntryInfo.Offset; if (structureEntryInfo.Type == DataType.Array) { structureEntryInfo.ReferenceKey = (short)(structureInfo.Entries.Count - 1); } else { structureEntryInfo.ReferenceKey = 0; } structureEntryInfo.ReferenceKey = xmlStructureEntryInfo.TypeHash; structureInfo.Entries.Add(structureEntryInfo); } strList.Add(new Tuple <int, PsoStructureInfo>(idxInfo.NameHash, structureInfo)); } }