1 /**
2 Collision data for KinematicBody2D collisions.
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.kinematiccollision2d;
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.reference;
24 /**
25 Collision data for KinematicBody2D collisions.
26 
27 Contains collision data for KinematicBody2D collisions. When a $(D KinematicBody2D) is moved using $(D KinematicBody2D.moveAndCollide), it stops if it detects a collision with another body. If a collision is detected, a KinematicCollision2D object is returned.
28 This object contains information about the collision, including the colliding object, the remaining motion, and the collision position. This information can be used to calculate a collision response.
29 */
30 @GodotBaseClass struct KinematicCollision2D
31 {
32 	enum string _GODOT_internal_name = "KinematicCollision2D";
33 public:
34 @nogc nothrow:
35 	union { godot_object _godot_object; Reference _GODOT_base; }
36 	alias _GODOT_base this;
37 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
38 	package(godot) __gshared bool _classBindingInitialized = false;
39 	package(godot) static struct _classBinding
40 	{
41 		__gshared:
42 		@GodotName("get_position") GodotMethod!(Vector2) getPosition;
43 		@GodotName("get_normal") GodotMethod!(Vector2) getNormal;
44 		@GodotName("get_travel") GodotMethod!(Vector2) getTravel;
45 		@GodotName("get_remainder") GodotMethod!(Vector2) getRemainder;
46 		@GodotName("get_local_shape") GodotMethod!(GodotObject) getLocalShape;
47 		@GodotName("get_collider") GodotMethod!(GodotObject) getCollider;
48 		@GodotName("get_collider_id") GodotMethod!(long) getColliderId;
49 		@GodotName("get_collider_shape") GodotMethod!(GodotObject) getColliderShape;
50 		@GodotName("get_collider_shape_index") GodotMethod!(long) getColliderShapeIndex;
51 		@GodotName("get_collider_velocity") GodotMethod!(Vector2) getColliderVelocity;
52 		@GodotName("get_collider_metadata") GodotMethod!(Variant) getColliderMetadata;
53 	}
54 	bool opEquals(in KinematicCollision2D other) const { return _godot_object.ptr is other._godot_object.ptr; }
55 	KinematicCollision2D opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; }
56 	bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; }
57 	mixin baseCasts;
58 	static KinematicCollision2D _new()
59 	{
60 		static godot_class_constructor constructor;
61 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("KinematicCollision2D");
62 		if(constructor is null) return typeof(this).init;
63 		return cast(KinematicCollision2D)(constructor());
64 	}
65 	@disable new(size_t s);
66 	/**
67 	
68 	*/
69 	Vector2 getPosition() const
70 	{
71 		checkClassBinding!(typeof(this))();
72 		return ptrcall!(Vector2)(_classBinding.getPosition, _godot_object);
73 	}
74 	/**
75 	
76 	*/
77 	Vector2 getNormal() const
78 	{
79 		checkClassBinding!(typeof(this))();
80 		return ptrcall!(Vector2)(_classBinding.getNormal, _godot_object);
81 	}
82 	/**
83 	
84 	*/
85 	Vector2 getTravel() const
86 	{
87 		checkClassBinding!(typeof(this))();
88 		return ptrcall!(Vector2)(_classBinding.getTravel, _godot_object);
89 	}
90 	/**
91 	
92 	*/
93 	Vector2 getRemainder() const
94 	{
95 		checkClassBinding!(typeof(this))();
96 		return ptrcall!(Vector2)(_classBinding.getRemainder, _godot_object);
97 	}
98 	/**
99 	
100 	*/
101 	GodotObject getLocalShape() const
102 	{
103 		checkClassBinding!(typeof(this))();
104 		return ptrcall!(GodotObject)(_classBinding.getLocalShape, _godot_object);
105 	}
106 	/**
107 	
108 	*/
109 	GodotObject getCollider() const
110 	{
111 		checkClassBinding!(typeof(this))();
112 		return ptrcall!(GodotObject)(_classBinding.getCollider, _godot_object);
113 	}
114 	/**
115 	
116 	*/
117 	long getColliderId() const
118 	{
119 		checkClassBinding!(typeof(this))();
120 		return ptrcall!(long)(_classBinding.getColliderId, _godot_object);
121 	}
122 	/**
123 	
124 	*/
125 	GodotObject getColliderShape() const
126 	{
127 		checkClassBinding!(typeof(this))();
128 		return ptrcall!(GodotObject)(_classBinding.getColliderShape, _godot_object);
129 	}
130 	/**
131 	
132 	*/
133 	long getColliderShapeIndex() const
134 	{
135 		checkClassBinding!(typeof(this))();
136 		return ptrcall!(long)(_classBinding.getColliderShapeIndex, _godot_object);
137 	}
138 	/**
139 	
140 	*/
141 	Vector2 getColliderVelocity() const
142 	{
143 		checkClassBinding!(typeof(this))();
144 		return ptrcall!(Vector2)(_classBinding.getColliderVelocity, _godot_object);
145 	}
146 	/**
147 	
148 	*/
149 	Variant getColliderMetadata() const
150 	{
151 		checkClassBinding!(typeof(this))();
152 		return ptrcall!(Variant)(_classBinding.getColliderMetadata, _godot_object);
153 	}
154 	/**
155 	The point of collision.
156 	*/
157 	@property Vector2 position()
158 	{
159 		return getPosition();
160 	}
161 	/**
162 	The colliding body's shape's normal at the point of collision.
163 	*/
164 	@property Vector2 normal()
165 	{
166 		return getNormal();
167 	}
168 	/**
169 	The distance the moving object traveled before collision.
170 	*/
171 	@property Vector2 travel()
172 	{
173 		return getTravel();
174 	}
175 	/**
176 	The moving object's remaining movement vector.
177 	*/
178 	@property Vector2 remainder()
179 	{
180 		return getRemainder();
181 	}
182 	/**
183 	The moving object's colliding shape.
184 	*/
185 	@property GodotObject localShape()
186 	{
187 		return getLocalShape();
188 	}
189 	/**
190 	The colliding body.
191 	*/
192 	@property GodotObject collider()
193 	{
194 		return getCollider();
195 	}
196 	/**
197 	The colliding body's unique $(D RID).
198 	*/
199 	@property long colliderId()
200 	{
201 		return getColliderId();
202 	}
203 	/**
204 	The colliding body's shape.
205 	*/
206 	@property GodotObject colliderShape()
207 	{
208 		return getColliderShape();
209 	}
210 	/**
211 	The colliding shape's index. See $(D CollisionObject2D).
212 	*/
213 	@property long colliderShapeIndex()
214 	{
215 		return getColliderShapeIndex();
216 	}
217 	/**
218 	The colliding object's velocity.
219 	*/
220 	@property Vector2 colliderVelocity()
221 	{
222 		return getColliderVelocity();
223 	}
224 	/**
225 	The colliding body's metadata. See $(D GodotObject).
226 	*/
227 	@property Variant colliderMetadata()
228 	{
229 		return getColliderMetadata();
230 	}
231 }