1 /**
2 Static body 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.staticbody2d;
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.physicsbody2d;
25 import godot.collisionobject2d;
26 import godot.node2d;
27 import godot.canvasitem;
28 import godot.node;
29 import godot.physicsmaterial;
30 /**
31 Static body for 2D physics.
32 
33 A StaticBody2D is a body that is not intended to move. It is ideal for implementing objects in the environment, such as walls or platforms.
34 Additionally, a constant linear or angular velocity can be set for the static body, which will affect colliding bodies as if it were moving (for example, a conveyor belt).
35 */
36 @GodotBaseClass struct StaticBody2D
37 {
38 	package(godot) enum string _GODOT_internal_name = "StaticBody2D";
39 public:
40 @nogc nothrow:
41 	union { /** */ godot_object _godot_object; /** */ PhysicsBody2D _GODOT_base; }
42 	alias _GODOT_base this;
43 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
44 	package(godot) __gshared bool _classBindingInitialized = false;
45 	package(godot) static struct GDNativeClassBinding
46 	{
47 		__gshared:
48 		@GodotName("_reload_physics_characteristics") GodotMethod!(void) _reloadPhysicsCharacteristics;
49 		@GodotName("get_bounce") GodotMethod!(double) getBounce;
50 		@GodotName("get_constant_angular_velocity") GodotMethod!(double) getConstantAngularVelocity;
51 		@GodotName("get_constant_linear_velocity") GodotMethod!(Vector2) getConstantLinearVelocity;
52 		@GodotName("get_friction") GodotMethod!(double) getFriction;
53 		@GodotName("get_physics_material_override") GodotMethod!(PhysicsMaterial) getPhysicsMaterialOverride;
54 		@GodotName("set_bounce") GodotMethod!(void, double) setBounce;
55 		@GodotName("set_constant_angular_velocity") GodotMethod!(void, double) setConstantAngularVelocity;
56 		@GodotName("set_constant_linear_velocity") GodotMethod!(void, Vector2) setConstantLinearVelocity;
57 		@GodotName("set_friction") GodotMethod!(void, double) setFriction;
58 		@GodotName("set_physics_material_override") GodotMethod!(void, PhysicsMaterial) setPhysicsMaterialOverride;
59 	}
60 	/// 
61 	pragma(inline, true) bool opEquals(in StaticBody2D other) const
62 	{ return _godot_object.ptr is other._godot_object.ptr; }
63 	/// 
64 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
65 	{ _godot_object.ptr = n; return null; }
66 	/// 
67 	pragma(inline, true) bool opEquals(typeof(null) n) const
68 	{ return _godot_object.ptr is n; }
69 	/// 
70 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
71 	mixin baseCasts;
72 	/// Construct a new instance of StaticBody2D.
73 	/// Note: use `memnew!StaticBody2D` instead.
74 	static StaticBody2D _new()
75 	{
76 		static godot_class_constructor constructor;
77 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("StaticBody2D");
78 		if(constructor is null) return typeof(this).init;
79 		return cast(StaticBody2D)(constructor());
80 	}
81 	@disable new(size_t s);
82 	/**
83 	
84 	*/
85 	void _reloadPhysicsCharacteristics()
86 	{
87 		Array _GODOT_args = Array.make();
88 		String _GODOT_method_name = String("_reload_physics_characteristics");
89 		this.callv(_GODOT_method_name, _GODOT_args);
90 	}
91 	/**
92 	
93 	*/
94 	double getBounce() const
95 	{
96 		checkClassBinding!(typeof(this))();
97 		return ptrcall!(double)(GDNativeClassBinding.getBounce, _godot_object);
98 	}
99 	/**
100 	
101 	*/
102 	double getConstantAngularVelocity() const
103 	{
104 		checkClassBinding!(typeof(this))();
105 		return ptrcall!(double)(GDNativeClassBinding.getConstantAngularVelocity, _godot_object);
106 	}
107 	/**
108 	
109 	*/
110 	Vector2 getConstantLinearVelocity() const
111 	{
112 		checkClassBinding!(typeof(this))();
113 		return ptrcall!(Vector2)(GDNativeClassBinding.getConstantLinearVelocity, _godot_object);
114 	}
115 	/**
116 	
117 	*/
118 	double getFriction() const
119 	{
120 		checkClassBinding!(typeof(this))();
121 		return ptrcall!(double)(GDNativeClassBinding.getFriction, _godot_object);
122 	}
123 	/**
124 	
125 	*/
126 	Ref!PhysicsMaterial getPhysicsMaterialOverride() const
127 	{
128 		checkClassBinding!(typeof(this))();
129 		return ptrcall!(PhysicsMaterial)(GDNativeClassBinding.getPhysicsMaterialOverride, _godot_object);
130 	}
131 	/**
132 	
133 	*/
134 	void setBounce(in double bounce)
135 	{
136 		checkClassBinding!(typeof(this))();
137 		ptrcall!(void)(GDNativeClassBinding.setBounce, _godot_object, bounce);
138 	}
139 	/**
140 	
141 	*/
142 	void setConstantAngularVelocity(in double vel)
143 	{
144 		checkClassBinding!(typeof(this))();
145 		ptrcall!(void)(GDNativeClassBinding.setConstantAngularVelocity, _godot_object, vel);
146 	}
147 	/**
148 	
149 	*/
150 	void setConstantLinearVelocity(in Vector2 vel)
151 	{
152 		checkClassBinding!(typeof(this))();
153 		ptrcall!(void)(GDNativeClassBinding.setConstantLinearVelocity, _godot_object, vel);
154 	}
155 	/**
156 	
157 	*/
158 	void setFriction(in double friction)
159 	{
160 		checkClassBinding!(typeof(this))();
161 		ptrcall!(void)(GDNativeClassBinding.setFriction, _godot_object, friction);
162 	}
163 	/**
164 	
165 	*/
166 	void setPhysicsMaterialOverride(PhysicsMaterial physics_material_override)
167 	{
168 		checkClassBinding!(typeof(this))();
169 		ptrcall!(void)(GDNativeClassBinding.setPhysicsMaterialOverride, _godot_object, physics_material_override);
170 	}
171 	/**
172 	The body's bounciness. Values range from `0` (no bounce) to `1` (full bounciness).
173 	Deprecated, use $(D PhysicsMaterial.bounce) instead via $(D physicsMaterialOverride).
174 	*/
175 	@property double bounce()
176 	{
177 		return getBounce();
178 	}
179 	/// ditto
180 	@property void bounce(double v)
181 	{
182 		setBounce(v);
183 	}
184 	/**
185 	The body's constant angular velocity. This does not rotate the body, but affects colliding bodies, as if it were rotating.
186 	*/
187 	@property double constantAngularVelocity()
188 	{
189 		return getConstantAngularVelocity();
190 	}
191 	/// ditto
192 	@property void constantAngularVelocity(double v)
193 	{
194 		setConstantAngularVelocity(v);
195 	}
196 	/**
197 	The body's constant linear velocity. This does not move the body, but affects colliding bodies, as if it were moving.
198 	*/
199 	@property Vector2 constantLinearVelocity()
200 	{
201 		return getConstantLinearVelocity();
202 	}
203 	/// ditto
204 	@property void constantLinearVelocity(Vector2 v)
205 	{
206 		setConstantLinearVelocity(v);
207 	}
208 	/**
209 	The body's friction. Values range from `0` (no friction) to `1` (full friction).
210 	Deprecated, use $(D PhysicsMaterial.friction) instead via $(D physicsMaterialOverride).
211 	*/
212 	@property double friction()
213 	{
214 		return getFriction();
215 	}
216 	/// ditto
217 	@property void friction(double v)
218 	{
219 		setFriction(v);
220 	}
221 	/**
222 	The physics material override for the body.
223 	If a material is assigned to this property, it will be used instead of any other physics material, such as an inherited one.
224 	*/
225 	@property PhysicsMaterial physicsMaterialOverride()
226 	{
227 		return getPhysicsMaterialOverride();
228 	}
229 	/// ditto
230 	@property void physicsMaterialOverride(PhysicsMaterial v)
231 	{
232 		setPhysicsMaterialOverride(v);
233 	}
234 }