Exemple #1
0
        public void Execute()
        {
            var size = bounds.size;

            for (int y = 1; y < size.y; y++)
            {
                for (int z = 0; z < size.z; z++)
                {
                    var offset1 = (y * size.z + z) * size.x;
                    var offset2 = ((y + bounds.min.y) * nodeArrayBounds.z + (z + bounds.min.z)) * nodeArrayBounds.x;
                    for (int x = 0; x < size.x; x++)
                    {
                        var shouldHaveNode = math.any(nodeNormals[offset1 + x]);
                        var hasNode        = nodes[offset2 + x] != null;
                        if (shouldHaveNode && !hasNode)
                        {
                            var node = nodes[offset2 + x] = newGridNodeDelegate();
                            active.InitializeNode(node);
                        }
                        else if (!shouldHaveNode && hasNode)
                        {
                            // Clear custom connections first and clear connections from other nodes to this one
                            nodes[offset2 + x].ClearCustomConnections(true);
                            // Clear grid connections without clearing the connections from other nodes to this one (a bit slow)
                            // Since this is inside a graph update we guarantee that the grid connections will be correct at the end
                            // of the update anyway
                            nodes[offset2 + x].ResetConnectionsInternal();
                            nodes[offset2 + x].Destroy();
                            nodes[offset2 + x] = null;
                        }
                    }
                }
            }
        }
Exemple #2
0
		/** Constructor for a graph node. */
		protected GraphNode (AstarPath astar) {
			if (!System.Object.ReferenceEquals(astar, null)) {
				this.nodeIndex = astar.GetNewNodeIndex();
				astar.InitializeNode(this);
			} else {
				throw new System.Exception("No active AstarPath object to bind to");
			}
		}
Exemple #3
0
		// End of fallback
		
		/** Constructor for a graph node. */
		public GraphNode (AstarPath astar) {
			//this.nodeIndex = NextNodeIndex++;
			if (astar != null) {
				this.nodeIndex = astar.GetNewNodeIndex();
				astar.InitializeNode (this);
			} else {
				throw new System.Exception ("No active AstarPath object to bind to");
			}
		}