1 /**
2 A material for physics properties.
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.physicsmaterial;
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.resource;
25 /**
26 A material for physics properties.
27 
28 Provides a means of modifying the collision properties of a $(D PhysicsBody).
29 */
30 @GodotBaseClass struct PhysicsMaterial
31 {
32 	package(godot) enum string _GODOT_internal_name = "PhysicsMaterial";
33 public:
34 @nogc nothrow:
35 	union { /** */ godot_object _godot_object; /** */ Resource _GODOT_base; }
36 	alias _GODOT_base this;
37 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
38 	package(godot) __gshared bool _classBindingInitialized = false;
39 	package(godot) static struct GDNativeClassBinding
40 	{
41 		__gshared:
42 		@GodotName("get_bounce") GodotMethod!(double) getBounce;
43 		@GodotName("get_friction") GodotMethod!(double) getFriction;
44 		@GodotName("is_absorbent") GodotMethod!(bool) isAbsorbent;
45 		@GodotName("is_rough") GodotMethod!(bool) isRough;
46 		@GodotName("set_absorbent") GodotMethod!(void, bool) setAbsorbent;
47 		@GodotName("set_bounce") GodotMethod!(void, double) setBounce;
48 		@GodotName("set_friction") GodotMethod!(void, double) setFriction;
49 		@GodotName("set_rough") GodotMethod!(void, bool) setRough;
50 	}
51 	/// 
52 	pragma(inline, true) bool opEquals(in PhysicsMaterial 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 PhysicsMaterial.
64 	/// Note: use `memnew!PhysicsMaterial` instead.
65 	static PhysicsMaterial _new()
66 	{
67 		static godot_class_constructor constructor;
68 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("PhysicsMaterial");
69 		if(constructor is null) return typeof(this).init;
70 		return cast(PhysicsMaterial)(constructor());
71 	}
72 	@disable new(size_t s);
73 	/**
74 	
75 	*/
76 	double getBounce() const
77 	{
78 		checkClassBinding!(typeof(this))();
79 		return ptrcall!(double)(GDNativeClassBinding.getBounce, _godot_object);
80 	}
81 	/**
82 	
83 	*/
84 	double getFriction() const
85 	{
86 		checkClassBinding!(typeof(this))();
87 		return ptrcall!(double)(GDNativeClassBinding.getFriction, _godot_object);
88 	}
89 	/**
90 	
91 	*/
92 	bool isAbsorbent() const
93 	{
94 		checkClassBinding!(typeof(this))();
95 		return ptrcall!(bool)(GDNativeClassBinding.isAbsorbent, _godot_object);
96 	}
97 	/**
98 	
99 	*/
100 	bool isRough() const
101 	{
102 		checkClassBinding!(typeof(this))();
103 		return ptrcall!(bool)(GDNativeClassBinding.isRough, _godot_object);
104 	}
105 	/**
106 	
107 	*/
108 	void setAbsorbent(in bool absorbent)
109 	{
110 		checkClassBinding!(typeof(this))();
111 		ptrcall!(void)(GDNativeClassBinding.setAbsorbent, _godot_object, absorbent);
112 	}
113 	/**
114 	
115 	*/
116 	void setBounce(in double bounce)
117 	{
118 		checkClassBinding!(typeof(this))();
119 		ptrcall!(void)(GDNativeClassBinding.setBounce, _godot_object, bounce);
120 	}
121 	/**
122 	
123 	*/
124 	void setFriction(in double friction)
125 	{
126 		checkClassBinding!(typeof(this))();
127 		ptrcall!(void)(GDNativeClassBinding.setFriction, _godot_object, friction);
128 	}
129 	/**
130 	
131 	*/
132 	void setRough(in bool rough)
133 	{
134 		checkClassBinding!(typeof(this))();
135 		ptrcall!(void)(GDNativeClassBinding.setRough, _godot_object, rough);
136 	}
137 	/**
138 	If `true`, subtracts the bounciness from the colliding object's bounciness instead of adding it.
139 	*/
140 	@property bool absorbent()
141 	{
142 		return isAbsorbent();
143 	}
144 	/// ditto
145 	@property void absorbent(bool v)
146 	{
147 		setAbsorbent(v);
148 	}
149 	/**
150 	The body's bounciness. Values range from `0` (no bounce) to `1` (full bounciness).
151 	*/
152 	@property double bounce()
153 	{
154 		return getBounce();
155 	}
156 	/// ditto
157 	@property void bounce(double v)
158 	{
159 		setBounce(v);
160 	}
161 	/**
162 	The body's friction. Values range from `0` (frictionless) to `1` (maximum friction).
163 	*/
164 	@property double friction()
165 	{
166 		return getFriction();
167 	}
168 	/// ditto
169 	@property void friction(double v)
170 	{
171 		setFriction(v);
172 	}
173 	/**
174 	If `true`, the physics engine will use the friction of the object marked as "rough" when two objects collide. If `false`, the physics engine will use the lowest friction of all colliding objects instead. If `true` for both colliding objects, the physics engine will use the highest friction.
175 	*/
176 	@property bool rough()
177 	{
178 		return isRough();
179 	}
180 	/// ditto
181 	@property void rough(bool v)
182 	{
183 		setRough(v);
184 	}
185 }