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.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.node2d;
24 /**
25 Base node for all joint constraints in 2D physics.
26 
27 Joints take 2 bodies and apply a custom constraint.
28 */
29 @GodotBaseClass struct Joint2D
30 {
31 	package(godot) enum string _GODOT_internal_name = "Joint2D";
32 public:
33 @nogc nothrow:
34 	union { /** */ godot_object _godot_object; /** */ Node2D _GODOT_base; }
35 	alias _GODOT_base this;
36 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
37 	package(godot) __gshared bool _classBindingInitialized = false;
38 	package(godot) static struct GDNativeClassBinding
39 	{
40 		__gshared:
41 		@GodotName("_body_exit_tree") GodotMethod!(void) _bodyExitTree;
42 		@GodotName("get_bias") GodotMethod!(double) getBias;
43 		@GodotName("get_exclude_nodes_from_collision") GodotMethod!(bool) getExcludeNodesFromCollision;
44 		@GodotName("get_node_a") GodotMethod!(NodePath) getNodeA;
45 		@GodotName("get_node_b") GodotMethod!(NodePath) getNodeB;
46 		@GodotName("set_bias") GodotMethod!(void, double) setBias;
47 		@GodotName("set_exclude_nodes_from_collision") GodotMethod!(void, bool) setExcludeNodesFromCollision;
48 		@GodotName("set_node_a") GodotMethod!(void, NodePath) setNodeA;
49 		@GodotName("set_node_b") GodotMethod!(void, NodePath) setNodeB;
50 	}
51 	/// 
52 	pragma(inline, true) bool opEquals(in Joint2D other) const
53 	{ return _godot_object.ptr is other._godot_object.ptr; }
54 	/// 
55 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
56 	{ _godot_object.ptr = n; return null; }
57 	/// 
58 	pragma(inline, true) bool opEquals(typeof(null) n) const
59 	{ return _godot_object.ptr is n; }
60 	/// 
61 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
62 	mixin baseCasts;
63 	/// Construct a new instance of Joint2D.
64 	/// Note: use `memnew!Joint2D` instead.
65 	static Joint2D _new()
66 	{
67 		static godot_class_constructor constructor;
68 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("Joint2D");
69 		if(constructor is null) return typeof(this).init;
70 		return cast(Joint2D)(constructor());
71 	}
72 	@disable new(size_t s);
73 	/**
74 	
75 	*/
76 	void _bodyExitTree()
77 	{
78 		Array _GODOT_args = Array.make();
79 		String _GODOT_method_name = String("_body_exit_tree");
80 		this.callv(_GODOT_method_name, _GODOT_args);
81 	}
82 	/**
83 	
84 	*/
85 	double getBias() const
86 	{
87 		checkClassBinding!(typeof(this))();
88 		return ptrcall!(double)(GDNativeClassBinding.getBias, _godot_object);
89 	}
90 	/**
91 	
92 	*/
93 	bool getExcludeNodesFromCollision() const
94 	{
95 		checkClassBinding!(typeof(this))();
96 		return ptrcall!(bool)(GDNativeClassBinding.getExcludeNodesFromCollision, _godot_object);
97 	}
98 	/**
99 	
100 	*/
101 	NodePath getNodeA() const
102 	{
103 		checkClassBinding!(typeof(this))();
104 		return ptrcall!(NodePath)(GDNativeClassBinding.getNodeA, _godot_object);
105 	}
106 	/**
107 	
108 	*/
109 	NodePath getNodeB() const
110 	{
111 		checkClassBinding!(typeof(this))();
112 		return ptrcall!(NodePath)(GDNativeClassBinding.getNodeB, _godot_object);
113 	}
114 	/**
115 	
116 	*/
117 	void setBias(in double bias)
118 	{
119 		checkClassBinding!(typeof(this))();
120 		ptrcall!(void)(GDNativeClassBinding.setBias, _godot_object, bias);
121 	}
122 	/**
123 	
124 	*/
125 	void setExcludeNodesFromCollision(in bool enable)
126 	{
127 		checkClassBinding!(typeof(this))();
128 		ptrcall!(void)(GDNativeClassBinding.setExcludeNodesFromCollision, _godot_object, enable);
129 	}
130 	/**
131 	
132 	*/
133 	void setNodeA(NodePathArg0)(in NodePathArg0 node)
134 	{
135 		checkClassBinding!(typeof(this))();
136 		ptrcall!(void)(GDNativeClassBinding.setNodeA, _godot_object, node);
137 	}
138 	/**
139 	
140 	*/
141 	void setNodeB(NodePathArg0)(in NodePathArg0 node)
142 	{
143 		checkClassBinding!(typeof(this))();
144 		ptrcall!(void)(GDNativeClassBinding.setNodeB, _godot_object, node);
145 	}
146 	/**
147 	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.
148 	*/
149 	@property double bias()
150 	{
151 		return getBias();
152 	}
153 	/// ditto
154 	@property void bias(double v)
155 	{
156 		setBias(v);
157 	}
158 	/**
159 	If `true`, $(D nodeA) and $(D nodeB) can not collide.
160 	*/
161 	@property bool disableCollision()
162 	{
163 		return getExcludeNodesFromCollision();
164 	}
165 	/// ditto
166 	@property void disableCollision(bool v)
167 	{
168 		setExcludeNodesFromCollision(v);
169 	}
170 	/**
171 	The first body attached to the joint. Must derive from $(D PhysicsBody2D).
172 	*/
173 	@property NodePath nodeA()
174 	{
175 		return getNodeA();
176 	}
177 	/// ditto
178 	@property void nodeA(NodePath v)
179 	{
180 		setNodeA(v);
181 	}
182 	/**
183 	The second body attached to the joint. Must derive from $(D PhysicsBody2D).
184 	*/
185 	@property NodePath nodeB()
186 	{
187 		return getNodeB();
188 	}
189 	/// ditto
190 	@property void nodeB(NodePath v)
191 	{
192 		setNodeB(v);
193 	}
194 }