1 /** 2 One-shot timer. 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.scenetreetimer; 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.reference; 24 /** 25 One-shot timer. 26 27 A one-shot timer managed by the scene tree, which emits $(D timeout) on completion. See also $(D SceneTree.createTimer). 28 As opposed to $(D Timer), it does not require the instantiation of a node. Commonly used to create a one-shot delay timer as in the following example: 29 30 31 func some_function(): 32 print("Timer started.") 33 yield(get_tree().create_timer(1.0), "timeout") 34 print("Timer ended.") 35 36 37 */ 38 @GodotBaseClass struct SceneTreeTimer 39 { 40 package(godot) enum string _GODOT_internal_name = "SceneTreeTimer"; 41 public: 42 @nogc nothrow: 43 union { /** */ godot_object _godot_object; /** */ Reference _GODOT_base; } 44 alias _GODOT_base this; 45 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 46 package(godot) __gshared bool _classBindingInitialized = false; 47 package(godot) static struct GDNativeClassBinding 48 { 49 __gshared: 50 @GodotName("get_time_left") GodotMethod!(double) getTimeLeft; 51 @GodotName("set_time_left") GodotMethod!(void, double) setTimeLeft; 52 } 53 /// 54 pragma(inline, true) bool opEquals(in SceneTreeTimer other) const 55 { return _godot_object.ptr is other._godot_object.ptr; } 56 /// 57 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 58 { _godot_object.ptr = n; return null; } 59 /// 60 pragma(inline, true) bool opEquals(typeof(null) n) const 61 { return _godot_object.ptr is n; } 62 /// 63 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 64 mixin baseCasts; 65 /// Construct a new instance of SceneTreeTimer. 66 /// Note: use `memnew!SceneTreeTimer` instead. 67 static SceneTreeTimer _new() 68 { 69 static godot_class_constructor constructor; 70 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("SceneTreeTimer"); 71 if(constructor is null) return typeof(this).init; 72 return cast(SceneTreeTimer)(constructor()); 73 } 74 @disable new(size_t s); 75 /** 76 77 */ 78 double getTimeLeft() const 79 { 80 checkClassBinding!(typeof(this))(); 81 return ptrcall!(double)(GDNativeClassBinding.getTimeLeft, _godot_object); 82 } 83 /** 84 85 */ 86 void setTimeLeft(in double time) 87 { 88 checkClassBinding!(typeof(this))(); 89 ptrcall!(void)(GDNativeClassBinding.setTimeLeft, _godot_object, time); 90 } 91 /** 92 The time remaining. 93 */ 94 @property double timeLeft() 95 { 96 return getTimeLeft(); 97 } 98 /// ditto 99 @property void timeLeft(double v) 100 { 101 setTimeLeft(v); 102 } 103 }