/
NavigationPolygon.hx
138 lines (111 loc) · 4.57 KB
/
NavigationPolygon.hx
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
// Automatically generated Godot externs: DO NOT EDIT
// MIT licensed, see LICENSE.md
package godot;
import cs.system.*;
/**
There are two ways to create polygons. Either by using the `godot.NavigationPolygon.addOutline` method, or using the `godot.NavigationPolygon.addPolygon` method.
Using `godot.NavigationPolygon.addOutline`:
```
var polygon = NavigationPolygon.new()
var outline = PoolVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)])
polygon.add_outline(outline)
polygon.make_polygons_from_outlines()
$NavigationPolygonInstance.navpoly = polygon
```
Using `godot.NavigationPolygon.addPolygon` and indices of the vertices array.
```
var polygon = NavigationPolygon.new()
var vertices = PoolVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)])
polygon.set_vertices(vertices)
var indices = PoolIntArray([0, 1, 2, 3])
polygon.add_polygon(indices)
$NavigationPolygonInstance.navpoly = polygon
```
**/
@:libType
@:csNative
@:native("Godot.NavigationPolygon")
@:autoBuild(godot.Godot.buildUserClass())
extern class NavigationPolygon extends godot.Resource {
@:native("Outlines")
public var outlines:godot.collections.Array;
@:native("Polygons")
public var polygons:godot.collections.Array;
@:native("Vertices")
public var vertices:cs.NativeArray<godot.Vector2>;
@:native("new")
public function new():Void;
/**
Sets the vertices that can be then indexed to create polygons with the `godot.NavigationPolygon.addPolygon` method.
**/
@:native("SetVertices")
public function setVertices(vertices:HaxeArray<godot.Vector2>):Void;
/**
Returns a `godot.Vector2` containing all the vertices being used to create the polygons.
**/
public extern inline function getVertices():std.Array<godot.Vector2> {
return cs.Lib.array(cs.Syntax.code("{0}.GetVertices()", this));
}
/**
Adds a polygon using the indices of the vertices you get when calling `godot.NavigationPolygon.getVertices`.
**/
@:native("AddPolygon")
public function addPolygon(polygon:HaxeArray<Int>):Void;
/**
Returns the count of all polygons.
**/
@:native("GetPolygonCount")
public function getPolygonCount():Int;
/**
Returns a `Int` containing the indices of the vertices of a created polygon.
**/
public extern inline function getPolygon(idx:Int):std.Array<Int> {
return cs.Lib.array(cs.Syntax.code("{0}.GetPolygon({1})", this, idx));
}
/**
Clears the array of polygons, but it doesn't clear the array of outlines and vertices.
**/
@:native("ClearPolygons")
public function clearPolygons():Void;
/**
Appends a `godot.Vector2` that contains the vertices of an outline to the internal array that contains all the outlines. You have to call `godot.NavigationPolygon.makePolygonsFromOutlines` in order for this array to be converted to polygons that the engine will use.
**/
@:native("AddOutline")
public function addOutline(outline:HaxeArray<godot.Vector2>):Void;
/**
Adds a `godot.Vector2` that contains the vertices of an outline to the internal array that contains all the outlines at a fixed position. You have to call `godot.NavigationPolygon.makePolygonsFromOutlines` in order for this array to be converted to polygons that the engine will use.
**/
@:native("AddOutlineAtIndex")
public function addOutlineAtIndex(outline:HaxeArray<godot.Vector2>, index:Int):Void;
/**
Returns the number of outlines that were created in the editor or by script.
**/
@:native("GetOutlineCount")
public function getOutlineCount():Int;
/**
Changes an outline created in the editor or by script. You have to call `godot.NavigationPolygon.makePolygonsFromOutlines` for the polygons to update.
**/
@:native("SetOutline")
public function setOutline(idx:Int, outline:HaxeArray<godot.Vector2>):Void;
/**
Returns a `godot.Vector2` containing the vertices of an outline that was created in the editor or by script.
**/
public extern inline function getOutline(idx:Int):std.Array<godot.Vector2> {
return cs.Lib.array(cs.Syntax.code("{0}.GetOutline({1})", this, idx));
}
/**
Removes an outline created in the editor or by script. You have to call `godot.NavigationPolygon.makePolygonsFromOutlines` for the polygons to update.
**/
@:native("RemoveOutline")
public function removeOutline(idx:Int):Void;
/**
Clears the array of the outlines, but it doesn't clear the vertices and the polygons that were created by them.
**/
@:native("ClearOutlines")
public function clearOutlines():Void;
/**
Creates polygons from the outlines added in the editor or by script.
**/
@:native("MakePolygonsFromOutlines")
public function makePolygonsFromOutlines():Void;
}