1 /**
2 A node that has methods to draw outlines or use indices of vertices to create navigation polygons.
3 
4 Copyright:
5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur.  
6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md)  
7 Copyright (c) 2017-2018 Godot-D contributors  
8 
9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License)
10 
11 
12 */
13 module godot.navigationpolygon;
14 import std.meta : AliasSeq, staticIndexOf;
15 import std.traits : Unqual;
16 import godot.d.meta;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.object;
22 import godot.classdb;
23 import godot.resource;
24 import godot.reference;
25 /**
26 A node that has methods to draw outlines or use indices of vertices to create navigation polygons.
27 
28 There are two ways to create polygons. Either by using the $(D addOutline) method or using the $(D addPolygon) method.
29 Using $(D addOutline):
30 $(D code)
31 var polygon = NavigationPolygon.new()
32 var outline = PoolVector2Array($(D Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)))
33 polygon.add_outline(outline)
34 polygon.make_polygons_from_outlines()
35 $NavigationPolygonInstance.navpoly = polygon
36 $(D /code)
37 Using $(D addPolygon) and indices of the vertices array.
38 $(D code)
39 var polygon = NavigationPolygon.new()
40 var vertices = PoolVector2Array($(D Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)))
41 polygon.set_vertices(vertices)
42 var indices = PoolIntArray(0, 3, 1)
43 polygon.add_polygon(indices)
44 $NavigationPolygonInstance.navpoly = polygon
45 $(D /code)
46 */
47 @GodotBaseClass struct NavigationPolygon
48 {
49 	enum string _GODOT_internal_name = "NavigationPolygon";
50 public:
51 @nogc nothrow:
52 	union { godot_object _godot_object; Resource _GODOT_base; }
53 	alias _GODOT_base this;
54 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
55 	package(godot) __gshared bool _classBindingInitialized = false;
56 	package(godot) static struct _classBinding
57 	{
58 		__gshared:
59 		@GodotName("set_vertices") GodotMethod!(void, PoolVector2Array) setVertices;
60 		@GodotName("get_vertices") GodotMethod!(PoolVector2Array) getVertices;
61 		@GodotName("add_polygon") GodotMethod!(void, PoolIntArray) addPolygon;
62 		@GodotName("get_polygon_count") GodotMethod!(long) getPolygonCount;
63 		@GodotName("get_polygon") GodotMethod!(PoolIntArray, long) getPolygon;
64 		@GodotName("clear_polygons") GodotMethod!(void) clearPolygons;
65 		@GodotName("add_outline") GodotMethod!(void, PoolVector2Array) addOutline;
66 		@GodotName("add_outline_at_index") GodotMethod!(void, PoolVector2Array, long) addOutlineAtIndex;
67 		@GodotName("get_outline_count") GodotMethod!(long) getOutlineCount;
68 		@GodotName("set_outline") GodotMethod!(void, long, PoolVector2Array) setOutline;
69 		@GodotName("get_outline") GodotMethod!(PoolVector2Array, long) getOutline;
70 		@GodotName("remove_outline") GodotMethod!(void, long) removeOutline;
71 		@GodotName("clear_outlines") GodotMethod!(void) clearOutlines;
72 		@GodotName("make_polygons_from_outlines") GodotMethod!(void) makePolygonsFromOutlines;
73 		@GodotName("_set_polygons") GodotMethod!(void, Array) _setPolygons;
74 		@GodotName("_get_polygons") GodotMethod!(Array) _getPolygons;
75 		@GodotName("_set_outlines") GodotMethod!(void, Array) _setOutlines;
76 		@GodotName("_get_outlines") GodotMethod!(Array) _getOutlines;
77 	}
78 	bool opEquals(in NavigationPolygon other) const { return _godot_object.ptr is other._godot_object.ptr; }
79 	NavigationPolygon opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; }
80 	bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; }
81 	mixin baseCasts;
82 	static NavigationPolygon _new()
83 	{
84 		static godot_class_constructor constructor;
85 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("NavigationPolygon");
86 		if(constructor is null) return typeof(this).init;
87 		return cast(NavigationPolygon)(constructor());
88 	}
89 	@disable new(size_t s);
90 	/**
91 	Sets the vertices that can be then indexed to create polygons with the $(D addPolygon) method.
92 	*/
93 	void setVertices(in PoolVector2Array vertices)
94 	{
95 		checkClassBinding!(typeof(this))();
96 		ptrcall!(void)(_classBinding.setVertices, _godot_object, vertices);
97 	}
98 	/**
99 	Returns a $(D PoolVector2Array) containing all the vertices being used to create the polygons.
100 	*/
101 	PoolVector2Array getVertices() const
102 	{
103 		checkClassBinding!(typeof(this))();
104 		return ptrcall!(PoolVector2Array)(_classBinding.getVertices, _godot_object);
105 	}
106 	/**
107 	Adds a polygon using the indices of the vertices you get when calling $(D getVertices).
108 	*/
109 	void addPolygon(in PoolIntArray polygon)
110 	{
111 		checkClassBinding!(typeof(this))();
112 		ptrcall!(void)(_classBinding.addPolygon, _godot_object, polygon);
113 	}
114 	/**
115 	Returns the count of all polygons.
116 	*/
117 	long getPolygonCount() const
118 	{
119 		checkClassBinding!(typeof(this))();
120 		return ptrcall!(long)(_classBinding.getPolygonCount, _godot_object);
121 	}
122 	/**
123 	Returns a $(D PoolIntArray) containing the indices of the vertices of a created polygon.
124 	*/
125 	PoolIntArray getPolygon(in long idx)
126 	{
127 		checkClassBinding!(typeof(this))();
128 		return ptrcall!(PoolIntArray)(_classBinding.getPolygon, _godot_object, idx);
129 	}
130 	/**
131 	Clears the array of polygons, but it doesn't clear the array of outlines and vertices.
132 	*/
133 	void clearPolygons()
134 	{
135 		checkClassBinding!(typeof(this))();
136 		ptrcall!(void)(_classBinding.clearPolygons, _godot_object);
137 	}
138 	/**
139 	Appends a $(D PoolVector2Array) that contains the vertices of an outline to the internal array that contains all the outlines. You have to call $(D makePolygonsFromOutlines) in order for this array to be converted to polygons that the engine will use.
140 	*/
141 	void addOutline(in PoolVector2Array outline)
142 	{
143 		checkClassBinding!(typeof(this))();
144 		ptrcall!(void)(_classBinding.addOutline, _godot_object, outline);
145 	}
146 	/**
147 	Adds a $(D PoolVector2Array) that contains the vertices of an outline to the internal array that contains all the outlines at a fixed position. You have to call $(D makePolygonsFromOutlines) in order for this array to be converted to polygons that the engine will use.
148 	*/
149 	void addOutlineAtIndex(in PoolVector2Array outline, in long index)
150 	{
151 		checkClassBinding!(typeof(this))();
152 		ptrcall!(void)(_classBinding.addOutlineAtIndex, _godot_object, outline, index);
153 	}
154 	/**
155 	Returns the number of outlines that were created in the editor or by script.
156 	*/
157 	long getOutlineCount() const
158 	{
159 		checkClassBinding!(typeof(this))();
160 		return ptrcall!(long)(_classBinding.getOutlineCount, _godot_object);
161 	}
162 	/**
163 	Changes an outline created in the editor or by script. You have to call $(D makePolygonsFromOutlines) for the polygons to update.
164 	*/
165 	void setOutline(in long idx, in PoolVector2Array outline)
166 	{
167 		checkClassBinding!(typeof(this))();
168 		ptrcall!(void)(_classBinding.setOutline, _godot_object, idx, outline);
169 	}
170 	/**
171 	Returns a $(D PoolVector2Array) containing the vertices of an outline that was created in the editor or by script.
172 	*/
173 	PoolVector2Array getOutline(in long idx) const
174 	{
175 		checkClassBinding!(typeof(this))();
176 		return ptrcall!(PoolVector2Array)(_classBinding.getOutline, _godot_object, idx);
177 	}
178 	/**
179 	Removes an outline created in the editor or by script. You have to call $(D makePolygonsFromOutlines) for the polygons to update.
180 	*/
181 	void removeOutline(in long idx)
182 	{
183 		checkClassBinding!(typeof(this))();
184 		ptrcall!(void)(_classBinding.removeOutline, _godot_object, idx);
185 	}
186 	/**
187 	Clears the array of the outlines, but it doesn't clear the vertices and the polygons that were created by them.
188 	*/
189 	void clearOutlines()
190 	{
191 		checkClassBinding!(typeof(this))();
192 		ptrcall!(void)(_classBinding.clearOutlines, _godot_object);
193 	}
194 	/**
195 	Creates polygons from the outlines added in the editor or by script.
196 	*/
197 	void makePolygonsFromOutlines()
198 	{
199 		checkClassBinding!(typeof(this))();
200 		ptrcall!(void)(_classBinding.makePolygonsFromOutlines, _godot_object);
201 	}
202 	/**
203 	
204 	*/
205 	void _setPolygons(in Array polygons)
206 	{
207 		Array _GODOT_args = Array.empty_array;
208 		_GODOT_args.append(polygons);
209 		String _GODOT_method_name = String("_set_polygons");
210 		this.callv(_GODOT_method_name, _GODOT_args);
211 	}
212 	/**
213 	
214 	*/
215 	Array _getPolygons() const
216 	{
217 		Array _GODOT_args = Array.empty_array;
218 		String _GODOT_method_name = String("_get_polygons");
219 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!Array);
220 	}
221 	/**
222 	
223 	*/
224 	void _setOutlines(in Array outlines)
225 	{
226 		Array _GODOT_args = Array.empty_array;
227 		_GODOT_args.append(outlines);
228 		String _GODOT_method_name = String("_set_outlines");
229 		this.callv(_GODOT_method_name, _GODOT_args);
230 	}
231 	/**
232 	
233 	*/
234 	Array _getOutlines() const
235 	{
236 		Array _GODOT_args = Array.empty_array;
237 		String _GODOT_method_name = String("_get_outlines");
238 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!Array);
239 	}
240 	/**
241 	
242 	*/
243 	@property PoolVector2Array vertices()
244 	{
245 		return getVertices();
246 	}
247 	/// ditto
248 	@property void vertices(PoolVector2Array v)
249 	{
250 		setVertices(v);
251 	}
252 	/**
253 	
254 	*/
255 	@property Array polygons()
256 	{
257 		return _getPolygons();
258 	}
259 	/// ditto
260 	@property void polygons(Array v)
261 	{
262 		_setPolygons(v);
263 	}
264 	/**
265 	
266 	*/
267 	@property Array outlines()
268 	{
269 		return _getOutlines();
270 	}
271 	/// ditto
272 	@property void outlines(Array v)
273 	{
274 		_setOutlines(v);
275 	}
276 }