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

This is the base class for components. NOTE: only the Entity class is allowed to create this object. More...

#include <Component.hpp>

Inheritance diagram for Engine::Component:
Engine::AnimationComponent Engine::CollisionComponent Engine::LightComponent Engine::ModelComponent Engine::TransformComponent

Public Member Functions

virtual ~Component ()=default
 
eastl::weak_ptr< EntityGetOwner () const
 This method allows you to get the entity holding this component. More...
 

Public Attributes

bool isEnabled
 

Protected Member Functions

 Component ()
 
virtual void InitializeComponent ()
 This method is used to initialize your component in. This method is called after the setting of the owner. More...
 
virtual void Update ()
 The update method of this component. NOTE: This method will not be called in case the entity is disabled. More...
 
virtual void OnComponentAdded (eastl::weak_ptr< Component > addedComponent)
 This method will be called whenever a component has been added to the entity. More...
 
virtual void OnComponentRemoved (eastl::weak_ptr< Component > removedComponent)
 This method will be called whenever a component has been removed from the entity. 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...
 

Friends

class Entity
 

Detailed Description

This is the base class for components. NOTE: only the Entity class is allowed to create this object.

Definition at line 16 of file Component.hpp.

Constructor & Destructor Documentation

virtual Engine::Component::~Component ( )
virtualdefault
Engine::Component::Component ( )
explicitprotected

Definition at line 14 of file Component.cpp.

Member Function Documentation

template<class ComponentType , class... Args>
eastl::weak_ptr< ComponentType > Engine::Component::AddComponent ( Args &&...  args)
protected

Allows you to create a component of the given type.

Parameters
...argsThe arguments required to initialize the component.
Returns
Returns the just created component of the given type as a weak pointer.

Definition at line 163 of file Component.hpp.

template<class ComponentType , class... Args>
eastl::vector< eastl::weak_ptr< ComponentType > > Engine::Component::AddComponents ( size_t  count,
Args &&...  args 
)
protected

Allows you to create X amount of components of the given type.

Parameters
countThe amount of components you want to add of this given type.
...argsThe arguments required to initialize the components.
Returns
Returns a vector of the just created components of the given type as a vector of weak pointers.

Definition at line 169 of file Component.hpp.

eastl::vector< eastl::shared_ptr< Component > > Engine::Component::GetAllComponents ( ) const
protected

Returns all the components of this entity.

Returns
Returns a vector of all the components of this entity.

Definition at line 34 of file Component.cpp.

template<typename ComponentType >
eastl::weak_ptr< ComponentType > Engine::Component::GetComponent ( )
protected

This method allows you to get the first component of the given type.

Returns
Returns the first component of the given type as a weak pointer.

Definition at line 151 of file Component.hpp.

template<typename ComponentType >
eastl::vector< eastl::weak_ptr< ComponentType > > Engine::Component::GetComponents ( )
protected

This method allows you to get all of the components of the given type.

Returns
Returns the all of the components of the given type as a weak pointer.

Definition at line 157 of file Component.hpp.

eastl::weak_ptr< Entity > Engine::Component::GetOwner ( ) const

This method allows you to get the entity holding this component.

Returns
Returns the owner of this component.

Definition at line 9 of file Component.cpp.

eastl::weak_ptr< Component > Engine::Component::GetPointerRefence ( ) const
protected

This method allows you to get a direct refence to the weak pointer of this component.

Returns
Returns the reference of this object as a weak pointer.

Definition at line 47 of file Component.cpp.

template<typename ComponentType >
eastl::weak_ptr< ComponentType > Engine::Component::GetPointerRefence ( )
protected

This method allows you to get a direct refence to the weak pointer of this component.

Returns
Returns the reference of this object as a weak pointer.

Definition at line 187 of file Component.hpp.

void Engine::Component::InitializeComponent ( )
protectedvirtual

This method is used to initialize your component in. This method is called after the setting of the owner.

Definition at line 18 of file Component.cpp.

template<typename archive >
void Engine::Component::LoadBaseComponent ( archive  ar)
protected

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)

Parameters
arthe archive that you want to load from

Definition at line 69 of file Component.cpp.

void Engine::Component::OnBeginContact ( eastl::weak_ptr< Entity entity)
protectedvirtual

Definition at line 39 of file Component.cpp.

void Engine::Component::OnComponentAdded ( eastl::weak_ptr< Component addedComponent)
protectedvirtual

This method will be called whenever a component has been added to the entity.

Parameters
addedComponentThe component that has been added.

Definition at line 26 of file Component.cpp.

void Engine::Component::OnComponentRemoved ( eastl::weak_ptr< Component removedComponent)
protectedvirtual

This method will be called whenever a component has been removed from the entity.

Parameters
removedComponentThe component that has been removed.

Definition at line 30 of file Component.cpp.

void Engine::Component::OnEndContact ( eastl::weak_ptr< Entity entity)
protectedvirtual

Definition at line 43 of file Component.cpp.

template<typename ComponentType >
void Engine::Component::RemoveAllComponents ( ) const
protected

Deletes all the components of the given type.

Definition at line 181 of file Component.hpp.

template<typename ComponentType >
void Engine::Component::RemoveComponent ( size_t  amountToRemove = 1) const
protected

Allows X amount of components of the given type.

Parameters
amountToRemoveWill remove 1 component by default, can be change optionally.

Definition at line 175 of file Component.hpp.

template<typename archive >
void Engine::Component::SaveBaseComponent ( archive  ar)
protected

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)

Parameters
arthe archive that you want to save to

Definition at line 63 of file Component.cpp.

void Engine::Component::Update ( )
protectedvirtual

The update method of this component. NOTE: This method will not be called in case the entity is disabled.

Reimplemented in Engine::TransformComponent.

Definition at line 22 of file Component.cpp.

Friends And Related Function Documentation

friend class Entity
friend

Definition at line 29 of file Component.hpp.

Member Data Documentation

bool Engine::Component::isEnabled

Definition at line 26 of file Component.hpp.


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