Modding:NPCPathfindingLogic
This class can perform pathfinding logic and store the result. This variant is specifically designed for NPCs and other entities and can be used for them to path to other objects, locations, or the player.
Example code: Pathfinding Sample
Static Public Methods
NPCPathfindingLogic generate(Entity entity)
Creates new pathfinding.
entity - the entity which is using this to pathfind somewhere. (This will be used to determine the start of the path, and will be automatically updated as the entity moves around the map(s))
Public Methods
void setDestination(Location destination)
Sets the place to navigate to. It is recommended to call this again anytime before getting the next direction (before moving). It will not incur a performance penalty to call it if the destination hasn't changed.
Okay to be nil if no destination.
CardinalDirection getNextDirection()
Calculate the route and determine the next direction this NPC would need to take to get there. An existing path is preferred as long as it is still valid.
It is capable of routing between multiple maps, if there is a path to do so.
int getRemainingDistance()
How many rooms distant is the destination from the NPC? Note, this does not update remaining distance, it only gets it as of the last move.