1 /**
2 Enable certain nodes only when visible.
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.visibilityenabler2d;
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.visibilitynotifier2d;
24 import godot.node2d;
25 import godot.canvasitem;
26 import godot.node;
27 /**
28 Enable certain nodes only when visible.
29 
30 The VisibilityEnabler2D will disable $(D RigidBody2D), $(D AnimationPlayer), and other nodes when they are not visible. It will only affect other nodes within the same scene as the VisibilityEnabler2D itself.
31 */
32 @GodotBaseClass struct VisibilityEnabler2D
33 {
34 	enum string _GODOT_internal_name = "VisibilityEnabler2D";
35 public:
36 @nogc nothrow:
37 	union { godot_object _godot_object; VisibilityNotifier2D _GODOT_base; }
38 	alias _GODOT_base this;
39 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
40 	package(godot) __gshared bool _classBindingInitialized = false;
41 	package(godot) static struct _classBinding
42 	{
43 		__gshared:
44 		@GodotName("set_enabler") GodotMethod!(void, long, bool) setEnabler;
45 		@GodotName("is_enabler_enabled") GodotMethod!(bool, long) isEnablerEnabled;
46 		@GodotName("_node_removed") GodotMethod!(void, GodotObject) _nodeRemoved;
47 	}
48 	bool opEquals(in VisibilityEnabler2D other) const { return _godot_object.ptr is other._godot_object.ptr; }
49 	VisibilityEnabler2D opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; }
50 	bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; }
51 	mixin baseCasts;
52 	static VisibilityEnabler2D _new()
53 	{
54 		static godot_class_constructor constructor;
55 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("VisibilityEnabler2D");
56 		if(constructor is null) return typeof(this).init;
57 		return cast(VisibilityEnabler2D)(constructor());
58 	}
59 	@disable new(size_t s);
60 	/// 
61 	enum Enabler : int
62 	{
63 		/**
64 		This enabler will pause $(D AnimationPlayer) nodes.
65 		*/
66 		enablerPauseAnimations = 0,
67 		/**
68 		This enabler will freeze $(D RigidBody2D) nodes.
69 		*/
70 		enablerFreezeBodies = 1,
71 		/**
72 		This enabler will stop $(D Particles2D) nodes.
73 		*/
74 		enablerPauseParticles = 2,
75 		/**
76 		This enabler will stop the parent's _process function.
77 		*/
78 		enablerParentProcess = 3,
79 		/**
80 		This enabler will stop the parent's _physics_process function.
81 		*/
82 		enablerParentPhysicsProcess = 4,
83 		/**
84 		
85 		*/
86 		enablerPauseAnimatedSprites = 5,
87 		/**
88 		
89 		*/
90 		enablerMax = 6,
91 	}
92 	/// 
93 	enum Constants : int
94 	{
95 		enablerPauseAnimations = 0,
96 		enablerFreezeBodies = 1,
97 		enablerPauseParticles = 2,
98 		enablerParentProcess = 3,
99 		enablerParentPhysicsProcess = 4,
100 		enablerPauseAnimatedSprites = 5,
101 		enablerMax = 6,
102 	}
103 	/**
104 	
105 	*/
106 	void setEnabler(in long enabler, in bool enabled)
107 	{
108 		checkClassBinding!(typeof(this))();
109 		ptrcall!(void)(_classBinding.setEnabler, _godot_object, enabler, enabled);
110 	}
111 	/**
112 	
113 	*/
114 	bool isEnablerEnabled(in long enabler) const
115 	{
116 		checkClassBinding!(typeof(this))();
117 		return ptrcall!(bool)(_classBinding.isEnablerEnabled, _godot_object, enabler);
118 	}
119 	/**
120 	
121 	*/
122 	void _nodeRemoved(GodotObject arg0)
123 	{
124 		Array _GODOT_args = Array.empty_array;
125 		_GODOT_args.append(arg0);
126 		String _GODOT_method_name = String("_node_removed");
127 		this.callv(_GODOT_method_name, _GODOT_args);
128 	}
129 	/**
130 	If `true` $(D AnimationPlayer) nodes will be paused.
131 	*/
132 	@property bool pauseAnimations()
133 	{
134 		return isEnablerEnabled(0);
135 	}
136 	/// ditto
137 	@property void pauseAnimations(bool v)
138 	{
139 		setEnabler(0, v);
140 	}
141 	/**
142 	If `true` $(D RigidBody2D) nodes will be paused.
143 	*/
144 	@property bool freezeBodies()
145 	{
146 		return isEnablerEnabled(1);
147 	}
148 	/// ditto
149 	@property void freezeBodies(bool v)
150 	{
151 		setEnabler(1, v);
152 	}
153 	/**
154 	If `true` $(D Particles2D) nodes will be paused.
155 	*/
156 	@property bool pauseParticles()
157 	{
158 		return isEnablerEnabled(2);
159 	}
160 	/// ditto
161 	@property void pauseParticles(bool v)
162 	{
163 		setEnabler(2, v);
164 	}
165 	/**
166 	If `true` $(D AnimatedSprite) nodes will be paused.
167 	*/
168 	@property bool pauseAnimatedSprites()
169 	{
170 		return isEnablerEnabled(5);
171 	}
172 	/// ditto
173 	@property void pauseAnimatedSprites(bool v)
174 	{
175 		setEnabler(5, v);
176 	}
177 	/**
178 	If `true` the parent's $(D Node._process) will be stopped.
179 	*/
180 	@property bool processParent()
181 	{
182 		return isEnablerEnabled(3);
183 	}
184 	/// ditto
185 	@property void processParent(bool v)
186 	{
187 		setEnabler(3, v);
188 	}
189 	/**
190 	If `true` the parent's $(D Node._physicsProcess) will be stopped.
191 	*/
192 	@property bool physicsProcessParent()
193 	{
194 		return isEnablerEnabled(4);
195 	}
196 	/// ditto
197 	@property void physicsProcessParent(bool v)
198 	{
199 		setEnabler(4, v);
200 	}
201 }