1 /**
2 Node that represents collision shape data in 2D space.
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.collisionshape2d;
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.node2d;
24 import godot.shape2d;
25 import godot.canvasitem;
26 import godot.node;
27 /**
28 Node that represents collision shape data in 2D space.
29 
30 Editor facility for creating and editing collision shapes in 2D space. You can use this node to represent all sorts of collision shapes, for example, add this to an $(D Area2D) to give it a detection shape, or add it to a $(D PhysicsBody2D) to create a solid object. $(B IMPORTANT): this is an Editor-only helper to create shapes, use $(D CollisionObject2D.shapeOwnerGetShape) to get the actual shape.
31 */
32 @GodotBaseClass struct CollisionShape2D
33 {
34 	enum string _GODOT_internal_name = "CollisionShape2D";
35 public:
36 @nogc nothrow:
37 	union { godot_object _godot_object; Node2D _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_shape") GodotMethod!(void, Shape2D) setShape;
45 		@GodotName("get_shape") GodotMethod!(Shape2D) getShape;
46 		@GodotName("set_disabled") GodotMethod!(void, bool) setDisabled;
47 		@GodotName("is_disabled") GodotMethod!(bool) isDisabled;
48 		@GodotName("set_one_way_collision") GodotMethod!(void, bool) setOneWayCollision;
49 		@GodotName("is_one_way_collision_enabled") GodotMethod!(bool) isOneWayCollisionEnabled;
50 		@GodotName("_shape_changed") GodotMethod!(void) _shapeChanged;
51 	}
52 	bool opEquals(in CollisionShape2D other) const { return _godot_object.ptr is other._godot_object.ptr; }
53 	CollisionShape2D 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 CollisionShape2D _new()
57 	{
58 		static godot_class_constructor constructor;
59 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("CollisionShape2D");
60 		if(constructor is null) return typeof(this).init;
61 		return cast(CollisionShape2D)(constructor());
62 	}
63 	@disable new(size_t s);
64 	/**
65 	
66 	*/
67 	void setShape(Shape2D shape)
68 	{
69 		checkClassBinding!(typeof(this))();
70 		ptrcall!(void)(_classBinding.setShape, _godot_object, shape);
71 	}
72 	/**
73 	
74 	*/
75 	Ref!Shape2D getShape() const
76 	{
77 		checkClassBinding!(typeof(this))();
78 		return ptrcall!(Shape2D)(_classBinding.getShape, _godot_object);
79 	}
80 	/**
81 	
82 	*/
83 	void setDisabled(in bool disabled)
84 	{
85 		checkClassBinding!(typeof(this))();
86 		ptrcall!(void)(_classBinding.setDisabled, _godot_object, disabled);
87 	}
88 	/**
89 	
90 	*/
91 	bool isDisabled() const
92 	{
93 		checkClassBinding!(typeof(this))();
94 		return ptrcall!(bool)(_classBinding.isDisabled, _godot_object);
95 	}
96 	/**
97 	
98 	*/
99 	void setOneWayCollision(in bool enabled)
100 	{
101 		checkClassBinding!(typeof(this))();
102 		ptrcall!(void)(_classBinding.setOneWayCollision, _godot_object, enabled);
103 	}
104 	/**
105 	
106 	*/
107 	bool isOneWayCollisionEnabled() const
108 	{
109 		checkClassBinding!(typeof(this))();
110 		return ptrcall!(bool)(_classBinding.isOneWayCollisionEnabled, _godot_object);
111 	}
112 	/**
113 	
114 	*/
115 	void _shapeChanged()
116 	{
117 		Array _GODOT_args = Array.empty_array;
118 		String _GODOT_method_name = String("_shape_changed");
119 		this.callv(_GODOT_method_name, _GODOT_args);
120 	}
121 	/**
122 	The actual shape owned by this collision shape.
123 	*/
124 	@property Shape2D shape()
125 	{
126 		return getShape();
127 	}
128 	/// ditto
129 	@property void shape(Shape2D v)
130 	{
131 		setShape(v);
132 	}
133 	/**
134 	A disabled collision shape has no effect in the world.
135 	*/
136 	@property bool disabled()
137 	{
138 		return isDisabled();
139 	}
140 	/// ditto
141 	@property void disabled(bool v)
142 	{
143 		setDisabled(v);
144 	}
145 	/**
146 	Sets whether this collision shape should only detect collision on one side (top or bottom).
147 	*/
148 	@property bool oneWayCollision()
149 	{
150 		return isOneWayCollisionEnabled();
151 	}
152 	/// ditto
153 	@property void oneWayCollision(bool v)
154 	{
155 		setOneWayCollision(v);
156 	}
157 }