| 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 "scene/resources/2d/navigation_polygon.h" |
| 34 |
|
| 35 |
class NavigationRegion2D : public Node2D { |
| 36 |
GDCLASS(NavigationRegion2D, Node2D); |
| 37 |
|
| 38 |
bool enabled = true; |
| 39 |
bool use_edge_connections = true; |
| 40 |
|
| 41 |
RID region; |
| 42 |
RID map_override; |
| 43 |
uint32_t navigation_layers = 1; |
| 44 |
real_t enter_cost = 0.0; |
| 45 |
real_t travel_cost = 1.0; |
| 46 |
Ref<NavigationPolygon> navigation_polygon; |
| 47 |
|
| 48 |
Transform2D current_global_transform; |
| 49 |
|
| 50 |
void _navigation_polygon_changed(); |
| 51 |
|
| 52 |
Rect2 bounds; |
| 53 |
|
| 54 |
#ifdef DEBUG_ENABLED |
| 55 |
private: |
| 56 |
RID debug_mesh_rid; |
| 57 |
RID debug_instance_rid; |
| 58 |
|
| 59 |
bool debug_mesh_dirty = true; |
| 60 |
|
| 61 |
void _set_debug_visible(bool p_visible); |
| 62 |
void _update_debug_mesh(); |
| 63 |
void _update_debug_edge_connections_mesh(); |
| 64 |
void _update_debug_baking_rect(); |
| 65 |
void _navigation_map_changed(RID p_map); |
| 66 |
void _navigation_debug_changed(); |
| 67 |
#endif |
| 68 |
|
| 69 |
protected: |
| 70 |
void _notification(int p_what); |
| 71 |
static void _bind_methods(); |
| 72 |
|
| 73 |
#ifndef DISABLE_DEPRECATED |
| 74 |
bool _set(const StringName &p_name, const Variant &p_value); |
| 75 |
bool _get(const StringName &p_name, Variant &r_ret) const; |
| 76 |
#endif |
| 77 |
|
| 78 |
public: |
| 79 |
#ifdef DEBUG_ENABLED |
| 80 |
virtual Rect2 _edit_get_rect() const override; |
| 81 |
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const override; |
| 82 |
#endif |
| 83 |
RID get_rid() const; |
| 84 |
|
| 85 |
void set_enabled(bool p_enabled); |
| 86 |
bool is_enabled() const; |
| 87 |
|
| 88 |
void set_navigation_map(RID p_navigation_map); |
| 89 |
RID get_navigation_map() const; |
| 90 |
|
| 91 |
void set_use_edge_connections(bool p_enabled); |
| 92 |
bool get_use_edge_connections() const; |
| 93 |
|
| 94 |
void set_navigation_layers(uint32_t p_navigation_layers); |
| 95 |
uint32_t get_navigation_layers() const; |
| 96 |
|
| 97 |
void set_navigation_layer_value(int p_layer_number, bool p_value); |
| 98 |
bool get_navigation_layer_value(int p_layer_number) const; |
| 99 |
|
| 100 |
RID get_region_rid() const; |
| 101 |
|
| 102 |
void set_enter_cost(real_t p_enter_cost); |
| 103 |
real_t get_enter_cost() const; |
| 104 |
|
| 105 |
void set_travel_cost(real_t p_travel_cost); |
| 106 |
real_t get_travel_cost() const; |
| 107 |
|
| 108 |
void set_navigation_polygon(const Ref<NavigationPolygon> &p_navigation_polygon); |
| 109 |
Ref<NavigationPolygon> get_navigation_polygon() const; |
| 110 |
|
| 111 |
PackedStringArray get_configuration_warnings() const override; |
| 112 |
|
| 113 |
void bake_navigation_polygon(bool p_on_thread); |
| 114 |
void _bake_finished(); |
| 115 |
bool is_baking() const; |
| 116 |
|
| 117 |
Rect2 get_bounds() const { return bounds; } |
| 118 |
|
| 119 |
NavigationRegion2D(); |
| 120 |
~NavigationRegion2D(); |
| 121 |
|
| 122 |
private: |
| 123 |
void _update_bounds(); |
| 124 |
void _region_enter_navigation_map(); |
| 125 |
void _region_exit_navigation_map(); |
| 126 |
void _region_update_transform(); |
| 127 |
}; |