1 /**
2 A $(D Camera) that includes collision.
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.clippedcamera;
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.camera;
25 import godot.spatial;
26 /**
27 A $(D Camera) that includes collision.
28 
29 This node extends $(D Camera) to add collisions with $(D Area) and/or $(D PhysicsBody) nodes. The camera cannot move through colliding objects.
30 */
31 @GodotBaseClass struct ClippedCamera
32 {
33 	package(godot) enum string _GODOT_internal_name = "ClippedCamera";
34 public:
35 @nogc nothrow:
36 	union { /** */ godot_object _godot_object; /** */ Camera _GODOT_base; }
37 	alias _GODOT_base this;
38 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
39 	package(godot) __gshared bool _classBindingInitialized = false;
40 	package(godot) static struct GDNativeClassBinding
41 	{
42 		__gshared:
43 		@GodotName("add_exception") GodotMethod!(void, GodotObject) addException;
44 		@GodotName("add_exception_rid") GodotMethod!(void, RID) addExceptionRid;
45 		@GodotName("clear_exceptions") GodotMethod!(void) clearExceptions;
46 		@GodotName("get_clip_offset") GodotMethod!(double) getClipOffset;
47 		@GodotName("get_collision_mask") GodotMethod!(long) getCollisionMask;
48 		@GodotName("get_collision_mask_bit") GodotMethod!(bool, long) getCollisionMaskBit;
49 		@GodotName("get_margin") GodotMethod!(double) getMargin;
50 		@GodotName("get_process_mode") GodotMethod!(ClippedCamera.ProcessMode) getProcessMode;
51 		@GodotName("is_clip_to_areas_enabled") GodotMethod!(bool) isClipToAreasEnabled;
52 		@GodotName("is_clip_to_bodies_enabled") GodotMethod!(bool) isClipToBodiesEnabled;
53 		@GodotName("remove_exception") GodotMethod!(void, GodotObject) removeException;
54 		@GodotName("remove_exception_rid") GodotMethod!(void, RID) removeExceptionRid;
55 		@GodotName("set_clip_to_areas") GodotMethod!(void, bool) setClipToAreas;
56 		@GodotName("set_clip_to_bodies") GodotMethod!(void, bool) setClipToBodies;
57 		@GodotName("set_collision_mask") GodotMethod!(void, long) setCollisionMask;
58 		@GodotName("set_collision_mask_bit") GodotMethod!(void, long, bool) setCollisionMaskBit;
59 		@GodotName("set_margin") GodotMethod!(void, double) setMargin;
60 		@GodotName("set_process_mode") GodotMethod!(void, long) setProcessMode;
61 	}
62 	/// 
63 	pragma(inline, true) bool opEquals(in ClippedCamera other) const
64 	{ return _godot_object.ptr is other._godot_object.ptr; }
65 	/// 
66 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
67 	{ _godot_object.ptr = n; return null; }
68 	/// 
69 	pragma(inline, true) bool opEquals(typeof(null) n) const
70 	{ return _godot_object.ptr is n; }
71 	/// 
72 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
73 	mixin baseCasts;
74 	/// Construct a new instance of ClippedCamera.
75 	/// Note: use `memnew!ClippedCamera` instead.
76 	static ClippedCamera _new()
77 	{
78 		static godot_class_constructor constructor;
79 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("ClippedCamera");
80 		if(constructor is null) return typeof(this).init;
81 		return cast(ClippedCamera)(constructor());
82 	}
83 	@disable new(size_t s);
84 	/// 
85 	enum ProcessMode : int
86 	{
87 		/**
88 		The camera updates with the `_physics_process` callback.
89 		*/
90 		clipProcessPhysics = 0,
91 		/**
92 		The camera updates with the `_process` callback.
93 		*/
94 		clipProcessIdle = 1,
95 	}
96 	/// 
97 	enum Constants : int
98 	{
99 		clipProcessPhysics = 0,
100 		clipProcessIdle = 1,
101 	}
102 	/**
103 	Adds a collision exception so the camera does not collide with the specified node.
104 	*/
105 	void addException(GodotObject node)
106 	{
107 		checkClassBinding!(typeof(this))();
108 		ptrcall!(void)(GDNativeClassBinding.addException, _godot_object, node);
109 	}
110 	/**
111 	Adds a collision exception so the camera does not collide with the specified $(D RID).
112 	*/
113 	void addExceptionRid(in RID rid)
114 	{
115 		checkClassBinding!(typeof(this))();
116 		ptrcall!(void)(GDNativeClassBinding.addExceptionRid, _godot_object, rid);
117 	}
118 	/**
119 	Removes all collision exceptions.
120 	*/
121 	void clearExceptions()
122 	{
123 		checkClassBinding!(typeof(this))();
124 		ptrcall!(void)(GDNativeClassBinding.clearExceptions, _godot_object);
125 	}
126 	/**
127 	Returns the distance the camera has been offset due to a collision.
128 	*/
129 	double getClipOffset() const
130 	{
131 		checkClassBinding!(typeof(this))();
132 		return ptrcall!(double)(GDNativeClassBinding.getClipOffset, _godot_object);
133 	}
134 	/**
135 	
136 	*/
137 	long getCollisionMask() const
138 	{
139 		checkClassBinding!(typeof(this))();
140 		return ptrcall!(long)(GDNativeClassBinding.getCollisionMask, _godot_object);
141 	}
142 	/**
143 	Returns `true` if the specified bit index is on.
144 	$(B Note:) Bit indices range from 0-19.
145 	*/
146 	bool getCollisionMaskBit(in long bit) const
147 	{
148 		checkClassBinding!(typeof(this))();
149 		return ptrcall!(bool)(GDNativeClassBinding.getCollisionMaskBit, _godot_object, bit);
150 	}
151 	/**
152 	
153 	*/
154 	double getMargin() const
155 	{
156 		checkClassBinding!(typeof(this))();
157 		return ptrcall!(double)(GDNativeClassBinding.getMargin, _godot_object);
158 	}
159 	/**
160 	
161 	*/
162 	ClippedCamera.ProcessMode getProcessMode() const
163 	{
164 		checkClassBinding!(typeof(this))();
165 		return ptrcall!(ClippedCamera.ProcessMode)(GDNativeClassBinding.getProcessMode, _godot_object);
166 	}
167 	/**
168 	
169 	*/
170 	bool isClipToAreasEnabled() const
171 	{
172 		checkClassBinding!(typeof(this))();
173 		return ptrcall!(bool)(GDNativeClassBinding.isClipToAreasEnabled, _godot_object);
174 	}
175 	/**
176 	
177 	*/
178 	bool isClipToBodiesEnabled() const
179 	{
180 		checkClassBinding!(typeof(this))();
181 		return ptrcall!(bool)(GDNativeClassBinding.isClipToBodiesEnabled, _godot_object);
182 	}
183 	/**
184 	Removes a collision exception with the specified node.
185 	*/
186 	void removeException(GodotObject node)
187 	{
188 		checkClassBinding!(typeof(this))();
189 		ptrcall!(void)(GDNativeClassBinding.removeException, _godot_object, node);
190 	}
191 	/**
192 	Removes a collision exception with the specified $(D RID).
193 	*/
194 	void removeExceptionRid(in RID rid)
195 	{
196 		checkClassBinding!(typeof(this))();
197 		ptrcall!(void)(GDNativeClassBinding.removeExceptionRid, _godot_object, rid);
198 	}
199 	/**
200 	
201 	*/
202 	void setClipToAreas(in bool enable)
203 	{
204 		checkClassBinding!(typeof(this))();
205 		ptrcall!(void)(GDNativeClassBinding.setClipToAreas, _godot_object, enable);
206 	}
207 	/**
208 	
209 	*/
210 	void setClipToBodies(in bool enable)
211 	{
212 		checkClassBinding!(typeof(this))();
213 		ptrcall!(void)(GDNativeClassBinding.setClipToBodies, _godot_object, enable);
214 	}
215 	/**
216 	
217 	*/
218 	void setCollisionMask(in long mask)
219 	{
220 		checkClassBinding!(typeof(this))();
221 		ptrcall!(void)(GDNativeClassBinding.setCollisionMask, _godot_object, mask);
222 	}
223 	/**
224 	Sets the specified bit index to the `value`.
225 	$(B Note:) Bit indices range from 0-19.
226 	*/
227 	void setCollisionMaskBit(in long bit, in bool value)
228 	{
229 		checkClassBinding!(typeof(this))();
230 		ptrcall!(void)(GDNativeClassBinding.setCollisionMaskBit, _godot_object, bit, value);
231 	}
232 	/**
233 	
234 	*/
235 	void setMargin(in double margin)
236 	{
237 		checkClassBinding!(typeof(this))();
238 		ptrcall!(void)(GDNativeClassBinding.setMargin, _godot_object, margin);
239 	}
240 	/**
241 	
242 	*/
243 	void setProcessMode(in long process_mode)
244 	{
245 		checkClassBinding!(typeof(this))();
246 		ptrcall!(void)(GDNativeClassBinding.setProcessMode, _godot_object, process_mode);
247 	}
248 	/**
249 	If `true`, the camera stops on contact with $(D Area)s.
250 	*/
251 	@property bool clipToAreas()
252 	{
253 		return isClipToAreasEnabled();
254 	}
255 	/// ditto
256 	@property void clipToAreas(bool v)
257 	{
258 		setClipToAreas(v);
259 	}
260 	/**
261 	If `true`, the camera stops on contact with $(D PhysicsBody)s.
262 	*/
263 	@property bool clipToBodies()
264 	{
265 		return isClipToBodiesEnabled();
266 	}
267 	/// ditto
268 	@property void clipToBodies(bool v)
269 	{
270 		setClipToBodies(v);
271 	}
272 	/**
273 	The camera's collision mask. Only objects in at least one collision layer matching the mask will be detected. See $(D url=https://docs.godotengine.org/en/3.3/tutorials/physics/physics_introduction.html#collision-layers-and-masks)Collision layers and masks$(D /url) in the documentation for more information.
274 	*/
275 	@property long collisionMask()
276 	{
277 		return getCollisionMask();
278 	}
279 	/// ditto
280 	@property void collisionMask(long v)
281 	{
282 		setCollisionMask(v);
283 	}
284 	/**
285 	The camera's collision margin. The camera can't get closer than this distance to a colliding object.
286 	*/
287 	@property double margin()
288 	{
289 		return getMargin();
290 	}
291 	/// ditto
292 	@property void margin(double v)
293 	{
294 		setMargin(v);
295 	}
296 	/**
297 	The camera's process callback. See $(D processmode).
298 	*/
299 	@property ClippedCamera.ProcessMode processMode()
300 	{
301 		return getProcessMode();
302 	}
303 	/// ditto
304 	@property void processMode(long v)
305 	{
306 		setProcessMode(v);
307 	}
308 }