1 /** 2 Base resource for $(D AnimationTree) nodes. 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.animationnode; 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.resource; 25 /** 26 Base resource for $(D AnimationTree) nodes. 27 28 In general, it's not used directly, but you can create custom ones with custom blending formulas. 29 Inherit this when creating nodes mainly for use in $(D AnimationNodeBlendTree), otherwise $(D AnimationRootNode) should be used instead. 30 */ 31 @GodotBaseClass struct AnimationNode 32 { 33 package(godot) enum string _GODOT_internal_name = "AnimationNode"; 34 public: 35 @nogc nothrow: 36 union { /** */ godot_object _godot_object; /** */ Resource _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("_get_filters") GodotMethod!(Array) _getFilters; 44 @GodotName("_set_filters") GodotMethod!(void, Array) _setFilters; 45 @GodotName("add_input") GodotMethod!(void, String) addInput; 46 @GodotName("blend_animation") GodotMethod!(void, String, double, double, bool, double) blendAnimation; 47 @GodotName("blend_input") GodotMethod!(double, long, double, bool, double, long, bool) blendInput; 48 @GodotName("blend_node") GodotMethod!(double, String, AnimationNode, double, bool, double, long, bool) blendNode; 49 @GodotName("get_caption") GodotMethod!(String) getCaption; 50 @GodotName("get_child_by_name") GodotMethod!(GodotObject, String) getChildByName; 51 @GodotName("get_child_nodes") GodotMethod!(Dictionary) getChildNodes; 52 @GodotName("get_input_count") GodotMethod!(long) getInputCount; 53 @GodotName("get_input_name") GodotMethod!(String, long) getInputName; 54 @GodotName("get_parameter") GodotMethod!(Variant, String) getParameter; 55 @GodotName("get_parameter_default_value") GodotMethod!(Variant, String) getParameterDefaultValue; 56 @GodotName("get_parameter_list") GodotMethod!(Array) getParameterList; 57 @GodotName("has_filter") GodotMethod!(String) hasFilter; 58 @GodotName("is_filter_enabled") GodotMethod!(bool) isFilterEnabled; 59 @GodotName("is_path_filtered") GodotMethod!(bool, NodePath) isPathFiltered; 60 @GodotName("process") GodotMethod!(void, double, bool) process; 61 @GodotName("remove_input") GodotMethod!(void, long) removeInput; 62 @GodotName("set_filter_enabled") GodotMethod!(void, bool) setFilterEnabled; 63 @GodotName("set_filter_path") GodotMethod!(void, NodePath, bool) setFilterPath; 64 @GodotName("set_parameter") GodotMethod!(void, String, Variant) setParameter; 65 } 66 /// 67 pragma(inline, true) bool opEquals(in AnimationNode other) const 68 { return _godot_object.ptr is other._godot_object.ptr; } 69 /// 70 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 71 { _godot_object.ptr = n; return null; } 72 /// 73 pragma(inline, true) bool opEquals(typeof(null) n) const 74 { return _godot_object.ptr is n; } 75 /// 76 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 77 mixin baseCasts; 78 /// Construct a new instance of AnimationNode. 79 /// Note: use `memnew!AnimationNode` instead. 80 static AnimationNode _new() 81 { 82 static godot_class_constructor constructor; 83 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("AnimationNode"); 84 if(constructor is null) return typeof(this).init; 85 return cast(AnimationNode)(constructor()); 86 } 87 @disable new(size_t s); 88 /// 89 enum FilterAction : int 90 { 91 /** 92 Do not use filtering. 93 */ 94 filterIgnore = 0, 95 /** 96 Paths matching the filter will be allowed to pass. 97 */ 98 filterPass = 1, 99 /** 100 Paths matching the filter will be discarded. 101 */ 102 filterStop = 2, 103 /** 104 Paths matching the filter will be blended (by the blend value). 105 */ 106 filterBlend = 3, 107 } 108 /// 109 enum Constants : int 110 { 111 filterIgnore = 0, 112 filterPass = 1, 113 filterStop = 2, 114 filterBlend = 3, 115 } 116 /** 117 118 */ 119 Array _getFilters() const 120 { 121 Array _GODOT_args = Array.make(); 122 String _GODOT_method_name = String("_get_filters"); 123 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!Array); 124 } 125 /** 126 127 */ 128 void _setFilters(in Array filters) 129 { 130 Array _GODOT_args = Array.make(); 131 _GODOT_args.append(filters); 132 String _GODOT_method_name = String("_set_filters"); 133 this.callv(_GODOT_method_name, _GODOT_args); 134 } 135 /** 136 Adds an input to the node. This is only useful for nodes created for use in an $(D AnimationNodeBlendTree). 137 */ 138 void addInput(in String name) 139 { 140 checkClassBinding!(typeof(this))(); 141 ptrcall!(void)(GDNativeClassBinding.addInput, _godot_object, name); 142 } 143 /** 144 Blend an animation by `blend` amount (name must be valid in the linked $(D AnimationPlayer)). A `time` and `delta` may be passed, as well as whether `seek` happened. 145 */ 146 void blendAnimation(in String animation, in double time, in double delta, in bool seeked, in double blend) 147 { 148 checkClassBinding!(typeof(this))(); 149 ptrcall!(void)(GDNativeClassBinding.blendAnimation, _godot_object, animation, time, delta, seeked, blend); 150 } 151 /** 152 Blend an input. This is only useful for nodes created for an $(D AnimationNodeBlendTree). The `time` parameter is a relative delta, unless `seek` is `true`, in which case it is absolute. A filter mode may be optionally passed (see $(D filteraction) for options). 153 */ 154 double blendInput(in long input_index, in double time, in bool seek, in double blend, in long filter = 0, in bool optimize = true) 155 { 156 checkClassBinding!(typeof(this))(); 157 return ptrcall!(double)(GDNativeClassBinding.blendInput, _godot_object, input_index, time, seek, blend, filter, optimize); 158 } 159 /** 160 Blend another animation node (in case this node contains children animation nodes). This function is only useful if you inherit from $(D AnimationRootNode) instead, else editors will not display your node for addition. 161 */ 162 double blendNode(in String name, AnimationNode node, in double time, in bool seek, in double blend, in long filter = 0, in bool optimize = true) 163 { 164 checkClassBinding!(typeof(this))(); 165 return ptrcall!(double)(GDNativeClassBinding.blendNode, _godot_object, name, node, time, seek, blend, filter, optimize); 166 } 167 /** 168 Gets the text caption for this node (used by some editors). 169 */ 170 String getCaption() 171 { 172 Array _GODOT_args = Array.make(); 173 String _GODOT_method_name = String("get_caption"); 174 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!String); 175 } 176 /** 177 Gets a child node by index (used by editors inheriting from $(D AnimationRootNode)). 178 */ 179 GodotObject getChildByName(in String name) 180 { 181 Array _GODOT_args = Array.make(); 182 _GODOT_args.append(name); 183 String _GODOT_method_name = String("get_child_by_name"); 184 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!GodotObject); 185 } 186 /** 187 Gets all children nodes in order as a `name: node` dictionary. Only useful when inheriting $(D AnimationRootNode). 188 */ 189 Dictionary getChildNodes() 190 { 191 Array _GODOT_args = Array.make(); 192 String _GODOT_method_name = String("get_child_nodes"); 193 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!Dictionary); 194 } 195 /** 196 Amount of inputs in this node, only useful for nodes that go into $(D AnimationNodeBlendTree). 197 */ 198 long getInputCount() const 199 { 200 checkClassBinding!(typeof(this))(); 201 return ptrcall!(long)(GDNativeClassBinding.getInputCount, _godot_object); 202 } 203 /** 204 Gets the name of an input by index. 205 */ 206 String getInputName(in long input) 207 { 208 checkClassBinding!(typeof(this))(); 209 return ptrcall!(String)(GDNativeClassBinding.getInputName, _godot_object, input); 210 } 211 /** 212 Gets the value of a parameter. Parameters are custom local memory used for your nodes, given a resource can be reused in multiple trees. 213 */ 214 Variant getParameter(in String name) const 215 { 216 checkClassBinding!(typeof(this))(); 217 return ptrcall!(Variant)(GDNativeClassBinding.getParameter, _godot_object, name); 218 } 219 /** 220 Gets the default value of a parameter. Parameters are custom local memory used for your nodes, given a resource can be reused in multiple trees. 221 */ 222 Variant getParameterDefaultValue(in String name) 223 { 224 Array _GODOT_args = Array.make(); 225 _GODOT_args.append(name); 226 String _GODOT_method_name = String("get_parameter_default_value"); 227 return this.callv(_GODOT_method_name, _GODOT_args); 228 } 229 /** 230 Gets the property information for parameter. Parameters are custom local memory used for your nodes, given a resource can be reused in multiple trees. Format is similar to $(D GodotObject.getPropertyList). 231 */ 232 Array getParameterList() 233 { 234 Array _GODOT_args = Array.make(); 235 String _GODOT_method_name = String("get_parameter_list"); 236 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!Array); 237 } 238 /** 239 Returns `true` whether you want the blend tree editor to display filter editing on this node. 240 */ 241 String hasFilter() 242 { 243 Array _GODOT_args = Array.make(); 244 String _GODOT_method_name = String("has_filter"); 245 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!String); 246 } 247 /** 248 249 */ 250 bool isFilterEnabled() const 251 { 252 checkClassBinding!(typeof(this))(); 253 return ptrcall!(bool)(GDNativeClassBinding.isFilterEnabled, _godot_object); 254 } 255 /** 256 Returns `true` whether a given path is filtered. 257 */ 258 bool isPathFiltered(NodePathArg0)(in NodePathArg0 path) const 259 { 260 checkClassBinding!(typeof(this))(); 261 return ptrcall!(bool)(GDNativeClassBinding.isPathFiltered, _godot_object, path); 262 } 263 /** 264 User-defined callback called when a custom node is processed. The `time` parameter is a relative delta, unless `seek` is `true`, in which case it is absolute. 265 Here, call the $(D blendInput), $(D blendNode) or $(D blendAnimation) functions. You can also use $(D getParameter) and $(D setParameter) to modify local memory. 266 This function should return the time left for the current animation to finish (if unsure, pass the value from the main blend being called). 267 */ 268 void process(in double time, in bool seek) 269 { 270 Array _GODOT_args = Array.make(); 271 _GODOT_args.append(time); 272 _GODOT_args.append(seek); 273 String _GODOT_method_name = String("process"); 274 this.callv(_GODOT_method_name, _GODOT_args); 275 } 276 /** 277 Removes an input, call this only when inactive. 278 */ 279 void removeInput(in long index) 280 { 281 checkClassBinding!(typeof(this))(); 282 ptrcall!(void)(GDNativeClassBinding.removeInput, _godot_object, index); 283 } 284 /** 285 286 */ 287 void setFilterEnabled(in bool enable) 288 { 289 checkClassBinding!(typeof(this))(); 290 ptrcall!(void)(GDNativeClassBinding.setFilterEnabled, _godot_object, enable); 291 } 292 /** 293 Adds or removes a path for the filter. 294 */ 295 void setFilterPath(NodePathArg0)(in NodePathArg0 path, in bool enable) 296 { 297 checkClassBinding!(typeof(this))(); 298 ptrcall!(void)(GDNativeClassBinding.setFilterPath, _godot_object, path, enable); 299 } 300 /** 301 Sets a custom parameter. These are used as local storage, because resources can be reused across the tree or scenes. 302 */ 303 void setParameter(VariantArg1)(in String name, in VariantArg1 value) 304 { 305 checkClassBinding!(typeof(this))(); 306 ptrcall!(void)(GDNativeClassBinding.setParameter, _godot_object, name, value); 307 } 308 /** 309 If `true`, filtering is enabled. 310 */ 311 @property bool filterEnabled() 312 { 313 return isFilterEnabled(); 314 } 315 /// ditto 316 @property void filterEnabled(bool v) 317 { 318 setFilterEnabled(v); 319 } 320 /** 321 322 */ 323 @property Array filters() 324 { 325 return _getFilters(); 326 } 327 /// ditto 328 @property void filters(Array v) 329 { 330 _setFilters(v); 331 } 332 }