1 /** 2 Camera which moves toward another node. 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.interpolatedcamera; 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.camera; 24 import godot.spatial; 25 import godot.node; 26 /** 27 Camera which moves toward another node. 28 29 InterpolatedCamera is a $(D Camera) which smoothly moves to match a target node's position and rotation. 30 If it is not $(D enabled) or does not have a valid target set, InterpolatedCamera acts like a normal Camera. 31 */ 32 @GodotBaseClass struct InterpolatedCamera 33 { 34 enum string _GODOT_internal_name = "InterpolatedCamera"; 35 public: 36 @nogc nothrow: 37 union { godot_object _godot_object; Camera _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_target_path") GodotMethod!(void, NodePath) setTargetPath; 45 @GodotName("get_target_path") GodotMethod!(NodePath) getTargetPath; 46 @GodotName("set_target") GodotMethod!(void, GodotObject) setTarget; 47 @GodotName("set_speed") GodotMethod!(void, double) setSpeed; 48 @GodotName("get_speed") GodotMethod!(double) getSpeed; 49 @GodotName("set_interpolation_enabled") GodotMethod!(void, bool) setInterpolationEnabled; 50 @GodotName("is_interpolation_enabled") GodotMethod!(bool) isInterpolationEnabled; 51 } 52 bool opEquals(in InterpolatedCamera other) const { return _godot_object.ptr is other._godot_object.ptr; } 53 InterpolatedCamera opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 54 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 55 mixin baseCasts; 56 static InterpolatedCamera _new() 57 { 58 static godot_class_constructor constructor; 59 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("InterpolatedCamera"); 60 if(constructor is null) return typeof(this).init; 61 return cast(InterpolatedCamera)(constructor()); 62 } 63 @disable new(size_t s); 64 /** 65 66 */ 67 void setTargetPath(NodePathArg0)(in NodePathArg0 target_path) 68 { 69 checkClassBinding!(typeof(this))(); 70 ptrcall!(void)(_classBinding.setTargetPath, _godot_object, target_path); 71 } 72 /** 73 74 */ 75 NodePath getTargetPath() const 76 { 77 checkClassBinding!(typeof(this))(); 78 return ptrcall!(NodePath)(_classBinding.getTargetPath, _godot_object); 79 } 80 /** 81 Sets the node to move toward and orient with. 82 */ 83 void setTarget(GodotObject target) 84 { 85 checkClassBinding!(typeof(this))(); 86 ptrcall!(void)(_classBinding.setTarget, _godot_object, target); 87 } 88 /** 89 90 */ 91 void setSpeed(in double speed) 92 { 93 checkClassBinding!(typeof(this))(); 94 ptrcall!(void)(_classBinding.setSpeed, _godot_object, speed); 95 } 96 /** 97 98 */ 99 double getSpeed() const 100 { 101 checkClassBinding!(typeof(this))(); 102 return ptrcall!(double)(_classBinding.getSpeed, _godot_object); 103 } 104 /** 105 106 */ 107 void setInterpolationEnabled(in bool target_path) 108 { 109 checkClassBinding!(typeof(this))(); 110 ptrcall!(void)(_classBinding.setInterpolationEnabled, _godot_object, target_path); 111 } 112 /** 113 114 */ 115 bool isInterpolationEnabled() const 116 { 117 checkClassBinding!(typeof(this))(); 118 return ptrcall!(bool)(_classBinding.isInterpolationEnabled, _godot_object); 119 } 120 /** 121 The target's $(D NodePath). 122 */ 123 @property NodePath target() 124 { 125 return getTargetPath(); 126 } 127 /// ditto 128 @property void target(NodePath v) 129 { 130 setTargetPath(v); 131 } 132 /** 133 How quickly the camera moves toward its target. Higher values will result in tighter camera motion. 134 */ 135 @property double speed() 136 { 137 return getSpeed(); 138 } 139 /// ditto 140 @property void speed(double v) 141 { 142 setSpeed(v); 143 } 144 /** 145 If `true` and a target is set, the camera will move automatically. 146 */ 147 @property bool enabled() 148 { 149 return isInterpolationEnabled(); 150 } 151 /// ditto 152 @property void enabled(bool v) 153 { 154 setInterpolationEnabled(v); 155 } 156 }