/
kinematicbody2d.gen.go
340 lines (272 loc) · 14.3 KB
/
kinematicbody2d.gen.go
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
package godot
import (
"github.com/shadowapex/godot-go/gdnative"
)
/*------------------------------------------------------------------------------
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. Any updates should be done in
// "class.go.tmpl" so they can be included in the generated
// code.
//----------------------------------------------------------------------------*/
//func NewKinematicBody2DFromPointer(ptr gdnative.Pointer) KinematicBody2D {
func newKinematicBody2DFromPointer(ptr gdnative.Pointer) KinematicBody2D {
owner := gdnative.NewObjectFromPointer(ptr)
obj := KinematicBody2D{}
obj.SetBaseObject(owner)
return obj
}
/*
Kinematic bodies are special types of bodies that are meant to be user-controlled. They are not affected by physics at all (to other types of bodies, such a character or a rigid body, these are the same as a static body). They have however, two main uses: Simulated Motion: When these bodies are moved manually, either from code or from an AnimationPlayer (with process mode set to fixed), the physics will automatically compute an estimate of their linear and angular velocity. This makes them very useful for moving platforms or other AnimationPlayer-controlled objects (like a door, a bridge that opens, etc). Kinematic Characters: KinematicBody2D also has an API for moving objects (the [method move_and_collide] and [method move_and_slide] methods) while performing collision tests. This makes them really useful to implement characters that collide against a world, but that don't require advanced physics.
*/
type KinematicBody2D struct {
PhysicsBody2D
owner gdnative.Object
}
func (o *KinematicBody2D) BaseClass() string {
return "KinematicBody2D"
}
/*
Returns the velocity of the floor. Only updates when calling [method move_and_slide].
Args: [], Returns: Vector2
*/
func (o *KinematicBody2D) GetFloorVelocity() gdnative.Vector2 {
//log.Println("Calling KinematicBody2D.GetFloorVelocity()")
// Build out the method's arguments
ptrArguments := make([]gdnative.Pointer, 0, 0)
// Get the method bind
methodBind := gdnative.NewMethodBind("KinematicBody2D", "get_floor_velocity")
// Call the parent method.
// Vector2
retPtr := gdnative.NewEmptyVector2()
gdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)
// If we have a return type, convert it from a pointer into its actual object.
ret := gdnative.NewVector2FromPointer(retPtr)
return ret
}
/*
Undocumented
Args: [], Returns: float
*/
func (o *KinematicBody2D) GetSafeMargin() gdnative.Real {
//log.Println("Calling KinematicBody2D.GetSafeMargin()")
// Build out the method's arguments
ptrArguments := make([]gdnative.Pointer, 0, 0)
// Get the method bind
methodBind := gdnative.NewMethodBind("KinematicBody2D", "get_safe_margin")
// Call the parent method.
// float
retPtr := gdnative.NewEmptyReal()
gdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)
// If we have a return type, convert it from a pointer into its actual object.
ret := gdnative.NewRealFromPointer(retPtr)
return ret
}
/*
Returns a [KinematicCollision2D], which contains information about a collision that occurred during the last [method move_and_slide] call. Since the body can collide several times in a single call to [method move_and_slide], you must specify the index of the collision in the range 0 to ([method get_slide_count] - 1).
Args: [{ false slide_idx int}], Returns: KinematicCollision2D
*/
func (o *KinematicBody2D) GetSlideCollision(slideIdx gdnative.Int) KinematicCollision2DImplementer {
//log.Println("Calling KinematicBody2D.GetSlideCollision()")
// Build out the method's arguments
ptrArguments := make([]gdnative.Pointer, 1, 1)
ptrArguments[0] = gdnative.NewPointerFromInt(slideIdx)
// Get the method bind
methodBind := gdnative.NewMethodBind("KinematicBody2D", "get_slide_collision")
// Call the parent method.
// KinematicCollision2D
retPtr := gdnative.NewEmptyObject()
gdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)
// If we have a return type, convert it from a pointer into its actual object.
ret := newKinematicCollision2DFromPointer(retPtr)
// Check to see if we already have an instance of this object in our Go instance registry.
if instance, ok := InstanceRegistry.Get(ret.GetBaseObject().ID()); ok {
return instance.(KinematicCollision2DImplementer)
}
// Check to see what kind of class this is and create it. This is generally used with
// GetNode().
className := ret.GetClass()
if className != "KinematicCollision2D" {
actualRet := getActualClass(className, ret.GetBaseObject())
return actualRet.(KinematicCollision2DImplementer)
}
return &ret
}
/*
Returns the number of times the body collided and changed direction during the last call to [method move_and_slide].
Args: [], Returns: int
*/
func (o *KinematicBody2D) GetSlideCount() gdnative.Int {
//log.Println("Calling KinematicBody2D.GetSlideCount()")
// Build out the method's arguments
ptrArguments := make([]gdnative.Pointer, 0, 0)
// Get the method bind
methodBind := gdnative.NewMethodBind("KinematicBody2D", "get_slide_count")
// Call the parent method.
// int
retPtr := gdnative.NewEmptyInt()
gdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)
// If we have a return type, convert it from a pointer into its actual object.
ret := gdnative.NewIntFromPointer(retPtr)
return ret
}
/*
Returns [code]true[/code] if the body is on the ceiling. Only updates when calling [method move_and_slide].
Args: [], Returns: bool
*/
func (o *KinematicBody2D) IsOnCeiling() gdnative.Bool {
//log.Println("Calling KinematicBody2D.IsOnCeiling()")
// Build out the method's arguments
ptrArguments := make([]gdnative.Pointer, 0, 0)
// Get the method bind
methodBind := gdnative.NewMethodBind("KinematicBody2D", "is_on_ceiling")
// Call the parent method.
// bool
retPtr := gdnative.NewEmptyBool()
gdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)
// If we have a return type, convert it from a pointer into its actual object.
ret := gdnative.NewBoolFromPointer(retPtr)
return ret
}
/*
Returns [code]true[/code] if the body is on the floor. Only updates when calling [method move_and_slide].
Args: [], Returns: bool
*/
func (o *KinematicBody2D) IsOnFloor() gdnative.Bool {
//log.Println("Calling KinematicBody2D.IsOnFloor()")
// Build out the method's arguments
ptrArguments := make([]gdnative.Pointer, 0, 0)
// Get the method bind
methodBind := gdnative.NewMethodBind("KinematicBody2D", "is_on_floor")
// Call the parent method.
// bool
retPtr := gdnative.NewEmptyBool()
gdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)
// If we have a return type, convert it from a pointer into its actual object.
ret := gdnative.NewBoolFromPointer(retPtr)
return ret
}
/*
Returns [code]true[/code] if the body is on a wall. Only updates when calling [method move_and_slide].
Args: [], Returns: bool
*/
func (o *KinematicBody2D) IsOnWall() gdnative.Bool {
//log.Println("Calling KinematicBody2D.IsOnWall()")
// Build out the method's arguments
ptrArguments := make([]gdnative.Pointer, 0, 0)
// Get the method bind
methodBind := gdnative.NewMethodBind("KinematicBody2D", "is_on_wall")
// Call the parent method.
// bool
retPtr := gdnative.NewEmptyBool()
gdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)
// If we have a return type, convert it from a pointer into its actual object.
ret := gdnative.NewBoolFromPointer(retPtr)
return ret
}
/*
Moves the body along the vector [code]rel_vec[/code]. The body will stop if it collides. Returns a [KinematicCollision2D], which contains information about the collision.
Args: [{ false rel_vec Vector2}], Returns: KinematicCollision2D
*/
func (o *KinematicBody2D) MoveAndCollide(relVec gdnative.Vector2) KinematicCollision2DImplementer {
//log.Println("Calling KinematicBody2D.MoveAndCollide()")
// Build out the method's arguments
ptrArguments := make([]gdnative.Pointer, 1, 1)
ptrArguments[0] = gdnative.NewPointerFromVector2(relVec)
// Get the method bind
methodBind := gdnative.NewMethodBind("KinematicBody2D", "move_and_collide")
// Call the parent method.
// KinematicCollision2D
retPtr := gdnative.NewEmptyObject()
gdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)
// If we have a return type, convert it from a pointer into its actual object.
ret := newKinematicCollision2DFromPointer(retPtr)
// Check to see if we already have an instance of this object in our Go instance registry.
if instance, ok := InstanceRegistry.Get(ret.GetBaseObject().ID()); ok {
return instance.(KinematicCollision2DImplementer)
}
// Check to see what kind of class this is and create it. This is generally used with
// GetNode().
className := ret.GetClass()
if className != "KinematicCollision2D" {
actualRet := getActualClass(className, ret.GetBaseObject())
return actualRet.(KinematicCollision2DImplementer)
}
return &ret
}
/*
Moves the body along a vector. If the body collides with another, it will slide along the other body rather than stop immediately. If the other body is a [code]KinematicBody2D[/code] or [RigidBody2D], it will also be affected by the motion of the other body. You can use this to make moving or rotating platforms, or to make nodes push other nodes. [code]linear_velocity[/code] is a value in pixels per second. Unlike in for example [method move_and_collide], you should [i]not[/i] multiply it with [code]delta[/code] — this is done by the method. [code]floor_normal[/code] is the up direction, used to determine what is a wall and what is a floor or a ceiling. If set to the default value of [code]Vector2(0, 0)[/code], everything is considered a wall. This is useful for topdown games. If the body is standing on a slope and the horizontal speed (relative to the floor's speed) goes below [code]slope_stop_min_velocity[/code], the body will stop completely. This prevents the body from sliding down slopes when you include gravity in [code]linear_velocity[/code]. When set to lower values, the body will not be able to stand still on steep slopes. If the body collides, it will change direction a maximum of [code]max_bounces[/code] times before it stops. [code]floor_max_angle[/code] is the maximum angle (in radians) where a slope is still considered a floor (or a ceiling), rather than a wall. The default value equals 45 degrees. Returns the movement that remained when the body stopped. To get more detailed information about collisions that occurred, use [method get_slide_collision].
Args: [{ false linear_velocity Vector2} {(0, 0) true floor_normal Vector2} {5 true slope_stop_min_velocity float} {4 true max_bounces int} {0.785398 true floor_max_angle float}], Returns: Vector2
*/
func (o *KinematicBody2D) MoveAndSlide(linearVelocity gdnative.Vector2, floorNormal gdnative.Vector2, slopeStopMinVelocity gdnative.Real, maxBounces gdnative.Int, floorMaxAngle gdnative.Real) gdnative.Vector2 {
//log.Println("Calling KinematicBody2D.MoveAndSlide()")
// Build out the method's arguments
ptrArguments := make([]gdnative.Pointer, 5, 5)
ptrArguments[0] = gdnative.NewPointerFromVector2(linearVelocity)
ptrArguments[1] = gdnative.NewPointerFromVector2(floorNormal)
ptrArguments[2] = gdnative.NewPointerFromReal(slopeStopMinVelocity)
ptrArguments[3] = gdnative.NewPointerFromInt(maxBounces)
ptrArguments[4] = gdnative.NewPointerFromReal(floorMaxAngle)
// Get the method bind
methodBind := gdnative.NewMethodBind("KinematicBody2D", "move_and_slide")
// Call the parent method.
// Vector2
retPtr := gdnative.NewEmptyVector2()
gdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)
// If we have a return type, convert it from a pointer into its actual object.
ret := gdnative.NewVector2FromPointer(retPtr)
return ret
}
/*
Undocumented
Args: [{ false pixels float}], Returns: void
*/
func (o *KinematicBody2D) SetSafeMargin(pixels gdnative.Real) {
//log.Println("Calling KinematicBody2D.SetSafeMargin()")
// Build out the method's arguments
ptrArguments := make([]gdnative.Pointer, 1, 1)
ptrArguments[0] = gdnative.NewPointerFromReal(pixels)
// Get the method bind
methodBind := gdnative.NewMethodBind("KinematicBody2D", "set_safe_margin")
// Call the parent method.
// void
retPtr := gdnative.NewEmptyVoid()
gdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)
}
/*
Checks for collisions without moving the body. Virtually sets the node's position, scale and rotation to that of the given [Transform2D], then tries to move the body along the vector [code]rel_vec[/code]. Returns [code]true[/code] if a collision would occur.
Args: [{ false from Transform2D} { false rel_vec Vector2}], Returns: bool
*/
func (o *KinematicBody2D) TestMove(from gdnative.Transform2D, relVec gdnative.Vector2) gdnative.Bool {
//log.Println("Calling KinematicBody2D.TestMove()")
// Build out the method's arguments
ptrArguments := make([]gdnative.Pointer, 2, 2)
ptrArguments[0] = gdnative.NewPointerFromTransform2D(from)
ptrArguments[1] = gdnative.NewPointerFromVector2(relVec)
// Get the method bind
methodBind := gdnative.NewMethodBind("KinematicBody2D", "test_move")
// Call the parent method.
// bool
retPtr := gdnative.NewEmptyBool()
gdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)
// If we have a return type, convert it from a pointer into its actual object.
ret := gdnative.NewBoolFromPointer(retPtr)
return ret
}
// KinematicBody2DImplementer is an interface that implements the methods
// of the KinematicBody2D class.
type KinematicBody2DImplementer interface {
PhysicsBody2DImplementer
GetFloorVelocity() gdnative.Vector2
GetSafeMargin() gdnative.Real
GetSlideCollision(slideIdx gdnative.Int) KinematicCollision2DImplementer
GetSlideCount() gdnative.Int
IsOnCeiling() gdnative.Bool
IsOnFloor() gdnative.Bool
IsOnWall() gdnative.Bool
MoveAndCollide(relVec gdnative.Vector2) KinematicCollision2DImplementer
MoveAndSlide(linearVelocity gdnative.Vector2, floorNormal gdnative.Vector2, slopeStopMinVelocity gdnative.Real, maxBounces gdnative.Int, floorMaxAngle gdnative.Real) gdnative.Vector2
SetSafeMargin(pixels gdnative.Real)
TestMove(from gdnative.Transform2D, relVec gdnative.Vector2) gdnative.Bool
}