1 /**
2 Damped spring constraint for 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.dampedspringjoint2d;
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.joint2d;
24 import godot.node2d;
25 import godot.canvasitem;
26 import godot.node;
27 /**
28 Damped spring constraint for 2D physics.
29 
30 This resembles a spring joint that always wants to go back to a given length.
31 */
32 @GodotBaseClass struct DampedSpringJoint2D
33 {
34 	enum string _GODOT_internal_name = "DampedSpringJoint2D";
35 public:
36 @nogc nothrow:
37 	union { godot_object _godot_object; Joint2D _GODOT_base; }
38 	alias _GODOT_base this;
39 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
40 	package(godot) __gshared bool _classBindingInitialized = false;
41 	package(godot) static struct _classBinding
42 	{
43 		__gshared:
44 		@GodotName("set_length") GodotMethod!(void, double) setLength;
45 		@GodotName("get_length") GodotMethod!(double) getLength;
46 		@GodotName("set_rest_length") GodotMethod!(void, double) setRestLength;
47 		@GodotName("get_rest_length") GodotMethod!(double) getRestLength;
48 		@GodotName("set_stiffness") GodotMethod!(void, double) setStiffness;
49 		@GodotName("get_stiffness") GodotMethod!(double) getStiffness;
50 		@GodotName("set_damping") GodotMethod!(void, double) setDamping;
51 		@GodotName("get_damping") GodotMethod!(double) getDamping;
52 	}
53 	bool opEquals(in DampedSpringJoint2D other) const { return _godot_object.ptr is other._godot_object.ptr; }
54 	DampedSpringJoint2D opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; }
55 	bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; }
56 	mixin baseCasts;
57 	static DampedSpringJoint2D _new()
58 	{
59 		static godot_class_constructor constructor;
60 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("DampedSpringJoint2D");
61 		if(constructor is null) return typeof(this).init;
62 		return cast(DampedSpringJoint2D)(constructor());
63 	}
64 	@disable new(size_t s);
65 	/**
66 	
67 	*/
68 	void setLength(in double length)
69 	{
70 		checkClassBinding!(typeof(this))();
71 		ptrcall!(void)(_classBinding.setLength, _godot_object, length);
72 	}
73 	/**
74 	
75 	*/
76 	double getLength() const
77 	{
78 		checkClassBinding!(typeof(this))();
79 		return ptrcall!(double)(_classBinding.getLength, _godot_object);
80 	}
81 	/**
82 	
83 	*/
84 	void setRestLength(in double rest_length)
85 	{
86 		checkClassBinding!(typeof(this))();
87 		ptrcall!(void)(_classBinding.setRestLength, _godot_object, rest_length);
88 	}
89 	/**
90 	
91 	*/
92 	double getRestLength() const
93 	{
94 		checkClassBinding!(typeof(this))();
95 		return ptrcall!(double)(_classBinding.getRestLength, _godot_object);
96 	}
97 	/**
98 	
99 	*/
100 	void setStiffness(in double stiffness)
101 	{
102 		checkClassBinding!(typeof(this))();
103 		ptrcall!(void)(_classBinding.setStiffness, _godot_object, stiffness);
104 	}
105 	/**
106 	
107 	*/
108 	double getStiffness() const
109 	{
110 		checkClassBinding!(typeof(this))();
111 		return ptrcall!(double)(_classBinding.getStiffness, _godot_object);
112 	}
113 	/**
114 	
115 	*/
116 	void setDamping(in double damping)
117 	{
118 		checkClassBinding!(typeof(this))();
119 		ptrcall!(void)(_classBinding.setDamping, _godot_object, damping);
120 	}
121 	/**
122 	
123 	*/
124 	double getDamping() const
125 	{
126 		checkClassBinding!(typeof(this))();
127 		return ptrcall!(double)(_classBinding.getDamping, _godot_object);
128 	}
129 	/**
130 	The spring joint's maximum length. The two attached bodies cannot stretch it past this value. Default value: `50`
131 	*/
132 	@property double length()
133 	{
134 		return getLength();
135 	}
136 	/// ditto
137 	@property void length(double v)
138 	{
139 		setLength(v);
140 	}
141 	/**
142 	When the bodies attached to the spring joint move they stretch or squash it. The joint always tries to resize towards this length. Default value: `0`
143 	*/
144 	@property double restLength()
145 	{
146 		return getRestLength();
147 	}
148 	/// ditto
149 	@property void restLength(double v)
150 	{
151 		setRestLength(v);
152 	}
153 	/**
154 	The higher the value, the less the bodies attached to the joint will deform it. The joint applies an opposing force to the bodies, the product of the stiffness multiplied by the size difference from its resting length. Default value: `20`
155 	*/
156 	@property double stiffness()
157 	{
158 		return getStiffness();
159 	}
160 	/// ditto
161 	@property void stiffness(double v)
162 	{
163 		setStiffness(v);
164 	}
165 	/**
166 	The spring joint's damping ratio. A value between `0` and `1`. When the two bodies move into different directions the system tries to align them to the spring axis again. A high `damping` value forces the attached bodies to align faster. Default value: `1`
167 	*/
168 	@property double damping()
169 	{
170 		return getDamping();
171 	}
172 	/// ditto
173 	@property void damping(double v)
174 	{
175 		setDamping(v);
176 	}
177 }