#ifndef PATHFINDING_HPP_INCLUDED #define PATHFINDING_HPP_INCLUDED #include "../../Core/Types/Tile.hpp" #include #include class Pathfinding { public: enum COLLISION_FLAG { OPEN = 0, CLOSED = 0xFFFFFF, UNINITIALIZED = 0x1000000, OCCUPIED = 0x100, SOLID = 0x20000, BLOCKED = 0x200000, NORTH = 0x2, EAST = 0x8, SOUTH = 0x20, WEST = 0x80, NORTHEAST = 0x4, SOUTHEAST = 0x10, SOUTHWEST = 0x40, NORTHWEST = 0x1, BLOCKED_NORTH = 0x400, BLOCKED_EAST = 0x1000, BLOCKED_SOUTH = 0x4000, BLOCKED_WEST = 0x10000, BLOCKED_NORTHEAST = 0x800, BLOCKED_SOUTHEAST = 0x2000, BLOCKED_NORTHWEST = 0x200, BLOCKED_SOUTHWEST = 0x8000, }; typedef enum PATHFINDER { BREADTH_FIRST_SEARCH } PATHFINDER; class TileNode { public: std::int32_t X; std::int32_t Y; std::int32_t Flag; bool Inspected; std::int32_t Parent[2]; TileNode(); TileNode(std::int32_t X, std::int32_t Y, std::int32_t Flag); bool IsBlocked(bool AllowOccupied = true) const; Tile ToWorldTile() const; bool operator==(const TileNode& N) const; operator bool() const; }; static void RegenerateNodes(); static std::vector> GetNodes(); static Tile FindWalkableTile(const Tile& T); static Tile FindWalkableTile(const Tile& T, const Tile& Min, const Tile& Max); static std::vector FindWalkableTiles(const Tile& T); static std::vector FindWalkableTiles(const Tile& T, const Tile& Min, const Tile& Max); static std::vector FindPathTo(const Tile& Goal, bool AllowOccupied = false, PATHFINDER Finder = BREADTH_FIRST_SEARCH); static std::vector FindPathTo(const std::vector& Goals, bool AllowOccupied = false, PATHFINDER Finder = BREADTH_FIRST_SEARCH); // Ignores collision static std::vector FindDirectPathTo(const Tile& Goal, PATHFINDER Finder = BREADTH_FIRST_SEARCH); static std::vector FindDirectPathTo(const std::vector& Goals, PATHFINDER Finder = BREADTH_FIRST_SEARCH); static bool IsInside(std::uint32_t X, std::uint32_t Y); static std::vector GetNeighborsTo(std::uint32_t X, std::uint32_t Y, bool AllowOccupied = false, bool CheckCollision = true); static std::vector Finder_BFS( std::uint32_t StartX, std::uint32_t StartY, std::uint32_t EndX, std::uint32_t EndY, bool AllowOccupied = false, bool CheckCollision = true ); static std::vector Finder_BFS( std::uint32_t StartX, std::uint32_t StartY, const std::vector>& Ends, bool AllowOccupied = false, bool CheckCollision = true ); private: static std::vector> Nodes; }; #endif // PATHFINDING_HPP_INCLUDED