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