private DetourElement GetNewDetourElement(BaseMonoEntity entity, Vector3 sourcePosition, Vector3 targetPosition) { NavMeshPath path = new NavMeshPath(); bool flag = NavMesh.CalculatePath(sourcePosition, targetPosition, this._stageAreaWalkMask, path); for (int i = 0; i < (path.corners.Length - 1); i++) { Debug.DrawLine(path.corners[i], path.corners[i + 1], Color.green, 0.1f); } this._getPathNumPerFrame++; DetourElement element = new DetourElement { id = entity.GetRuntimeID(), targetPosition = targetPosition, isCompletePath = flag, lastGetPathTime = Time.time }; Vector3[] vectorArray = this.SimplifyPath(sourcePosition, path); if (vectorArray.Length == 0) { return(null); } CapsuleCollider componentInChildren = entity.GetComponentInChildren <CapsuleCollider>(); if (componentInChildren != null) { element.disReachCornerThreshold = componentInChildren.radius; } else { element.disReachCornerThreshold = this._disReachCornerThreshold; } element.corners = vectorArray; element.targetCornerIndex = 0; return(element); }