public static Movable ClosestReachableMovable(this Movable seeker, float maxDistance = float.MaxValue, Predicate <Movable> candidateValidator = null, List <Movable> candidates = null) { Predicate <Movable> predicate = null; if (candidateValidator == null) { predicate = mov => seeker.CanReach(mov); } else { predicate = mov => seeker.CanReach(mov) && candidateValidator(mov); } return(ClosestMovable(seeker, maxDistance, predicate, candidates)); }
public int[] ShortestDepotPath(int[] startInd, Movable mover) { int[] shortestInd = null; float shortestLen = Mathf.Infinity; foreach (int[] stopInd in depots) { float len = mover.TravelDistance (stopInd); if (len < shortestLen && mover.CanReach (stopInd)) { shortestInd = stopInd; shortestLen = len; } } return shortestInd; }