示例#1
0
        public object Read(NodeEntry node, BinaryReader reader, List <INodeParser> parsers)
        {
            node.Parser = this;
            reader.Skip(4);

            var result = new FactsDB();
            var count  = reader.ReadByte();

            // There should be count many children
            if (count != node.Children.Count)
            {
                throw new InvalidDataException($"Expected {count} FactsTable but found {node.Children.Count}.");
            }

            var parser = parsers.Where(p => p.ParsableNodeName == Constants.NodeNames.FACTS_TABLE).FirstOrDefault();

            Debug.Assert(parser != null);

            foreach (var child in node.Children)
            {
                child.Value = (FactsTable)parser.Read(child, reader, parsers);
                result.FactsTables.Add((FactsTable)child.Value);
            }

            // There is a blob between the last factstable and the next node in questsystem
            result.TrailingBytes = reader.ReadBytes(node.TrailingSize);

            result.Node = node;

            return(result);
        }
示例#2
0
        public object Read(NodeEntry node, BinaryReader reader, List <INodeParser> parsers)
        {
            reader.Skip(4);

            var result = new FactsDB();

            result.FactsTableCount = reader.ReadByte();

            ParserUtils.ParseChildren(node.Children, reader, parsers);

            // There is a blob between the last factstable and the next node in questsystem
            var nextNode = node.GetNextNode();
            var toRead   = nextNode.Offset - reader.BaseStream.Position;

            Debug.Assert(toRead >= 0);
            result.TrailingBytes = reader.ReadBytes((int)toRead);

            return(result);
        }