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