1 /** 2 Overrides the location sounds are heard from. 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.listener; 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.spatial; 25 /** 26 Overrides the location sounds are heard from. 27 28 Once added to the scene tree and enabled using $(D makeCurrent), this node will override the location sounds are heard from. This can be used to listen from a location different from the $(D Camera). 29 $(B Note:) There is no 2D equivalent for this node yet. 30 */ 31 @GodotBaseClass struct Listener 32 { 33 package(godot) enum string _GODOT_internal_name = "Listener"; 34 public: 35 @nogc nothrow: 36 union { /** */ godot_object _godot_object; /** */ Spatial _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_current") GodotMethod!(void) clearCurrent; 44 @GodotName("get_listener_transform") GodotMethod!(Transform) getListenerTransform; 45 @GodotName("is_current") GodotMethod!(bool) isCurrent; 46 @GodotName("make_current") GodotMethod!(void) makeCurrent; 47 } 48 /// 49 pragma(inline, true) bool opEquals(in Listener other) const 50 { return _godot_object.ptr is other._godot_object.ptr; } 51 /// 52 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 53 { _godot_object.ptr = n; return null; } 54 /// 55 pragma(inline, true) bool opEquals(typeof(null) n) const 56 { return _godot_object.ptr is n; } 57 /// 58 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 59 mixin baseCasts; 60 /// Construct a new instance of Listener. 61 /// Note: use `memnew!Listener` instead. 62 static Listener _new() 63 { 64 static godot_class_constructor constructor; 65 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("Listener"); 66 if(constructor is null) return typeof(this).init; 67 return cast(Listener)(constructor()); 68 } 69 @disable new(size_t s); 70 /** 71 Disables the listener to use the current camera's listener instead. 72 */ 73 void clearCurrent() 74 { 75 checkClassBinding!(typeof(this))(); 76 ptrcall!(void)(GDNativeClassBinding.clearCurrent, _godot_object); 77 } 78 /** 79 Returns the listener's global orthonormalized $(D Transform). 80 */ 81 Transform getListenerTransform() const 82 { 83 checkClassBinding!(typeof(this))(); 84 return ptrcall!(Transform)(GDNativeClassBinding.getListenerTransform, _godot_object); 85 } 86 /** 87 Returns `true` if the listener was made current using $(D makeCurrent), `false` otherwise. 88 $(B Note:) There may be more than one Listener marked as "current" in the scene tree, but only the one that was made current last will be used. 89 */ 90 bool isCurrent() const 91 { 92 checkClassBinding!(typeof(this))(); 93 return ptrcall!(bool)(GDNativeClassBinding.isCurrent, _godot_object); 94 } 95 /** 96 Enables the listener. This will override the current camera's listener. 97 */ 98 void makeCurrent() 99 { 100 checkClassBinding!(typeof(this))(); 101 ptrcall!(void)(GDNativeClassBinding.makeCurrent, _godot_object); 102 } 103 }