| 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 "2d/nav_base_iteration_2d.h" |
| 34 |
#include "nav_base_2d.h" |
| 35 |
#include "nav_utils_2d.h" |
| 36 |
|
| 37 |
class NavLinkIteration2D : public NavBaseIteration2D { |
| 38 |
GDCLASS(NavLinkIteration2D, NavBaseIteration2D); |
| 39 |
|
| 40 |
public: |
| 41 |
bool bidirectional = true; |
| 42 |
Vector2 start_position; |
| 43 |
Vector2 end_position; |
| 44 |
|
| 45 |
Vector2 get_start_position() const { return start_position; } |
| 46 |
Vector2 get_end_position() const { return end_position; } |
| 47 |
bool is_bidirectional() const { return bidirectional; } |
| 48 |
|
| 49 |
virtual ~NavLinkIteration2D() override { |
| 50 |
navmesh_polygons.clear(); |
| 51 |
internal_connections.clear(); |
| 52 |
} |
| 53 |
}; |
| 54 |
|
| 55 |
#include "core/templates/self_list.h" |
| 56 |
|
| 57 |
class NavLink2D : public NavBase2D { |
| 58 |
NavMap2D *map = nullptr; |
| 59 |
bool bidirectional = true; |
| 60 |
Vector2 start_position; |
| 61 |
Vector2 end_position; |
| 62 |
bool enabled = true; |
| 63 |
|
| 64 |
SelfList<NavLink2D> sync_dirty_request_list_element; |
| 65 |
|
| 66 |
uint32_t iteration_id = 0; |
| 67 |
|
| 68 |
mutable RWLock iteration_rwlock; |
| 69 |
Ref<NavLinkIteration2D> iteration; |
| 70 |
|
| 71 |
bool iteration_dirty = true; |
| 72 |
bool iteration_building = false; |
| 73 |
bool iteration_ready = false; |
| 74 |
|
| 75 |
void _build_iteration(); |
| 76 |
void _sync_iteration(); |
| 77 |
|
| 78 |
public: |
| 79 |
NavLink2D(); |
| 80 |
~NavLink2D(); |
| 81 |
|
| 82 |
uint32_t get_iteration_id() const { return iteration_id; } |
| 83 |
|
| 84 |
void set_map(NavMap2D *p_map); |
| 85 |
NavMap2D *get_map() const { |
| 86 |
return map; |
| 87 |
} |
| 88 |
|
| 89 |
void set_enabled(bool p_enabled); |
| 90 |
bool get_enabled() const { return enabled; } |
| 91 |
|
| 92 |
void set_bidirectional(bool p_bidirectional); |
| 93 |
bool is_bidirectional() const { |
| 94 |
return bidirectional; |
| 95 |
} |
| 96 |
|
| 97 |
void set_start_position(Vector2 p_position); |
| 98 |
Vector2 get_start_position() const { |
| 99 |
return start_position; |
| 100 |
} |
| 101 |
|
| 102 |
void set_end_position(Vector2 p_position); |
| 103 |
Vector2 get_end_position() const { |
| 104 |
return end_position; |
| 105 |
} |
| 106 |
|
| 107 |
|
| 108 |
virtual void set_navigation_layers(uint32_t p_navigation_layers) override; |
| 109 |
virtual void set_enter_cost(real_t p_enter_cost) override; |
| 110 |
virtual void set_travel_cost(real_t p_travel_cost) override; |
| 111 |
virtual void set_owner_id(ObjectID p_owner_id) override; |
| 112 |
|
| 113 |
bool sync(); |
| 114 |
void request_sync(); |
| 115 |
void cancel_sync_request(); |
| 116 |
|
| 117 |
Ref<NavLinkIteration2D> get_iteration(); |
| 118 |
}; |