Pathfinding.LayerGridGraph.GetNearestNode C# (CSharp) Method

GetNearestNode() private method

private GetNearestNode ( Vector3 position, int x, int z, NNConstraint constraint ) : LevelGridNode
position UnityEngine.Vector3
x int
z int
constraint NNConstraint
return LevelGridNode
		private LevelGridNode GetNearestNode (Vector3 position, int x, int z, NNConstraint constraint) {
			
			
			int index = width*z+x;
			float minDist = float.PositiveInfinity;
			LevelGridNode minNode = null;
			for (int i=0;i<layerCount;i++) {
				LevelGridNode node = nodes[index + width*depth*i];
				if (node != null) {
					float dist =  ((Vector3)node.position - position).sqrMagnitude;
					if (dist < minDist && constraint.Suitable (node)) {
						minDist = dist;
						minNode = node;
					}
				}
			}
			return minNode;
		}