1 /**
2 Class that has everything pertaining to a 2D 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.world2d;
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.physics2ddirectspacestate;
25 import godot.reference;
26 /**
27 Class that has everything pertaining to a 2D world.
28 
29 A physics space, a visual scenario and a sound space. 2D nodes register their resources into the current 2D world.
30 */
31 @GodotBaseClass struct World2D
32 {
33 	enum string _GODOT_internal_name = "World2D";
34 public:
35 @nogc nothrow:
36 	union { godot_object _godot_object; Resource _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 _classBinding
41 	{
42 		__gshared:
43 		@GodotName("get_canvas") GodotMethod!(RID) getCanvas;
44 		@GodotName("get_space") GodotMethod!(RID) getSpace;
45 		@GodotName("get_direct_space_state") GodotMethod!(Physics2DDirectSpaceState) getDirectSpaceState;
46 	}
47 	bool opEquals(in World2D other) const { return _godot_object.ptr is other._godot_object.ptr; }
48 	World2D opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; }
49 	bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; }
50 	mixin baseCasts;
51 	static World2D _new()
52 	{
53 		static godot_class_constructor constructor;
54 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("World2D");
55 		if(constructor is null) return typeof(this).init;
56 		return cast(World2D)(constructor());
57 	}
58 	@disable new(size_t s);
59 	/**
60 	
61 	*/
62 	RID getCanvas()
63 	{
64 		checkClassBinding!(typeof(this))();
65 		return ptrcall!(RID)(_classBinding.getCanvas, _godot_object);
66 	}
67 	/**
68 	
69 	*/
70 	RID getSpace()
71 	{
72 		checkClassBinding!(typeof(this))();
73 		return ptrcall!(RID)(_classBinding.getSpace, _godot_object);
74 	}
75 	/**
76 	
77 	*/
78 	Physics2DDirectSpaceState getDirectSpaceState()
79 	{
80 		checkClassBinding!(typeof(this))();
81 		return ptrcall!(Physics2DDirectSpaceState)(_classBinding.getDirectSpaceState, _godot_object);
82 	}
83 	/**
84 	The $(D RID) of this world's canvas resource. Used by the $(D VisualServer) for 2D drawing.
85 	*/
86 	@property RID canvas()
87 	{
88 		return getCanvas();
89 	}
90 	/**
91 	The $(D RID) of this world's physics space resource. Used by the $(D Physics2DServer) for 2D physics, treating it as both a space and an area.
92 	*/
93 	@property RID space()
94 	{
95 		return getSpace();
96 	}
97 	/**
98 	The state of this world's physics space. This allows arbitrary querying for collision.
99 	*/
100 	@property Physics2DDirectSpaceState directSpaceState()
101 	{
102 		return getDirectSpaceState();
103 	}
104 }