Example #1
0
 /// <summary>
 /// Plots a course and notifies the fleet of the outcome via Fleet.OnCoursePlotComplete().
 /// </summary>
 /// <param name="destination">The destination.</param>
 public void PlotCourse(Vector3 destination) {
     IsFinalDestinationReached = false;
     if (!destination.IsSameAs(Destination)) {
         Destination = destination;
     }
     else {
         GenerateCourse();
     }
 }
Example #2
0
 /// <summary>
 /// Checks whether the pilot can approach the provided location directly.
 /// </summary>
 /// <param name="location">The location to approach.</param>
 /// <returns>
 ///   <c>true</c> if there is nothing obstructing a direct approach.
 /// </returns>
 private bool CheckApproachTo(Vector3 location) {
     Vector3 currentPosition = _data.Position;
     Vector3 vectorToLocation = location - currentPosition;
     float distanceToLocation = vectorToLocation.magnitude;
     float closeEnoughDistance = location.IsSameAs(_targetInfo.Destination) ? _targetInfo.CloseEnoughDistance : _waypointCloseEnoughDistance;
     if (distanceToLocation < closeEnoughDistance) {
         // already inside close enough distance
         return true;
     }
     Vector3 directionToLocation = vectorToLocation.normalized;
     float rayDistance = distanceToLocation - closeEnoughDistance;
     float clampedRayDistance = Mathf.Clamp(rayDistance, 0.1F, Mathf.Infinity);
     RaycastHit hitInfo;
     if (Physics.Raycast(currentPosition, directionToLocation, out hitInfo, clampedRayDistance, _keepoutOnlyLayerMask.value)) {
         D.Log("{0} encountered obstacle {1} when checking approach to {2}.", _ship.FullName, hitInfo.collider.name, location);
         // there is a keepout zone obstacle in the way 
         return false;
     }
     return true;
 }