Pathfinding.GridGraph.DeSerializeNodes C# (CSharp) Method

DeSerializeNodes() private method

private DeSerializeNodes ( Pathfinding.Node nodes, AstarSerializer serializer ) : void
nodes Pathfinding.Node
serializer AstarSerializer
return void
        public void DeSerializeNodes(Node[] nodes, AstarSerializer serializer)
        {
            /*for (int i=0;i<nodes.Length;i++) {
                GridNode node = nodes[i] as GridNode;

                if (node == null) {
                    Debug.LogError ("DeSerialization Error : Couldn't cast the node to the appropriate type - GridGenerator");
                    return;
                }*/

            GenerateMatrix ();

            SetUpOffsetsAndCosts ();

            if (nodes == null || nodes.Length == 0) {
                return;
            }

            nodes = new GridNode[nodes.Length];

            int gridIndex = GridNode.SetGridGraph (this);

            int numberSize = (int)serializer.readerStream.ReadByte ();

            for (int z = 0; z < depth; z ++) {
                for (int x = 0; x < width; x++) {

                    GridNode node = nodes[z*width+x] as GridNode;

                    nodes[z*width+x] = node;

                    if (node == null) {
                        Debug.LogError ("DeSerialization Error : Couldn't cast the node to the appropriate type - GridGenerator");
                        return;
                    }

                    node.SetIndex  (z*width+x);
                    node.SetGridIndex (gridIndex);

                    float yPos = 0;

                    //if (serializer.mask == AstarSerializer.SMask.SaveNodePositions) {
                        //Needs to multiply with precision factor because the position will be scaled by Int3.Precision later (Vector3 --> Int3 conversion)
                    if (numberSize == 0) {
                        yPos = serializer.readerStream.ReadInt16 ();
                    } else {
                        yPos = serializer.readerStream.ReadInt32 ();
                    }
                    //}

                    node.position = (Int3)matrix.MultiplyPoint3x4 (new Vector3 (x+0.5F,yPos,z+0.5F));
                }
            }
        }