Debian Codegraph @

modules/navigation_2d/nav_link_2d.h

raw symbols SCIP
1 /**************************************************************************/
2 /* nav_link_2d.h */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
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 // NavBase properties.
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 };