Exemple #1
0
        // Finds the nearest path element that pairs with the given task
        public bool NearestPathElementWithPair(PathElement origin, PerformerTask task, out PathElement destination)
        {
            GridPoint point = ConnectionToPoint(origin);

            destination = Pathfinder.FindNearestPoint(
                point,
                (GridPoint p) => { return(TaskMatcher.GetPair(task, p) != null); }
                );
            return(destination != null);
        }
Exemple #2
0
        // Finds a pair for the given task
        public bool PairFromTask(PerformerTask task, PathElement currentElement, PathElement previousElement, out PathElement destination)
        {
            // Early out if task does not require a pair
            if (task.Settings.Pair == null)
            {
                destination = null;
                return(false);
            }

            bool gotoPrevious = !task.Settings.AlwaysPairNearest &&
                                previousElement != null &&
                                TaskMatcher.GetPair(task, previousElement) != null;

            if (gotoPrevious)
            {
                destination = previousElement;
                return(true);
            }

            return(NearestPathElementWithPair(currentElement, task, out destination));
        }