mirror of
https://github.com/orange-cpp/omath.git
synced 2026-04-18 22:43:27 +00:00
added tests improved API
This commit is contained in:
@@ -8,21 +8,39 @@
|
||||
#include <memory>
|
||||
namespace omath::pathfinding
|
||||
{
|
||||
enum class WalkBotStatus
|
||||
{
|
||||
IDLE,
|
||||
PATHING,
|
||||
FINISHED
|
||||
};
|
||||
class WalkBot
|
||||
{
|
||||
public:
|
||||
WalkBot() = default;
|
||||
explicit WalkBot(std::shared_ptr<NavigationMesh> mesh);
|
||||
explicit WalkBot(const std::shared_ptr<NavigationMesh>& mesh, float min_node_distance = 1.f);
|
||||
|
||||
void set_nav_mesh(std::shared_ptr<NavigationMesh> mesh);
|
||||
void set_nav_mesh(const std::shared_ptr<NavigationMesh>& mesh);
|
||||
void set_min_node_distance(float distance);
|
||||
|
||||
void update(const Vector3<float>& bot_position, const Vector3<float>& target_position, float min_node_distance);
|
||||
void set_target(const Vector3<float>& target);
|
||||
|
||||
void on_path(std::function<void(const Vector3<float>&)> callback);
|
||||
// Clear navigation state so the bot can be re-routed without stale
|
||||
// visited-node memory.
|
||||
void reset();
|
||||
|
||||
// Call every game tick with the current bot world position.
|
||||
void update(const Vector3<float>& bot_position);
|
||||
|
||||
void on_path(const std::function<void(const Vector3<float>&)>& callback);
|
||||
void on_status(const std::function<void(WalkBotStatus)>& callback);
|
||||
|
||||
private:
|
||||
std::weak_ptr<NavigationMesh> m_mav_mesh;
|
||||
std::weak_ptr<NavigationMesh> m_nav_mesh;
|
||||
std::optional<std::function<void(const Vector3<float>&)>> m_on_next_path_node;
|
||||
std::optional<std::function<void(WalkBotStatus)>> m_on_status_update;
|
||||
std::optional<Vector3<float>> m_last_visited;
|
||||
std::optional<Vector3<float>> m_target;
|
||||
float m_min_node_distance{1.f};
|
||||
};
|
||||
} // namespace omath::pathfinding
|
||||
Reference in New Issue
Block a user