Esempio n. 1
0
 public Node(NodeStruct node)
 {
     ImportFromStruct(node);
 }
Esempio n. 2
0
        private void WriteNodes(ref Stream s)
        {
            BinaryWriter bw = new BinaryWriter(s);

                NodeStruct node = new NodeStruct();
                for (int i = 0; i < Nodes.Count; i++)
                {
                    node.bestZ = 0.0f;
                    node.id = (ushort)i;
                    node.v.x = (float)Nodes.ElementAt(i).X;
                    node.v.y = (float)Nodes.ElementAt(i).Y;
                    node.v.z = (float)Nodes.ElementAt(i).Z;
                    //node.bestZ = (float)Nodes.ElementAt(i).Z;
                    node.bestZ = Nodes.ElementAt(i).BestZ;

                    //this should probably be removed at some point
                    //and corrected in the path data itself
                    if (node.bestZ == 0)
                    {
                        node.bestZ = node.v.z;
                    }

                    bw.Write(Functions.StructToByteArray(node));

                    int neighborCount = Nodes.ElementAt(i).Neighbors.Count;

                    NeighborStruct neighbor = new NeighborStruct();
                    List<Neighbor> nList = Nodes.ElementAt(i).Neighbors;
                    for (int j = 0; j < 50; j++)
                    {
                        if (j >= neighborCount)
                        {
                            neighbor.id = -1;
                            neighbor.doorId = 0;
                            neighbor.distance = 999999.0F;
                            neighbor.teleport = 0;
                        }
                        else
                        {
                            neighbor.distance = nList.ElementAt(j).Distance;
                            neighbor.doorId = nList.ElementAt(j).DoorId;

                            if (nList.ElementAt(j).Warp) neighbor.teleport = 1;
                            else neighbor.teleport = 0;

                            for (int k = 0; k < Nodes.Count; k++)
                            {
                                if (Nodes.ElementAt(k) == nList.ElementAt(j).Node)
                                {
                                    neighbor.id = (short)k;
                                }
                            }
                        }

                        bw.Write(Functions.StructToByteArray(neighbor));
                    }
                }
        }
Esempio n. 3
0
 public void ImportFromStruct(NodeStruct node)
 {
     _id = node.id;
     _location.X = node.v.x;
     _location.Y = node.v.y;
     _location.Z = node.v.z;
     _bestZ = node.bestZ;
 }