1 /**
2 Base class for all objects affected by physics in 3D space.
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.physicsbody;
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.collisionobject;
23 import godot.spatial;
24 import godot.node;
25 /**
26 Base class for all objects affected by physics in 3D space.
27 
28 PhysicsBody is an abstract base class for implementing a physics body. All *Body types inherit from it.
29 */
30 @GodotBaseClass struct PhysicsBody
31 {
32 	enum string _GODOT_internal_name = "PhysicsBody";
33 public:
34 @nogc nothrow:
35 	union { godot_object _godot_object; CollisionObject _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 _classBinding
40 	{
41 		__gshared:
42 		@GodotName("set_collision_layer") GodotMethod!(void, long) setCollisionLayer;
43 		@GodotName("get_collision_layer") GodotMethod!(long) getCollisionLayer;
44 		@GodotName("set_collision_mask") GodotMethod!(void, long) setCollisionMask;
45 		@GodotName("get_collision_mask") GodotMethod!(long) getCollisionMask;
46 		@GodotName("set_collision_mask_bit") GodotMethod!(void, long, bool) setCollisionMaskBit;
47 		@GodotName("get_collision_mask_bit") GodotMethod!(bool, long) getCollisionMaskBit;
48 		@GodotName("set_collision_layer_bit") GodotMethod!(void, long, bool) setCollisionLayerBit;
49 		@GodotName("get_collision_layer_bit") GodotMethod!(bool, long) getCollisionLayerBit;
50 		@GodotName("_set_layers") GodotMethod!(void, long) _setLayers;
51 		@GodotName("_get_layers") GodotMethod!(long) _getLayers;
52 		@GodotName("get_collision_exceptions") GodotMethod!(Array) getCollisionExceptions;
53 		@GodotName("add_collision_exception_with") GodotMethod!(void, GodotObject) addCollisionExceptionWith;
54 		@GodotName("remove_collision_exception_with") GodotMethod!(void, GodotObject) removeCollisionExceptionWith;
55 	}
56 	bool opEquals(in PhysicsBody other) const { return _godot_object.ptr is other._godot_object.ptr; }
57 	PhysicsBody opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; }
58 	bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; }
59 	mixin baseCasts;
60 	static PhysicsBody _new()
61 	{
62 		static godot_class_constructor constructor;
63 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("PhysicsBody");
64 		if(constructor is null) return typeof(this).init;
65 		return cast(PhysicsBody)(constructor());
66 	}
67 	@disable new(size_t s);
68 	/**
69 	
70 	*/
71 	void setCollisionLayer(in long layer)
72 	{
73 		checkClassBinding!(typeof(this))();
74 		ptrcall!(void)(_classBinding.setCollisionLayer, _godot_object, layer);
75 	}
76 	/**
77 	
78 	*/
79 	long getCollisionLayer() const
80 	{
81 		checkClassBinding!(typeof(this))();
82 		return ptrcall!(long)(_classBinding.getCollisionLayer, _godot_object);
83 	}
84 	/**
85 	
86 	*/
87 	void setCollisionMask(in long mask)
88 	{
89 		checkClassBinding!(typeof(this))();
90 		ptrcall!(void)(_classBinding.setCollisionMask, _godot_object, mask);
91 	}
92 	/**
93 	
94 	*/
95 	long getCollisionMask() const
96 	{
97 		checkClassBinding!(typeof(this))();
98 		return ptrcall!(long)(_classBinding.getCollisionMask, _godot_object);
99 	}
100 	/**
101 	Sets individual bits on the collision mask. Use this if you only need to change one layer's value.
102 	*/
103 	void setCollisionMaskBit(in long bit, in bool value)
104 	{
105 		checkClassBinding!(typeof(this))();
106 		ptrcall!(void)(_classBinding.setCollisionMaskBit, _godot_object, bit, value);
107 	}
108 	/**
109 	Returns an individual bit on the collision mask.
110 	*/
111 	bool getCollisionMaskBit(in long bit) const
112 	{
113 		checkClassBinding!(typeof(this))();
114 		return ptrcall!(bool)(_classBinding.getCollisionMaskBit, _godot_object, bit);
115 	}
116 	/**
117 	Sets individual bits on the layer mask. Use this if you only need to change one layer's value.
118 	*/
119 	void setCollisionLayerBit(in long bit, in bool value)
120 	{
121 		checkClassBinding!(typeof(this))();
122 		ptrcall!(void)(_classBinding.setCollisionLayerBit, _godot_object, bit, value);
123 	}
124 	/**
125 	Returns an individual bit on the collision mask.
126 	*/
127 	bool getCollisionLayerBit(in long bit) const
128 	{
129 		checkClassBinding!(typeof(this))();
130 		return ptrcall!(bool)(_classBinding.getCollisionLayerBit, _godot_object, bit);
131 	}
132 	/**
133 	
134 	*/
135 	void _setLayers(in long mask)
136 	{
137 		Array _GODOT_args = Array.empty_array;
138 		_GODOT_args.append(mask);
139 		String _GODOT_method_name = String("_set_layers");
140 		this.callv(_GODOT_method_name, _GODOT_args);
141 	}
142 	/**
143 	
144 	*/
145 	long _getLayers() const
146 	{
147 		Array _GODOT_args = Array.empty_array;
148 		String _GODOT_method_name = String("_get_layers");
149 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!long);
150 	}
151 	/**
152 	Returns an array of nodes that were added as collision exceptions for this body.
153 	*/
154 	Array getCollisionExceptions()
155 	{
156 		checkClassBinding!(typeof(this))();
157 		return ptrcall!(Array)(_classBinding.getCollisionExceptions, _godot_object);
158 	}
159 	/**
160 	Adds a body to the list of bodies that this body can't collide with.
161 	*/
162 	void addCollisionExceptionWith(GodotObject _body)
163 	{
164 		checkClassBinding!(typeof(this))();
165 		ptrcall!(void)(_classBinding.addCollisionExceptionWith, _godot_object, _body);
166 	}
167 	/**
168 	Removes a body from the list of bodies that this body can't collide with.
169 	*/
170 	void removeCollisionExceptionWith(GodotObject _body)
171 	{
172 		checkClassBinding!(typeof(this))();
173 		ptrcall!(void)(_classBinding.removeCollisionExceptionWith, _godot_object, _body);
174 	}
175 	/**
176 	The physics layers this area is in.
177 	Collidable objects can exist in any of 32 different layers. These layers work like a tagging system, and are not visual. A collidable can use these layers to select with which objects it can collide, using the collision_mask property.
178 	A contact is detected if object A is in any of the layers that object B scans, or object B is in any layer scanned by object A.
179 	*/
180 	@property long collisionLayer()
181 	{
182 		return getCollisionLayer();
183 	}
184 	/// ditto
185 	@property void collisionLayer(long v)
186 	{
187 		setCollisionLayer(v);
188 	}
189 	/**
190 	The physics layers this area scans for collisions.
191 	*/
192 	@property long collisionMask()
193 	{
194 		return getCollisionMask();
195 	}
196 	/// ditto
197 	@property void collisionMask(long v)
198 	{
199 		setCollisionMask(v);
200 	}
201 }