Exemplo n.º 1
0
        private Path ReadPath(BinaryReader br)
        {
            var path = new Path
            {
                Name      = br.ReadFixedLengthString(Encoding.ASCII, 128),
                Type      = br.ReadFixedLengthString(Encoding.ASCII, 128),
                Direction = (Path.PathDirection)br.ReadInt32()
            };
            var numNodes = br.ReadInt32();

            for (var i = 0; i < numNodes; i++)
            {
                var node = new Path.PathNode
                {
                    Position = br.ReadVector3(),
                    ID       = br.ReadInt32(),
                    Name     = br.ReadFixedLengthString(Encoding.ASCII, 128)
                };

                var numProps = br.ReadInt32();
                for (var j = 0; j < numProps; j++)
                {
                    var key   = br.ReadCString();
                    var value = br.ReadCString();
                    node.Properties[key] = value;
                }
                path.Nodes.Add(node);
            }
            return(path);
        }
Exemplo n.º 2
0
 private void WritePath(BinaryWriter bw, Path path)
 {
     bw.WriteFixedLengthString(Encoding.ASCII, 128, path.Name);
     bw.WriteFixedLengthString(Encoding.ASCII, 128, path.Type);
     bw.Write((int)path.Direction);
     bw.Write(path.Nodes.Count);
     foreach (var node in path.Nodes)
     {
         bw.WriteVector3(node.Position);
         bw.Write(node.ID);
         bw.WriteFixedLengthString(Encoding.ASCII, 128, node.Name);
         bw.Write(node.Properties.Count);
         foreach (var property in node.Properties)
         {
             bw.WriteCString(property.Key, MaxVariableStringLength);
             bw.WriteCString(property.Value, MaxVariableStringLength);
         }
     }
 }