| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "nav_rid_2d.h" |
| 34 |
|
| 35 |
#include "core/object/class_db.h" |
| 36 |
#include "core/templates/self_list.h" |
| 37 |
|
| 38 |
class NavAgent2D; |
| 39 |
class NavMap2D; |
| 40 |
|
| 41 |
class NavObstacle2D : public NavRid2D { |
| 42 |
NavAgent2D *agent = nullptr; |
| 43 |
NavMap2D *map = nullptr; |
| 44 |
Vector2 velocity; |
| 45 |
Vector2 position; |
| 46 |
Vector<Vector2> vertices; |
| 47 |
|
| 48 |
real_t radius = 0.0; |
| 49 |
|
| 50 |
bool avoidance_enabled = false; |
| 51 |
uint32_t avoidance_layers = 1; |
| 52 |
|
| 53 |
bool obstacle_dirty = true; |
| 54 |
|
| 55 |
uint32_t last_map_iteration_id = 0; |
| 56 |
bool paused = false; |
| 57 |
|
| 58 |
SelfList<NavObstacle2D> sync_dirty_request_list_element; |
| 59 |
|
| 60 |
public: |
| 61 |
NavObstacle2D(); |
| 62 |
~NavObstacle2D(); |
| 63 |
|
| 64 |
void set_avoidance_enabled(bool p_enabled); |
| 65 |
bool is_avoidance_enabled() { return avoidance_enabled; } |
| 66 |
|
| 67 |
void set_map(NavMap2D *p_map); |
| 68 |
NavMap2D *get_map() { return map; } |
| 69 |
|
| 70 |
void set_agent(NavAgent2D *p_agent); |
| 71 |
NavAgent2D *get_agent() { return agent; } |
| 72 |
|
| 73 |
void set_position(const Vector2 &p_position); |
| 74 |
Vector2 get_position() const { return position; } |
| 75 |
|
| 76 |
void set_radius(real_t p_radius); |
| 77 |
real_t get_radius() const { return radius; } |
| 78 |
|
| 79 |
void set_velocity(const Vector2 &p_velocity); |
| 80 |
Vector2 get_velocity() const { return velocity; } |
| 81 |
|
| 82 |
void set_vertices(const Vector<Vector2> &p_vertices); |
| 83 |
const Vector<Vector2> &get_vertices() const { return vertices; } |
| 84 |
|
| 85 |
bool is_map_changed(); |
| 86 |
|
| 87 |
void set_avoidance_layers(uint32_t p_layers); |
| 88 |
uint32_t get_avoidance_layers() const { return avoidance_layers; } |
| 89 |
|
| 90 |
void set_paused(bool p_paused); |
| 91 |
bool get_paused() const; |
| 92 |
|
| 93 |
bool is_dirty() const; |
| 94 |
void sync(); |
| 95 |
void request_sync(); |
| 96 |
void cancel_sync_request(); |
| 97 |
|
| 98 |
private: |
| 99 |
void internal_update_agent(); |
| 100 |
}; |