Beispiel #1
0
 private static void WriteParamObject(TextWriter writer, ParamObject paramObj, int IndentAmount)
 {
     writer.WriteLine($"{YamlHashStr(paramObj.HashString)} : !obj".Indent(IndentAmount));
     foreach (var entry in paramObj.paramEntries)
     {
         writer.WriteLine($"{WriteParamData(entry)}".Indent(IndentAmount + 2));
     }
 }
Beispiel #2
0
        private void WriteObject(FileWriter writer, ParamObject paramObj)
        {
            TotalObjCount += 1;
            int EntryCount = paramObj.paramEntries == null ? 0 : paramObj.paramEntries.Length;

            long startPosition = writer.Position;

            writer.Write(paramObj.Hash);
            var paramEntry = WritePlaceholderOffsetU16(writer, startPosition);

            writer.Write((ushort)EntryCount);

            _savedParamObjects.Add(new ObjectContext()
            {
                ParamObject      = paramObj,
                PlaceholderOffet = paramEntry,
            });
        }
        internal static void Write(ParamObject entry, FileWriter writer)
        {
            int EntryCount = entry.paramEntries == null ? 0 : entry.paramEntries.Length;

            long startPosition = writer.Position;

            writer.Write(uint.MaxValue); //Write the size after
            writer.Write(EntryCount);
            writer.Write(entry.Hash);
            writer.Write(entry.GroupHash);

            for (int i = 0; i < EntryCount; i++)
            {
                ParamEntryV1.Write(entry.paramEntries[i], writer);
            }

            writer.WriteSize(writer.Position, startPosition);
        }
Beispiel #4
0
        private static ParamObject ParseParamObject(YamlScalarNode node, YamlNode valueNode)
        {
            ParamObject paramObject = new ParamObject();

            paramObject.Hash = ParseHash(node.Value);

            List <ParamEntry> entries = new List <ParamEntry>();

            if (valueNode is YamlMappingNode)
            {
                foreach (var child in ((YamlMappingNode)valueNode).Children)
                {
                    entries.Add(ParseParamEntry(((YamlScalarNode)child.Key).Value, child.Value));
                }
            }

            paramObject.paramEntries = entries.ToArray();
            return(paramObject);
        }
        internal static ParamObject Read(FileReader reader)
        {
            ParamObject entry = new ParamObject();

            long CurrentPosition = reader.Position;

            uint Size       = reader.ReadUInt32();
            uint EntryCount = reader.ReadUInt32();

            entry.Hash      = reader.ReadUInt32();
            entry.GroupHash = reader.ReadUInt32();

            entry.paramEntries = new ParamEntry[EntryCount];
            for (int i = 0; i < EntryCount; i++)
            {
                entry.paramEntries[i] = ParamEntryV1.Read(reader);
            }

            reader.Seek(CurrentPosition + Size, SeekOrigin.Begin);
            return(entry);
        }
        internal static ParamObject Read(FileReader reader)
        {
            ParamObject entry = new ParamObject();

            long CurrentPosition = reader.Position;

            entry.Hash = reader.ReadUInt32();
            ushort ChildOffset = reader.ReadUInt16();
            ushort ChildCount  = reader.ReadUInt16();

            if (ChildOffset != 0)
            {
                using (reader.TemporarySeek(ChildOffset * 4 + CurrentPosition, SeekOrigin.Begin))
                {
                    entry.paramEntries = new ParamEntry[ChildCount];
                    for (int i = 0; i < ChildCount; i++)
                    {
                        entry.paramEntries[i] = ParamEntryV2.Read(reader);
                    }
                }
            }
            return(entry);
        }