1 /** 2 Base node for all joint constraints in 2D physics. 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.joint2d; 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.node2d; 23 import godot.canvasitem; 24 import godot.node; 25 /** 26 Base node for all joint constraints in 2D physics. 27 28 Joints take 2 bodies and apply a custom constraint. 29 */ 30 @GodotBaseClass struct Joint2D 31 { 32 enum string _GODOT_internal_name = "Joint2D"; 33 public: 34 @nogc nothrow: 35 union { godot_object _godot_object; Node2D _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("set_node_a") GodotMethod!(void, NodePath) setNodeA; 43 @GodotName("get_node_a") GodotMethod!(NodePath) getNodeA; 44 @GodotName("set_node_b") GodotMethod!(void, NodePath) setNodeB; 45 @GodotName("get_node_b") GodotMethod!(NodePath) getNodeB; 46 @GodotName("set_bias") GodotMethod!(void, double) setBias; 47 @GodotName("get_bias") GodotMethod!(double) getBias; 48 @GodotName("set_exclude_nodes_from_collision") GodotMethod!(void, bool) setExcludeNodesFromCollision; 49 @GodotName("get_exclude_nodes_from_collision") GodotMethod!(bool) getExcludeNodesFromCollision; 50 } 51 bool opEquals(in Joint2D other) const { return _godot_object.ptr is other._godot_object.ptr; } 52 Joint2D opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 53 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 54 mixin baseCasts; 55 static Joint2D _new() 56 { 57 static godot_class_constructor constructor; 58 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("Joint2D"); 59 if(constructor is null) return typeof(this).init; 60 return cast(Joint2D)(constructor()); 61 } 62 @disable new(size_t s); 63 /** 64 65 */ 66 void setNodeA(NodePathArg0)(in NodePathArg0 node) 67 { 68 checkClassBinding!(typeof(this))(); 69 ptrcall!(void)(_classBinding.setNodeA, _godot_object, node); 70 } 71 /** 72 73 */ 74 NodePath getNodeA() const 75 { 76 checkClassBinding!(typeof(this))(); 77 return ptrcall!(NodePath)(_classBinding.getNodeA, _godot_object); 78 } 79 /** 80 81 */ 82 void setNodeB(NodePathArg0)(in NodePathArg0 node) 83 { 84 checkClassBinding!(typeof(this))(); 85 ptrcall!(void)(_classBinding.setNodeB, _godot_object, node); 86 } 87 /** 88 89 */ 90 NodePath getNodeB() const 91 { 92 checkClassBinding!(typeof(this))(); 93 return ptrcall!(NodePath)(_classBinding.getNodeB, _godot_object); 94 } 95 /** 96 97 */ 98 void setBias(in double bias) 99 { 100 checkClassBinding!(typeof(this))(); 101 ptrcall!(void)(_classBinding.setBias, _godot_object, bias); 102 } 103 /** 104 105 */ 106 double getBias() const 107 { 108 checkClassBinding!(typeof(this))(); 109 return ptrcall!(double)(_classBinding.getBias, _godot_object); 110 } 111 /** 112 113 */ 114 void setExcludeNodesFromCollision(in bool enable) 115 { 116 checkClassBinding!(typeof(this))(); 117 ptrcall!(void)(_classBinding.setExcludeNodesFromCollision, _godot_object, enable); 118 } 119 /** 120 121 */ 122 bool getExcludeNodesFromCollision() const 123 { 124 checkClassBinding!(typeof(this))(); 125 return ptrcall!(bool)(_classBinding.getExcludeNodesFromCollision, _godot_object); 126 } 127 /** 128 The first body attached to the joint. Must derive from $(D PhysicsBody2D). 129 */ 130 @property NodePath nodeA() 131 { 132 return getNodeA(); 133 } 134 /// ditto 135 @property void nodeA(NodePath v) 136 { 137 setNodeA(v); 138 } 139 /** 140 The second body attached to the joint. Must derive from $(D PhysicsBody2D). 141 */ 142 @property NodePath nodeB() 143 { 144 return getNodeB(); 145 } 146 /// ditto 147 @property void nodeB(NodePath v) 148 { 149 setNodeB(v); 150 } 151 /** 152 When $(D nodeA) and $(D nodeB) move in different directions the `bias` controls how fast the joint pulls them back to their original position. The lower the `bias` the more the two bodies can pull on the joint. Default value: `0` 153 */ 154 @property double bias() 155 { 156 return getBias(); 157 } 158 /// ditto 159 @property void bias(double v) 160 { 161 setBias(v); 162 } 163 /** 164 If `true` $(D nodeA) and $(D nodeB) can collide. Default value: `false`. 165 */ 166 @property bool disableCollision() 167 { 168 return getExcludeNodesFromCollision(); 169 } 170 /// ditto 171 @property void disableCollision(bool v) 172 { 173 setExcludeNodesFromCollision(v); 174 } 175 }