1 /** 2 Class that has everything pertaining to a world. 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.world; 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 import godot.reference; 26 import godot.physicsdirectspacestate; 27 import godot.environment; 28 /** 29 Class that has everything pertaining to a world. 30 31 A physics space, a visual scenario and a sound space. Spatial nodes register their resources into the current world. 32 */ 33 @GodotBaseClass struct World 34 { 35 package(godot) enum string _GODOT_internal_name = "World"; 36 public: 37 @nogc nothrow: 38 union { /** */ godot_object _godot_object; /** */ Resource _GODOT_base; } 39 alias _GODOT_base this; 40 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 41 package(godot) __gshared bool _classBindingInitialized = false; 42 package(godot) static struct GDNativeClassBinding 43 { 44 __gshared: 45 @GodotName("get_direct_space_state") GodotMethod!(PhysicsDirectSpaceState) getDirectSpaceState; 46 @GodotName("get_environment") GodotMethod!(Environment) getEnvironment; 47 @GodotName("get_fallback_environment") GodotMethod!(Environment) getFallbackEnvironment; 48 @GodotName("get_scenario") GodotMethod!(RID) getScenario; 49 @GodotName("get_space") GodotMethod!(RID) getSpace; 50 @GodotName("set_environment") GodotMethod!(void, Environment) setEnvironment; 51 @GodotName("set_fallback_environment") GodotMethod!(void, Environment) setFallbackEnvironment; 52 } 53 /// 54 pragma(inline, true) bool opEquals(in World 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 World. 66 /// Note: use `memnew!World` instead. 67 static World _new() 68 { 69 static godot_class_constructor constructor; 70 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("World"); 71 if(constructor is null) return typeof(this).init; 72 return cast(World)(constructor()); 73 } 74 @disable new(size_t s); 75 /** 76 77 */ 78 PhysicsDirectSpaceState getDirectSpaceState() 79 { 80 checkClassBinding!(typeof(this))(); 81 return ptrcall!(PhysicsDirectSpaceState)(GDNativeClassBinding.getDirectSpaceState, _godot_object); 82 } 83 /** 84 85 */ 86 Ref!Environment getEnvironment() const 87 { 88 checkClassBinding!(typeof(this))(); 89 return ptrcall!(Environment)(GDNativeClassBinding.getEnvironment, _godot_object); 90 } 91 /** 92 93 */ 94 Ref!Environment getFallbackEnvironment() const 95 { 96 checkClassBinding!(typeof(this))(); 97 return ptrcall!(Environment)(GDNativeClassBinding.getFallbackEnvironment, _godot_object); 98 } 99 /** 100 101 */ 102 RID getScenario() const 103 { 104 checkClassBinding!(typeof(this))(); 105 return ptrcall!(RID)(GDNativeClassBinding.getScenario, _godot_object); 106 } 107 /** 108 109 */ 110 RID getSpace() const 111 { 112 checkClassBinding!(typeof(this))(); 113 return ptrcall!(RID)(GDNativeClassBinding.getSpace, _godot_object); 114 } 115 /** 116 117 */ 118 void setEnvironment(Environment env) 119 { 120 checkClassBinding!(typeof(this))(); 121 ptrcall!(void)(GDNativeClassBinding.setEnvironment, _godot_object, env); 122 } 123 /** 124 125 */ 126 void setFallbackEnvironment(Environment env) 127 { 128 checkClassBinding!(typeof(this))(); 129 ptrcall!(void)(GDNativeClassBinding.setFallbackEnvironment, _godot_object, env); 130 } 131 /** 132 Direct access to the world's physics 3D space state. Used for querying current and potential collisions. 133 */ 134 @property PhysicsDirectSpaceState directSpaceState() 135 { 136 return getDirectSpaceState(); 137 } 138 /** 139 The World's $(D Environment). 140 */ 141 @property Environment environment() 142 { 143 return getEnvironment(); 144 } 145 /// ditto 146 @property void environment(Environment v) 147 { 148 setEnvironment(v); 149 } 150 /** 151 The World's fallback_environment will be used if the World's $(D Environment) fails or is missing. 152 */ 153 @property Environment fallbackEnvironment() 154 { 155 return getFallbackEnvironment(); 156 } 157 /// ditto 158 @property void fallbackEnvironment(Environment v) 159 { 160 setFallbackEnvironment(v); 161 } 162 /** 163 The World's visual scenario. 164 */ 165 @property RID scenario() 166 { 167 return getScenario(); 168 } 169 /** 170 The World's physics space. 171 */ 172 @property RID space() 173 { 174 return getSpace(); 175 } 176 }