Engine
Frameworkcreatedbymeusableforthecreationofsimplegames.CurrentlysupportsOpenGL(Verysimple)andVulkan.
Public Member Functions | Friends | List of all members
Engine::CollisionComponent Class Reference

The Collision component is an entities link to the Collision System and allows for interaction with the other collision components. IMPORTANT: The Collision Component requires a Transform Component to be attached to the same entitiy. More...

#include <CollisionComponent.hpp>

Inheritance diagram for Engine::CollisionComponent:
Engine::Component

Public Member Functions

void SetBodyType (b2BodyType bodyType)
 Sets the Body Type (Static, Dynamic, Kinematic) for the collision body. More...
 
b2BodyType GetBodyType () const
 Gets the Body Type (Static, Dynamic, Kinematic) of the collision body. More...
 
void SetCircle (const float radius)
 Sets the Shape of the component to Circle More...
 
float GetCircleRadius () const
 Get the Radius of the circle shape (still returns even if it isn't a circle shape) More...
 
void SetAABB (const float sizeX, const float sizeY)
 Sets the Shape of the component to AABB More...
 
void SetAABB (const glm::vec2 &size)
 Sets the Shape of the component to AABB More...
 
glm::vec2 GetAABBSize () const
 Gets the size of AABB. (Still returns the size even if the shape isn't AABB) More...
 
CollisionShapeType GetCollisionShapeType () const
 Gets the collision shape type of the collision component More...
 
void SetCollisionLayer (CollisionLayer layer)
 Sets the collision layer The collision layer is the "type" of the collision body,other collision bodies looking for this "type" will generate a collision response if they are detectable by this collision body More...
 
CollisionLayer GetCollisionLayer () const
 Gets the collision layer More...
 
void SetDetectionLayers (CollisionLayer layers)
 Sets the detection layers The detection layers are what this collision object will be looking for to collide/interact with. More...
 
CollisionLayer GetDetectionLayers () const
 Gets the detection layers More...
 
void SetIsSensor (bool isSensor)
 Sets if the collision object will be a sensor or not. NOTE: A sensor is an object that does do collision callbacks but does not do collision correction/response on world update. NOTE: Use this if you want something to act as a trigger. More...
 
bool GetIsSensor () const
 Returns true if the collision object is a sensor More...
 
template<typename archive >
void SaveComponent (archive ar)
 
template<typename archive >
void LoadComponent (archive ar)
 loads the data from the archive to this component More...
 
- Public Member Functions inherited from Engine::Component
virtual ~Component ()=default
 
eastl::weak_ptr< EntityGetOwner () const
 This method allows you to get the entity holding this component. More...
 

Friends

class CollisionSystem
 

Additional Inherited Members

- Public Attributes inherited from Engine::Component
bool isEnabled
 
- Protected Member Functions inherited from Engine::Component
 Component ()
 
virtual void Update ()
 The update method of this component. NOTE: This method will not be called in case the entity is disabled. More...
 
template<typename ComponentType >
eastl::weak_ptr< ComponentType > GetComponent ()
 This method allows you to get the first component of the given type. More...
 
template<typename ComponentType >
eastl::vector< eastl::weak_ptr< ComponentType > > GetComponents ()
 This method allows you to get all of the components of the given type. More...
 
eastl::vector< eastl::shared_ptr< Component > > GetAllComponents () const
 Returns all the components of this entity. More...
 
template<class ComponentType , class... Args>
eastl::weak_ptr< ComponentType > AddComponent (Args &&...args)
 Allows you to create a component of the given type. More...
 
template<class ComponentType , class... Args>
eastl::vector< eastl::weak_ptr< ComponentType > > AddComponents (size_t count, Args &&...args)
 Allows you to create X amount of components of the given type. More...
 
template<typename ComponentType >
void RemoveComponent (size_t amountToRemove=1) const
 Allows X amount of components of the given type. More...
 
template<typename ComponentType >
void RemoveAllComponents () const
 Deletes all the components of the given type. More...
 
template<typename archive >
void SaveBaseComponent (archive ar)
 Saves the data of this component to a archive (all derived classes have their own version, but if needed they can call this one as a failsafe/default version) More...
 
template<typename archive >
void LoadBaseComponent (archive ar)
 loads the data from the archive to this component (all derived classes have their own version, but if needed they can call this one as a failsafe/default version) More...
 
virtual void OnBeginContact (eastl::weak_ptr< Entity > entity)
 
virtual void OnEndContact (eastl::weak_ptr< Entity > entity)
 
eastl::weak_ptr< ComponentGetPointerRefence () const
 This method allows you to get a direct refence to the weak pointer of this component. More...
 
template<typename ComponentType >
eastl::weak_ptr< ComponentType > GetPointerRefence ()
 This method allows you to get a direct refence to the weak pointer of this component. More...
 

Detailed Description

The Collision component is an entities link to the Collision System and allows for interaction with the other collision components. IMPORTANT: The Collision Component requires a Transform Component to be attached to the same entitiy.

Definition at line 17 of file CollisionComponent.hpp.

Member Function Documentation

glm::vec2 Engine::CollisionComponent::GetAABBSize ( ) const

Gets the size of AABB. (Still returns the size even if the shape isn't AABB)

Returns
glm::vec2 representing the size of the AABB

Definition at line 120 of file CollisionComponent.cpp.

b2BodyType Engine::CollisionComponent::GetBodyType ( ) const

Gets the Body Type (Static, Dynamic, Kinematic) of the collision body.

Returns
b2BodyType representing the body type

Definition at line 91 of file CollisionComponent.cpp.

float Engine::CollisionComponent::GetCircleRadius ( ) const

Get the Radius of the circle shape (still returns even if it isn't a circle shape)

Returns
float that represenets the radius of the circle shape

Definition at line 102 of file CollisionComponent.cpp.

CollisionLayer Engine::CollisionComponent::GetCollisionLayer ( ) const

Gets the collision layer

Returns
CollisionLayer representing the collision layer

Definition at line 135 of file CollisionComponent.cpp.

CollisionShapeType Engine::CollisionComponent::GetCollisionShapeType ( ) const

Gets the collision shape type of the collision component

Returns

Definition at line 125 of file CollisionComponent.cpp.

CollisionLayer Engine::CollisionComponent::GetDetectionLayers ( ) const

Gets the detection layers

Returns
CollisionLayer representing the detection layers

Definition at line 145 of file CollisionComponent.cpp.

bool Engine::CollisionComponent::GetIsSensor ( ) const

Returns true if the collision object is a sensor

Returns
A bool representing whether the collision object is a sensor or not

Definition at line 155 of file CollisionComponent.cpp.

template<typename archive >
void Engine::CollisionComponent::LoadComponent ( archive  ar)

loads the data from the archive to this component

Parameters
arthe archive that you want to load from

Definition at line 174 of file CollisionComponent.cpp.

template<typename archive >
void Engine::CollisionComponent::SaveComponent ( archive  ar)

Saves the data of this component to a archive

Parameters
arthe archive that you want to save to

Definition at line 160 of file CollisionComponent.cpp.

void Engine::CollisionComponent::SetAABB ( const float  sizeX,
const float  sizeY 
)

Sets the Shape of the component to AABB

Parameters
sizeXThe size of the AABB along the x axis
sizeYThe size of the AABB along the y axis

Definition at line 107 of file CollisionComponent.cpp.

void Engine::CollisionComponent::SetAABB ( const glm::vec2 &  size)

Sets the Shape of the component to AABB

Parameters
sizeThe size of the AABB

Definition at line 115 of file CollisionComponent.cpp.

void Engine::CollisionComponent::SetBodyType ( b2BodyType  bodyType)

Sets the Body Type (Static, Dynamic, Kinematic) for the collision body.

Parameters
bodyTypeThe body type the component will assume

Definition at line 86 of file CollisionComponent.cpp.

void Engine::CollisionComponent::SetCircle ( const float  radius)

Sets the Shape of the component to Circle

Parameters
radiusThe Radius for the circle shape

Definition at line 96 of file CollisionComponent.cpp.

void Engine::CollisionComponent::SetCollisionLayer ( CollisionLayer  layer)

Sets the collision layer The collision layer is the "type" of the collision body,other collision bodies looking for this "type" will generate a collision response if they are detectable by this collision body

Parameters
layerThe new layer

Definition at line 130 of file CollisionComponent.cpp.

void Engine::CollisionComponent::SetDetectionLayers ( CollisionLayer  layers)

Sets the detection layers The detection layers are what this collision object will be looking for to collide/interact with.

Parameters
layersThe new detection layers

Definition at line 140 of file CollisionComponent.cpp.

void Engine::CollisionComponent::SetIsSensor ( bool  isSensor)

Sets if the collision object will be a sensor or not. NOTE: A sensor is an object that does do collision callbacks but does not do collision correction/response on world update. NOTE: Use this if you want something to act as a trigger.

Parameters
isSensorThe new value determining if the collision object will be a sensor.

Definition at line 150 of file CollisionComponent.cpp.

Friends And Related Function Documentation

friend class CollisionSystem
friend

Definition at line 21 of file CollisionComponent.hpp.


The documentation for this class was generated from the following files: