52 virtual float getWalkCost(
int xFrom,
int yFrom,
int xTo,
int yTo,
void* userData)
const = 0;
179 std::swap(data, rhs.data);
180 std::swap(cppData, rhs.cppData);
183 std::swap(data, rhs.data);
184 std::swap(cppData, rhs.cppData);
322 void getDestination(
int *x,
int *y)
const;
395 void get(
int index,
int *x,
int *y)
const;
492 bool walk(
int *x,
int *y,
bool recalculateWhenNeeded);
495 friend float TCOD_path_func(
int xFrom,
int yFrom,
int xTo,
int yTo,
void *data);
504class TCODLIB_API TCODDijkstra {
506 TCODDijkstra (
TCODMap *map,
float diagonalCost=1.41f);
507 TCODDijkstra (
int width,
int height,
const ITCODPathCallback *listener,
void *userData,
float diagonalCost=1.41f);
509 TCODDijkstra(
const TCODDijkstra&) =
delete;
510 TCODDijkstra& operator=(
const TCODDijkstra&) =
delete;
511 TCODDijkstra(TCODDijkstra&& rhs)
noexcept {
512 std::swap(data, rhs.data);
513 std::swap(cppData, rhs.cppData);
515 TCODDijkstra& operator=(TCODDijkstra&& rhs)
noexcept {
516 std::swap(data, rhs.data);
517 std::swap(cppData, rhs.cppData);
521 ~TCODDijkstra (
void);
581 bool walk (
int *x,
int *y);
582 bool isEmpty()
const;
585 void get(
int index,
int *x,
int *y)
const;
587 TCOD_dijkstra_t data{};
590 const ITCODPathCallback *listener{};
Callback class for defining pathfinding graph edges.
Definition path.hpp:49
void compute(int rootX, int rootY)
In case of Dijkstra, this works in a slightly different way. In order to be able to compute a path,...
bool setPath(int toX, int toY)
After the map is analyzed and all the distances from the root node are known, an unlimited number of ...
float getDistance(int x, int y)
You can get the distance of any set of coordinates from the root node: Note that if the coordinates x...
void get(int index, int *x, int *y) const
You can get the coordinates of each point along the path :void TCODPath::get(int index,...
bool compute(int ox, int oy, int dx, int dy)
Once you created a TCODPath object, you can compute the path between two points:
virtual ~TCODPath()
To release the resources used by a path, destroy it with :TCODPath::~TCODPath() TCODDijkstra::~TCODDi...
void reverse()
Once you computed a path, you can exchange origin and destination :void TCODPath::reverse() void TCOD...
int size() const
You can get the number of steps needed to reach destination :int TCODPath::size() const int TCODDijks...
bool walk(int *x, int *y, bool recalculateWhenNeeded)
You can walk the path and go to the next step with : Note that walking the path consume one step (and...
void getOrigin(int *x, int *y) const
You can read the current origin and destination cells with getOrigin/getDestination....
TCODPath(int width, int height, const ITCODPathCallback *listener, void *userData, float diagonalCost=1.41f)
Since the walkable status of a cell may depend on a lot of parameters (the creature type,...
TCODPath(const TCODMap *map, float diagonalCost=1.41f)
First, you have to allocate a path using a map from the Field of view module.
bool isEmpty() const
If you want a creature to follow the path, a more convenient way is to walk the path : You know when ...
Libtcod A* and Dijkstra pathfinders.