Have PathFinder.search return index of destination goal



  • When passing an array of goals to PathFinder.search, it would be very useful if the returned object included the index of the selected goal. This would save CPU when you need to determine the object associated with the returned path. Currently you have to search using the last room position in the path which gets messy when using a range and multiple object types.

    👍


  • I agree the addition to the return value would be nice. I never pass game objects into a pathfinder. It's always an array of destinations (range,pos) even if it's a single destination. Associating the returned path with index of the destination was straightforward in my case and not terribly cpu intensive. My wrapper then returns the index so my higher level logic knows which target was selected.

    It get's a little hairy when the pathfinding fails but that corner case is hard no matter how you handle it.

    If the plugin did the index tracking it would be noticeably faster only when there are large number of destinations (>100 i'd guess, but for sure >10). Changing the plugin is a tall order.