This sets Waypoints contents to the list of waypoints that must be passed to travel from sector SectorBegin to SectorEnd.
Special cases: when either SectorBegin or SectorEnd are nil (this can easily happen if you pass here results of SectorWithPoint method), or when SectorBegin = SectorEnd, or when there is no possible way, it returns False and just clears Waypoints (i.e. sets Waypoints.Count to 0).
Otherwise (if a way is found) it returns True and sets Waypoints items as appropriate. The order of Waypoints is significant: starting from SectorBegin, you should first travel to Waypoints[0], then to Waypoints[1] etc. In this case for sure we have at least one Waypoint.
(So the result of this function is actually just a comfortable thing, you can get the same result just checking Waypoints.Count <> 0)
TODO: This should use breadth-first search. Right now it uses depth-first search. For small sectors+waypoints graphs it doesn't matter.
|