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.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.resource; 24 import godot.environment; 25 import godot.physicsdirectspacestate; 26 import godot.reference; 27 /** 28 Class that has everything pertaining to a world. 29 30 A physics space, a visual scenario and a sound space. Spatial nodes register their resources into the current world. 31 */ 32 @GodotBaseClass struct World 33 { 34 enum string _GODOT_internal_name = "World"; 35 public: 36 @nogc nothrow: 37 union { godot_object _godot_object; Resource _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("get_space") GodotMethod!(RID) getSpace; 45 @GodotName("get_scenario") GodotMethod!(RID) getScenario; 46 @GodotName("set_environment") GodotMethod!(void, Environment) setEnvironment; 47 @GodotName("get_environment") GodotMethod!(Environment) getEnvironment; 48 @GodotName("set_fallback_environment") GodotMethod!(void, Environment) setFallbackEnvironment; 49 @GodotName("get_fallback_environment") GodotMethod!(Environment) getFallbackEnvironment; 50 @GodotName("get_direct_space_state") GodotMethod!(PhysicsDirectSpaceState) getDirectSpaceState; 51 } 52 bool opEquals(in World other) const { return _godot_object.ptr is other._godot_object.ptr; } 53 World 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 World _new() 57 { 58 static godot_class_constructor constructor; 59 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("World"); 60 if(constructor is null) return typeof(this).init; 61 return cast(World)(constructor()); 62 } 63 @disable new(size_t s); 64 /** 65 66 */ 67 RID getSpace() const 68 { 69 checkClassBinding!(typeof(this))(); 70 return ptrcall!(RID)(_classBinding.getSpace, _godot_object); 71 } 72 /** 73 74 */ 75 RID getScenario() const 76 { 77 checkClassBinding!(typeof(this))(); 78 return ptrcall!(RID)(_classBinding.getScenario, _godot_object); 79 } 80 /** 81 82 */ 83 void setEnvironment(Environment env) 84 { 85 checkClassBinding!(typeof(this))(); 86 ptrcall!(void)(_classBinding.setEnvironment, _godot_object, env); 87 } 88 /** 89 90 */ 91 Ref!Environment getEnvironment() const 92 { 93 checkClassBinding!(typeof(this))(); 94 return ptrcall!(Environment)(_classBinding.getEnvironment, _godot_object); 95 } 96 /** 97 98 */ 99 void setFallbackEnvironment(Environment env) 100 { 101 checkClassBinding!(typeof(this))(); 102 ptrcall!(void)(_classBinding.setFallbackEnvironment, _godot_object, env); 103 } 104 /** 105 106 */ 107 Ref!Environment getFallbackEnvironment() const 108 { 109 checkClassBinding!(typeof(this))(); 110 return ptrcall!(Environment)(_classBinding.getFallbackEnvironment, _godot_object); 111 } 112 /** 113 114 */ 115 PhysicsDirectSpaceState getDirectSpaceState() 116 { 117 checkClassBinding!(typeof(this))(); 118 return ptrcall!(PhysicsDirectSpaceState)(_classBinding.getDirectSpaceState, _godot_object); 119 } 120 /** 121 The World's $(D Environment). 122 */ 123 @property Environment environment() 124 { 125 return getEnvironment(); 126 } 127 /// ditto 128 @property void environment(Environment v) 129 { 130 setEnvironment(v); 131 } 132 /** 133 The World's fallback_environment will be used if the World's $(D Environment) fails or is missing. 134 */ 135 @property Environment fallbackEnvironment() 136 { 137 return getFallbackEnvironment(); 138 } 139 /// ditto 140 @property void fallbackEnvironment(Environment v) 141 { 142 setFallbackEnvironment(v); 143 } 144 /** 145 The World's physics space. 146 */ 147 @property RID space() 148 { 149 return getSpace(); 150 } 151 /** 152 The World's visual scenario. 153 */ 154 @property RID scenario() 155 { 156 return getScenario(); 157 } 158 /** 159 The World's physics direct space state, used for making various queries. Might be used only during `_physics_process`. 160 */ 161 @property PhysicsDirectSpaceState directSpaceState() 162 { 163 return getDirectSpaceState(); 164 } 165 }