UGDK
0.5.0
|
A class that knows how to manage collisions. More...
#include <pyramidworks/collision/collisionobject.h>
Public Member Functions | |
CollisionObject (CollisionData *data, const std::string &colclass, std::unique_ptr< geometry::GeometricShape > &&shape) | |
~CollisionObject () | |
void | SearchCollisions (std::list< CollisionInstance > &collision_list) const |
Search if there's any collision. More... | |
bool | IsColliding (const CollisionObject *obj) const |
Verifies if this CollisionObject is colliding with another CollisionObject. More... | |
void | AddCollisionLogic (const std::string &colclass, const CollisionLogic &logic) |
Adds a new collision to the known collisions. More... | |
void | RemoveCollisionLogic (const std::string &colclass) |
Removes a collision from the known collisions. More... | |
void | ChangeCollisionClass (const std::string &) |
Changes the collision class associated with this object. More... | |
void | StartColliding (CollisionManager *) |
Enables collisions with this object in the given CollisionManager. More... | |
void | StopColliding () |
Removes this object from it's CollisionClass object list. More... | |
void | MoveTo (const ugdk::math::Vector2D &position) |
Moves the object to the given position. More... | |
ugdk::structure::Box< 2 > | CreateBoundingBox () const |
Wrapper to shape()->CreateBoundingBox(absolute_position()) More... | |
ugdk::math::Vector2D | absolute_position () const |
Calculates the position of this object, with the offset added. More... | |
void | ChangeShape (std::unique_ptr< geometry::GeometricShape > &&shape) |
Changes the shape used. More... | |
const std::string & | collision_class () const |
Returns the name of the collision class of this object. More... | |
CollisionData * | data () const |
Returns the CollisionData associated with this object. More... | |
const ugdk::math::Vector2D & | position () const |
Returns the position of this object. More... | |
const ugdk::math::Vector2D & | offset () const |
Returns the offset of this object. More... | |
const geometry::GeometricShape * | shape () const |
Returns the shape used. More... | |
void | set_offset (const ugdk::math::Vector2D &_offset) |
Changes the offset of this object. More... | |
void | set_data (CollisionData *data) |
Changes the data of this object. More... | |
A class that knows how to manage collisions.
It encapsulates everything that is related to collisions, from finding the collisions to calling the corresponding methods.
pyramidworks::collision::CollisionObject::CollisionObject | ( | CollisionData * | data, |
const std::string & | colclass, | ||
std::unique_ptr< geometry::GeometricShape > && | shape | ||
) |
data | The data sent to the CollisionLogic when a collision happens. |
colclass | Name of the collision class of this object. |
shape | The shape for this object. |
pyramidworks::collision::CollisionObject::~CollisionObject | ( | ) |
|
inline |
Calculates the position of this object, with the offset added.
void pyramidworks::collision::CollisionObject::AddCollisionLogic | ( | const std::string & | colclass, |
const CollisionLogic & | logic | ||
) |
Adds a new collision to the known collisions.
colclass | Name of the collision class. |
logic | The handler called when the collision occurs. |
void pyramidworks::collision::CollisionObject::ChangeCollisionClass | ( | const std::string & | ) |
Changes the collision class associated with this object.
colclass | The string representating the collision class to set to. |
void pyramidworks::collision::CollisionObject::ChangeShape | ( | std::unique_ptr< geometry::GeometricShape > && | shape | ) |
Changes the shape used.
shape | The shape to use. |
|
inline |
Returns the name of the collision class of this object.
ugdk::structure::Box<2> pyramidworks::collision::CollisionObject::CreateBoundingBox | ( | ) | const |
Wrapper to shape()->CreateBoundingBox(absolute_position())
|
inline |
Returns the CollisionData associated with this object.
bool pyramidworks::collision::CollisionObject::IsColliding | ( | const CollisionObject * | obj | ) | const |
Verifies if this CollisionObject is colliding with another CollisionObject.
obj | The CollisionObject to check against. |
void pyramidworks::collision::CollisionObject::MoveTo | ( | const ugdk::math::Vector2D & | position | ) |
Moves the object to the given position.
|
inline |
Returns the offset of this object.
|
inline |
Returns the position of this object.
void pyramidworks::collision::CollisionObject::RemoveCollisionLogic | ( | const std::string & | colclass | ) |
Removes a collision from the known collisions.
colclass | Name of the collision class. |
void pyramidworks::collision::CollisionObject::SearchCollisions | ( | std::list< CollisionInstance > & | collision_list | ) | const |
Search if there's any collision.
For each CollisionClass this object knows how to collide with, it gathers a list of CollisionObject it's colliding with and generates a list of the collisions.
collision_list | A list in which the result is appended to. |
|
inline |
Changes the data of this object.
|
inline |
Changes the offset of this object.
|
inline |
Returns the shape used.
void pyramidworks::collision::CollisionObject::StartColliding | ( | CollisionManager * | ) |
Enables collisions with this object in the given CollisionManager.
void pyramidworks::collision::CollisionObject::StopColliding | ( | ) |
Removes this object from it's CollisionClass object list.