1 /**
2 Base class for all 2D Shapes.
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.shape2d;
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.resource;
23 import godot.reference;
24 /**
25 Base class for all 2D Shapes.
26 
27 All 2D shape types inherit from this.
28 */
29 @GodotBaseClass struct Shape2D
30 {
31 	enum string _GODOT_internal_name = "Shape2D";
32 public:
33 @nogc nothrow:
34 	union { godot_object _godot_object; Resource _GODOT_base; }
35 	alias _GODOT_base this;
36 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
37 	package(godot) __gshared bool _classBindingInitialized = false;
38 	package(godot) static struct _classBinding
39 	{
40 		__gshared:
41 		@GodotName("set_custom_solver_bias") GodotMethod!(void, double) setCustomSolverBias;
42 		@GodotName("get_custom_solver_bias") GodotMethod!(double) getCustomSolverBias;
43 		@GodotName("collide") GodotMethod!(bool, Transform2D, Shape2D, Transform2D) collide;
44 		@GodotName("collide_with_motion") GodotMethod!(bool, Transform2D, Vector2, Shape2D, Transform2D, Vector2) collideWithMotion;
45 		@GodotName("collide_and_get_contacts") GodotMethod!(Variant, Transform2D, Shape2D, Transform2D) collideAndGetContacts;
46 		@GodotName("collide_with_motion_and_get_contacts") GodotMethod!(Variant, Transform2D, Vector2, Shape2D, Transform2D, Vector2) collideWithMotionAndGetContacts;
47 	}
48 	bool opEquals(in Shape2D other) const { return _godot_object.ptr is other._godot_object.ptr; }
49 	Shape2D opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; }
50 	bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; }
51 	mixin baseCasts;
52 	static Shape2D _new()
53 	{
54 		static godot_class_constructor constructor;
55 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("Shape2D");
56 		if(constructor is null) return typeof(this).init;
57 		return cast(Shape2D)(constructor());
58 	}
59 	@disable new(size_t s);
60 	/**
61 	
62 	*/
63 	void setCustomSolverBias(in double bias)
64 	{
65 		checkClassBinding!(typeof(this))();
66 		ptrcall!(void)(_classBinding.setCustomSolverBias, _godot_object, bias);
67 	}
68 	/**
69 	
70 	*/
71 	double getCustomSolverBias() const
72 	{
73 		checkClassBinding!(typeof(this))();
74 		return ptrcall!(double)(_classBinding.getCustomSolverBias, _godot_object);
75 	}
76 	/**
77 	Returns `true` if this shape is colliding with another.
78 	This method needs the transformation matrix for this shape (`local_xform`), the shape to check collisions with (`with_shape`), and the transformation matrix of that shape (`shape_xform`).
79 	*/
80 	bool collide(in Transform2D local_xform, Shape2D with_shape, in Transform2D shape_xform)
81 	{
82 		checkClassBinding!(typeof(this))();
83 		return ptrcall!(bool)(_classBinding.collide, _godot_object, local_xform, with_shape, shape_xform);
84 	}
85 	/**
86 	Return whether this shape would collide with another, if a given movement was applied.
87 	This method needs the transformation matrix for this shape (`local_xform`), the movement to test on this shape (`local_motion`), the shape to check collisions with (`with_shape`), the transformation matrix of that shape (`shape_xform`), and the movement to test onto the other object (`shape_motion`).
88 	*/
89 	bool collideWithMotion(in Transform2D local_xform, in Vector2 local_motion, Shape2D with_shape, in Transform2D shape_xform, in Vector2 shape_motion)
90 	{
91 		checkClassBinding!(typeof(this))();
92 		return ptrcall!(bool)(_classBinding.collideWithMotion, _godot_object, local_xform, local_motion, with_shape, shape_xform, shape_motion);
93 	}
94 	/**
95 	Returns a list of the points where this shape touches another. If there are no collisions the list is empty.
96 	This method needs the transformation matrix for this shape (`local_xform`), the shape to check collisions with (`with_shape`), and the transformation matrix of that shape (`shape_xform`).
97 	*/
98 	Variant collideAndGetContacts(in Transform2D local_xform, Shape2D with_shape, in Transform2D shape_xform)
99 	{
100 		checkClassBinding!(typeof(this))();
101 		return ptrcall!(Variant)(_classBinding.collideAndGetContacts, _godot_object, local_xform, with_shape, shape_xform);
102 	}
103 	/**
104 	Returns a list of the points where this shape would touch another, if a given movement was applied. If there are no collisions the list is empty.
105 	This method needs the transformation matrix for this shape (`local_xform`), the movement to test on this shape (`local_motion`), the shape to check collisions with (`with_shape`), the transformation matrix of that shape (`shape_xform`), and the movement to test onto the other object (`shape_motion`).
106 	*/
107 	Variant collideWithMotionAndGetContacts(in Transform2D local_xform, in Vector2 local_motion, Shape2D with_shape, in Transform2D shape_xform, in Vector2 shape_motion)
108 	{
109 		checkClassBinding!(typeof(this))();
110 		return ptrcall!(Variant)(_classBinding.collideWithMotionAndGetContacts, _godot_object, local_xform, local_motion, with_shape, shape_xform, shape_motion);
111 	}
112 	/**
113 	
114 	*/
115 	@property double customSolverBias()
116 	{
117 		return getCustomSolverBias();
118 	}
119 	/// ditto
120 	@property void customSolverBias(double v)
121 	{
122 		setCustomSolverBias(v);
123 	}
124 }