Pathfinding.LevelGridNode.UpdateRecursiveG C# (CSharp) Method

UpdateRecursiveG() public method

public UpdateRecursiveG ( Path path, PathNode pathNode, PathHandler handler ) : void
path Path
pathNode PathNode
handler PathHandler
return void
		public override void UpdateRecursiveG (Path path, PathNode pathNode, PathHandler handler) {
			//BaseUpdateAllG (nodeR, nodeRunData);
			
			handler.PushNode (pathNode);
			UpdateG (path, pathNode);
			
			LayerGridGraph graph = GetGridGraph (GraphIndex);
			int[] neighbourOffsets = graph.neighbourOffsets;
			LevelGridNode[] nodes = graph.nodes;
			int index = NodeInGridIndex;
			
			for (int i=0;i<4;i++) {
				int conn = GetConnectionValue(i);//(gridConnections >> i*4) & 0xF;
				if (conn != LevelGridNode.NoConnection) {
					
					LevelGridNode other = nodes[index+neighbourOffsets[i] + graph.width*graph.depth*conn];
					PathNode otherPN = handler.GetPathNode (other);
					
					if (otherPN != null && otherPN.parent == pathNode && otherPN.pathID == handler.PathID) {
						other.UpdateRecursiveG (path, otherPN,handler);
					}
				}
			}
		}
		

Usage Example

Ejemplo n.º 1
0
        public override void UpdateRecursiveG(Path path, PathNode pathNode, PathHandler handler)
        {
            handler.heap.Add(pathNode);
            base.UpdateG(path, pathNode);
            LayerGridGraph gridGraph = LevelGridNode.GetGridGraph(base.GraphIndex);

            int[]           neighbourOffsets = gridGraph.neighbourOffsets;
            LevelGridNode[] nodes            = gridGraph.nodes;
            int             nodeInGridIndex  = base.NodeInGridIndex;

            for (int i = 0; i < 4; i++)
            {
                int connectionValue = this.GetConnectionValue(i);
                if (connectionValue != 255)
                {
                    LevelGridNode levelGridNode = nodes[nodeInGridIndex + neighbourOffsets[i] + gridGraph.lastScannedWidth * gridGraph.lastScannedDepth * connectionValue];
                    PathNode      pathNode2     = handler.GetPathNode(levelGridNode);
                    if (pathNode2 != null && pathNode2.parent == pathNode && pathNode2.pathID == handler.PathID)
                    {
                        levelGridNode.UpdateRecursiveG(path, pathNode2, handler);
                    }
                }
            }
            base.UpdateRecursiveG(path, pathNode, handler);
        }