Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WalkPlan"/> class.
        /// </summary>
        /// <param name="strategy">The strategy of the plan.</param>
        /// <param name="goalDeterminationFunction">A function used to determine the goal of this plan.</param>
        /// <param name="goalDistance">The distance to consider the walk plan at goal.</param>
        /// <param name="startingWaypoints">The waypoints already known to the goal.</param>
        public WalkPlan(WalkPlanStrategy strategy, Func <Location> goalDeterminationFunction, int goalDistance = 1, params Location[] startingWaypoints)
        {
            goalDeterminationFunction.ThrowIfNull(nameof(goalDeterminationFunction));

            this.Strategy           = strategy;
            this.GetGoalLocation    = goalDeterminationFunction;
            this.GoalTargetDistance = goalDistance;

            this.Waypoints = new LinkedList <Location>(startingWaypoints);

            this.consecutiveRecalculations = 0;
            this.State = this.Waypoints.Count > 0 ? WalkPlanState.OnTrack : WalkPlanState.NeedsToRecalculate;
        }
Example #2
0
 /// <summary>
 /// Checks if a given walk strategy is considered static.
 /// </summary>
 /// <param name="strategy">The strategy to evaluate.</param>
 /// <returns>True if the strategy is considered static, false otherwise.</returns>
 public static bool IsStatic(this WalkPlanStrategy strategy)
 {
     return(strategy == WalkPlanStrategy.DoNotRecalculate || strategy == WalkPlanStrategy.RecalculateOnInterruption);
 }