/// <summary> /// Re-evaluates the entire goal map. Should be called when obstacles change. If the /// obstacles have not changed but the goals have, call <see cref="UpdatePathsOnly" /> for better efficiency. /// </summary> /// <returns>False if no goals were produced by the evaluator, true otherwise</returns> public bool Update() { if (BaseMap.Bounds() != this.Bounds()) { throw new InvalidOperationException( $"Grid views used as the {nameof(BaseMap)} for {nameof(GoalMap)} instances must not change size."); } _walkable.Clear(); for (var y = 0; y < BaseMap.Height; ++y) { for (var x = 0; x < BaseMap.Width; ++x) { var state = BaseMap[x, y]; if (state == GoalState.Obstacle) { _goalMap[x, y] = null; } else { _walkable.Add(new Point(x, y)); } } } return(UpdatePathsOnlyUnchecked()); }
/// <summary> /// Re-evaluates the walkable portion of the goal map. Should be called anytime the goals change /// but the obstacles haven't. If the obstacles have also changed, call <see cref="Update" /> instead. /// </summary> /// <returns>False if no goals were produced by the evaluator, true otherwise</returns> public bool UpdatePathsOnly() { if (BaseMap.Bounds() != this.Bounds()) { throw new InvalidOperationException( $"Grid views used as the {nameof(BaseMap)} for {nameof(GoalMap)} instances must not change size."); } return(UpdatePathsOnlyUnchecked()); }