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