1 /**
2 A node to be used for advanced animation transitions in an $(D AnimationPlayer).
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.animationtree;
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.node;
25 import godot.animationnode;
26 /**
27 A node to be used for advanced animation transitions in an $(D AnimationPlayer).
28 
29 Note: When linked with an $(D AnimationPlayer), several properties and methods of the corresponding $(D AnimationPlayer) will not function as expected. Playback and transitions should be handled using only the $(D AnimationTree) and its constituent $(D AnimationNode)(s). The $(D AnimationPlayer) node should be used solely for adding, deleting, and editing animations.
30 */
31 @GodotBaseClass struct AnimationTree
32 {
33 	package(godot) enum string _GODOT_internal_name = "AnimationTree";
34 public:
35 @nogc nothrow:
36 	union { /** */ godot_object _godot_object; /** */ Node _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("_clear_caches") GodotMethod!(void) _clearCaches;
44 		@GodotName("_node_removed") GodotMethod!(void, Node) _nodeRemoved;
45 		@GodotName("_tree_changed") GodotMethod!(void) _treeChanged;
46 		@GodotName("_update_properties") GodotMethod!(void) _updateProperties;
47 		@GodotName("advance") GodotMethod!(void, double) advance;
48 		@GodotName("get_animation_player") GodotMethod!(NodePath) getAnimationPlayer;
49 		@GodotName("get_process_mode") GodotMethod!(AnimationTree.AnimationProcessMode) getProcessMode;
50 		@GodotName("get_root_motion_track") GodotMethod!(NodePath) getRootMotionTrack;
51 		@GodotName("get_root_motion_transform") GodotMethod!(Transform) getRootMotionTransform;
52 		@GodotName("get_tree_root") GodotMethod!(AnimationNode) getTreeRoot;
53 		@GodotName("is_active") GodotMethod!(bool) isActive;
54 		@GodotName("rename_parameter") GodotMethod!(void, String, String) renameParameter;
55 		@GodotName("set_active") GodotMethod!(void, bool) setActive;
56 		@GodotName("set_animation_player") GodotMethod!(void, NodePath) setAnimationPlayer;
57 		@GodotName("set_process_mode") GodotMethod!(void, long) setProcessMode;
58 		@GodotName("set_root_motion_track") GodotMethod!(void, NodePath) setRootMotionTrack;
59 		@GodotName("set_tree_root") GodotMethod!(void, AnimationNode) setTreeRoot;
60 	}
61 	/// 
62 	pragma(inline, true) bool opEquals(in AnimationTree other) const
63 	{ return _godot_object.ptr is other._godot_object.ptr; }
64 	/// 
65 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
66 	{ _godot_object.ptr = n; return null; }
67 	/// 
68 	pragma(inline, true) bool opEquals(typeof(null) n) const
69 	{ return _godot_object.ptr is n; }
70 	/// 
71 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
72 	mixin baseCasts;
73 	/// Construct a new instance of AnimationTree.
74 	/// Note: use `memnew!AnimationTree` instead.
75 	static AnimationTree _new()
76 	{
77 		static godot_class_constructor constructor;
78 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("AnimationTree");
79 		if(constructor is null) return typeof(this).init;
80 		return cast(AnimationTree)(constructor());
81 	}
82 	@disable new(size_t s);
83 	/// 
84 	enum AnimationProcessMode : int
85 	{
86 		/**
87 		The animations will progress during the physics frame (i.e. $(D Node._physicsProcess)).
88 		*/
89 		animationProcessPhysics = 0,
90 		/**
91 		The animations will progress during the idle frame (i.e. $(D Node._process)).
92 		*/
93 		animationProcessIdle = 1,
94 		/**
95 		The animations will only progress manually (see $(D advance)).
96 		*/
97 		animationProcessManual = 2,
98 	}
99 	/// 
100 	enum Constants : int
101 	{
102 		animationProcessPhysics = 0,
103 		animationProcessIdle = 1,
104 		animationProcessManual = 2,
105 	}
106 	/**
107 	
108 	*/
109 	void _clearCaches()
110 	{
111 		Array _GODOT_args = Array.make();
112 		String _GODOT_method_name = String("_clear_caches");
113 		this.callv(_GODOT_method_name, _GODOT_args);
114 	}
115 	/**
116 	
117 	*/
118 	void _nodeRemoved(Node arg0)
119 	{
120 		Array _GODOT_args = Array.make();
121 		_GODOT_args.append(arg0);
122 		String _GODOT_method_name = String("_node_removed");
123 		this.callv(_GODOT_method_name, _GODOT_args);
124 	}
125 	/**
126 	
127 	*/
128 	void _treeChanged()
129 	{
130 		Array _GODOT_args = Array.make();
131 		String _GODOT_method_name = String("_tree_changed");
132 		this.callv(_GODOT_method_name, _GODOT_args);
133 	}
134 	/**
135 	
136 	*/
137 	void _updateProperties()
138 	{
139 		Array _GODOT_args = Array.make();
140 		String _GODOT_method_name = String("_update_properties");
141 		this.callv(_GODOT_method_name, _GODOT_args);
142 	}
143 	/**
144 	Manually advance the animations by the specified time (in seconds).
145 	*/
146 	void advance(in double delta)
147 	{
148 		checkClassBinding!(typeof(this))();
149 		ptrcall!(void)(GDNativeClassBinding.advance, _godot_object, delta);
150 	}
151 	/**
152 	
153 	*/
154 	NodePath getAnimationPlayer() const
155 	{
156 		checkClassBinding!(typeof(this))();
157 		return ptrcall!(NodePath)(GDNativeClassBinding.getAnimationPlayer, _godot_object);
158 	}
159 	/**
160 	
161 	*/
162 	AnimationTree.AnimationProcessMode getProcessMode() const
163 	{
164 		checkClassBinding!(typeof(this))();
165 		return ptrcall!(AnimationTree.AnimationProcessMode)(GDNativeClassBinding.getProcessMode, _godot_object);
166 	}
167 	/**
168 	
169 	*/
170 	NodePath getRootMotionTrack() const
171 	{
172 		checkClassBinding!(typeof(this))();
173 		return ptrcall!(NodePath)(GDNativeClassBinding.getRootMotionTrack, _godot_object);
174 	}
175 	/**
176 	Retrieve the motion of the $(D rootMotionTrack) as a $(D Transform) that can be used elsewhere. If $(D rootMotionTrack) is not a path to a track of type $(D constant Animation.TYPE_TRANSFORM), returns an identity transformation. See also $(D rootMotionTrack) and $(D RootMotionView).
177 	*/
178 	Transform getRootMotionTransform() const
179 	{
180 		checkClassBinding!(typeof(this))();
181 		return ptrcall!(Transform)(GDNativeClassBinding.getRootMotionTransform, _godot_object);
182 	}
183 	/**
184 	
185 	*/
186 	Ref!AnimationNode getTreeRoot() const
187 	{
188 		checkClassBinding!(typeof(this))();
189 		return ptrcall!(AnimationNode)(GDNativeClassBinding.getTreeRoot, _godot_object);
190 	}
191 	/**
192 	
193 	*/
194 	bool isActive() const
195 	{
196 		checkClassBinding!(typeof(this))();
197 		return ptrcall!(bool)(GDNativeClassBinding.isActive, _godot_object);
198 	}
199 	/**
200 	
201 	*/
202 	void renameParameter(in String old_name, in String new_name)
203 	{
204 		checkClassBinding!(typeof(this))();
205 		ptrcall!(void)(GDNativeClassBinding.renameParameter, _godot_object, old_name, new_name);
206 	}
207 	/**
208 	
209 	*/
210 	void setActive(in bool active)
211 	{
212 		checkClassBinding!(typeof(this))();
213 		ptrcall!(void)(GDNativeClassBinding.setActive, _godot_object, active);
214 	}
215 	/**
216 	
217 	*/
218 	void setAnimationPlayer(NodePathArg0)(in NodePathArg0 root)
219 	{
220 		checkClassBinding!(typeof(this))();
221 		ptrcall!(void)(GDNativeClassBinding.setAnimationPlayer, _godot_object, root);
222 	}
223 	/**
224 	
225 	*/
226 	void setProcessMode(in long mode)
227 	{
228 		checkClassBinding!(typeof(this))();
229 		ptrcall!(void)(GDNativeClassBinding.setProcessMode, _godot_object, mode);
230 	}
231 	/**
232 	
233 	*/
234 	void setRootMotionTrack(NodePathArg0)(in NodePathArg0 path)
235 	{
236 		checkClassBinding!(typeof(this))();
237 		ptrcall!(void)(GDNativeClassBinding.setRootMotionTrack, _godot_object, path);
238 	}
239 	/**
240 	
241 	*/
242 	void setTreeRoot(AnimationNode root)
243 	{
244 		checkClassBinding!(typeof(this))();
245 		ptrcall!(void)(GDNativeClassBinding.setTreeRoot, _godot_object, root);
246 	}
247 	/**
248 	If `true`, the $(D AnimationTree) will be processing.
249 	*/
250 	@property bool active()
251 	{
252 		return isActive();
253 	}
254 	/// ditto
255 	@property void active(bool v)
256 	{
257 		setActive(v);
258 	}
259 	/**
260 	The path to the $(D AnimationPlayer) used for animating.
261 	*/
262 	@property NodePath animPlayer()
263 	{
264 		return getAnimationPlayer();
265 	}
266 	/// ditto
267 	@property void animPlayer(NodePath v)
268 	{
269 		setAnimationPlayer(v);
270 	}
271 	/**
272 	The process mode of this $(D AnimationTree). See $(D animationprocessmode) for available modes.
273 	*/
274 	@property AnimationTree.AnimationProcessMode processMode()
275 	{
276 		return getProcessMode();
277 	}
278 	/// ditto
279 	@property void processMode(long v)
280 	{
281 		setProcessMode(v);
282 	}
283 	/**
284 	The path to the Animation track used for root motion. Paths must be valid scene-tree paths to a node, and must be specified starting from the parent node of the node that will reproduce the animation. To specify a track that controls properties or bones, append its name after the path, separated by `":"`. For example, `"character/skeleton:ankle"` or `"character/mesh:transform/local"`.
285 	If the track has type $(D constant Animation.TYPE_TRANSFORM), the transformation will be cancelled visually, and the animation will appear to stay in place. See also $(D getRootMotionTransform) and $(D RootMotionView).
286 	*/
287 	@property NodePath rootMotionTrack()
288 	{
289 		return getRootMotionTrack();
290 	}
291 	/// ditto
292 	@property void rootMotionTrack(NodePath v)
293 	{
294 		setRootMotionTrack(v);
295 	}
296 	/**
297 	The root animation node of this $(D AnimationTree). See $(D AnimationNode).
298 	*/
299 	@property AnimationNode treeRoot()
300 	{
301 		return getTreeRoot();
302 	}
303 	/// ditto
304 	@property void treeRoot(AnimationNode v)
305 	{
306 		setTreeRoot(v);
307 	}
308 }