Pathfinding.GridNode.GetIndex C# (CSharp) Method

GetIndex() private method

private GetIndex ( ) : int
return int
		public int GetIndex () { return 0; }
		

Usage Example

Ejemplo n.º 1
0
		/** Calculates the grid connections for a single node */
		public virtual void CalculateConnections (GridNode[] graphNodes, int x, int z, GridNode node) {
			
			//Reset all connections
			node.flags = node.flags & -256;
			
			//All connections are disabled if the node is not walkable
			if (!node.walkable) {
				return;
			}
			
			int index = node.GetIndex ();
			
			if (corners == null) {
				corners = new int[4];
			} else {
				for (int i = 0;i<4;i++) {
					corners[i] = 0;
				}
			}
			
			for (int i=0, j = 3; i<4; j = i, i++) {
				
				int nx = x + neighbourXOffsets[i];
				int nz = z + neighbourZOffsets[i];
				
				if (nx < 0 || nz < 0 || nx >= width || nz >= depth) {
					continue;
				}
				
				GridNode other = graphNodes[index+neighbourOffsets[i]];
				
				if (IsValidConnection (node, other)) {
					node.SetConnectionRaw (i,1);
					
					corners[i]++;
					corners[j]++;
				}
			}
			
			if (neighbours == NumNeighbours.Eight) {
				if (cutCorners) {
					for (int i=0; i<4; i++) {
						
						if (corners[i] >= 1) {
							int nx = x + neighbourXOffsets[i+4];
							int nz = z + neighbourZOffsets[i+4];
						
							if (nx < 0 || nz < 0 || nx >= width || nz >= depth) {
								continue;
							}
					
							GridNode other = graphNodes[index+neighbourOffsets[i+4]];
							
							if (IsValidConnection (node,other)) {
								node.SetConnectionRaw (i+4,1);
							}
						}
					}
				} else {
					for (int i=0; i<4; i++) {
						
						//We don't need to check if it is out of bounds because if both of the other neighbours are inside the bounds this one must be too
						if (corners[i] == 2) {
							GridNode other = graphNodes[index+neighbourOffsets[i+4]];
							
							if (IsValidConnection (node,other)) {
								node.SetConnectionRaw (i+4,1);
							}
						}
					}
				}
			}
			
		}
All Usage Examples Of Pathfinding.GridNode::GetIndex