1 /**
2 2D sprite node in 3D world, that can use multiple 2D textures for animation.
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.animatedsprite3d;
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.spritebase3d;
24 import godot.spriteframes;
25 import godot.geometryinstance;
26 import godot.visualinstance;
27 import godot.spatial;
28 import godot.node;
29 /**
30 2D sprite node in 3D world, that can use multiple 2D textures for animation.
31 
32 Animations are created using a $(D SpriteFrames) resource, which can be configured in the editor via the SpriteFrames panel.
33 */
34 @GodotBaseClass struct AnimatedSprite3D
35 {
36 	enum string _GODOT_internal_name = "AnimatedSprite3D";
37 public:
38 @nogc nothrow:
39 	union { godot_object _godot_object; SpriteBase3D _GODOT_base; }
40 	alias _GODOT_base this;
41 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
42 	package(godot) __gshared bool _classBindingInitialized = false;
43 	package(godot) static struct _classBinding
44 	{
45 		__gshared:
46 		@GodotName("set_sprite_frames") GodotMethod!(void, SpriteFrames) setSpriteFrames;
47 		@GodotName("get_sprite_frames") GodotMethod!(SpriteFrames) getSpriteFrames;
48 		@GodotName("set_animation") GodotMethod!(void, String) setAnimation;
49 		@GodotName("get_animation") GodotMethod!(String) getAnimation;
50 		@GodotName("_set_playing") GodotMethod!(void, bool) _setPlaying;
51 		@GodotName("_is_playing") GodotMethod!(bool) _isPlaying;
52 		@GodotName("play") GodotMethod!(void, String) play;
53 		@GodotName("stop") GodotMethod!(void) stop;
54 		@GodotName("is_playing") GodotMethod!(bool) isPlaying;
55 		@GodotName("set_frame") GodotMethod!(void, long) setFrame;
56 		@GodotName("get_frame") GodotMethod!(long) getFrame;
57 		@GodotName("_res_changed") GodotMethod!(void) _resChanged;
58 	}
59 	bool opEquals(in AnimatedSprite3D other) const { return _godot_object.ptr is other._godot_object.ptr; }
60 	AnimatedSprite3D opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; }
61 	bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; }
62 	mixin baseCasts;
63 	static AnimatedSprite3D _new()
64 	{
65 		static godot_class_constructor constructor;
66 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("AnimatedSprite3D");
67 		if(constructor is null) return typeof(this).init;
68 		return cast(AnimatedSprite3D)(constructor());
69 	}
70 	@disable new(size_t s);
71 	/**
72 	
73 	*/
74 	void setSpriteFrames(SpriteFrames sprite_frames)
75 	{
76 		checkClassBinding!(typeof(this))();
77 		ptrcall!(void)(_classBinding.setSpriteFrames, _godot_object, sprite_frames);
78 	}
79 	/**
80 	
81 	*/
82 	Ref!SpriteFrames getSpriteFrames() const
83 	{
84 		checkClassBinding!(typeof(this))();
85 		return ptrcall!(SpriteFrames)(_classBinding.getSpriteFrames, _godot_object);
86 	}
87 	/**
88 	
89 	*/
90 	void setAnimation(StringArg0)(in StringArg0 animation)
91 	{
92 		checkClassBinding!(typeof(this))();
93 		ptrcall!(void)(_classBinding.setAnimation, _godot_object, animation);
94 	}
95 	/**
96 	
97 	*/
98 	String getAnimation() const
99 	{
100 		checkClassBinding!(typeof(this))();
101 		return ptrcall!(String)(_classBinding.getAnimation, _godot_object);
102 	}
103 	/**
104 	
105 	*/
106 	void _setPlaying(in bool playing)
107 	{
108 		Array _GODOT_args = Array.empty_array;
109 		_GODOT_args.append(playing);
110 		String _GODOT_method_name = String("_set_playing");
111 		this.callv(_GODOT_method_name, _GODOT_args);
112 	}
113 	/**
114 	
115 	*/
116 	bool _isPlaying() const
117 	{
118 		Array _GODOT_args = Array.empty_array;
119 		String _GODOT_method_name = String("_is_playing");
120 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!bool);
121 	}
122 	/**
123 	Play the animation set in parameter. If no parameter is provided, the current animation is played.
124 	*/
125 	void play(StringArg0)(in StringArg0 anim = "")
126 	{
127 		checkClassBinding!(typeof(this))();
128 		ptrcall!(void)(_classBinding.play, _godot_object, anim);
129 	}
130 	/**
131 	Stop the current animation (does not reset the frame counter).
132 	*/
133 	void stop()
134 	{
135 		checkClassBinding!(typeof(this))();
136 		ptrcall!(void)(_classBinding.stop, _godot_object);
137 	}
138 	/**
139 	Return true if an animation if currently being played.
140 	*/
141 	bool isPlaying() const
142 	{
143 		checkClassBinding!(typeof(this))();
144 		return ptrcall!(bool)(_classBinding.isPlaying, _godot_object);
145 	}
146 	/**
147 	
148 	*/
149 	void setFrame(in long frame)
150 	{
151 		checkClassBinding!(typeof(this))();
152 		ptrcall!(void)(_classBinding.setFrame, _godot_object, frame);
153 	}
154 	/**
155 	
156 	*/
157 	long getFrame() const
158 	{
159 		checkClassBinding!(typeof(this))();
160 		return ptrcall!(long)(_classBinding.getFrame, _godot_object);
161 	}
162 	/**
163 	
164 	*/
165 	void _resChanged()
166 	{
167 		Array _GODOT_args = Array.empty_array;
168 		String _GODOT_method_name = String("_res_changed");
169 		this.callv(_GODOT_method_name, _GODOT_args);
170 	}
171 	/**
172 	The $(D SpriteFrames) resource containing the animation(s).
173 	*/
174 	@property SpriteFrames frames()
175 	{
176 		return getSpriteFrames();
177 	}
178 	/// ditto
179 	@property void frames(SpriteFrames v)
180 	{
181 		setSpriteFrames(v);
182 	}
183 	/**
184 	The current animation from the `frames` resource. If this value changes, the `frame` counter is reset.
185 	*/
186 	@property String animation()
187 	{
188 		return getAnimation();
189 	}
190 	/// ditto
191 	@property void animation(String v)
192 	{
193 		setAnimation(v);
194 	}
195 	/**
196 	The displayed animation frame's index.
197 	*/
198 	@property long frame()
199 	{
200 		return getFrame();
201 	}
202 	/// ditto
203 	@property void frame(long v)
204 	{
205 		setFrame(v);
206 	}
207 	/**
208 	If `true` the $(D animation) is currently playing.
209 	*/
210 	@property bool playing()
211 	{
212 		return _isPlaying();
213 	}
214 	/// ditto
215 	@property void playing(bool v)
216 	{
217 		_setPlaying(v);
218 	}
219 }