private bool RunToStop(Func <T, bool> stopIndicator) { bool stop = false; while (queue.HasNext && !stop) { var current = queue.Next(); var steps = current.GetAllNextMoving(); foreach (var step in steps) { if (checker.Check(step)) { queue.Add((T)step.Final); current.Children.Add(step.Final); step.Final.Parent = current; if (!stop && stopIndicator != null) { stop = stopIndicator((T)step.Final); } } } } return(stop); }
public MovingPathFinder(Map map, T start) { if (map == null) { throw new ArgumentNullException("map"); } if (start.IsOverlapping) { throw new ArgumentException("start is overlapping."); } if (!start.IsMeetMap(map)) { throw new ArgumentException("start does not meet the map."); } this.map = map; this.start = start; queue = new StateQueue <T>(); queue.Add(start); checker = new MovingChecker(); }