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

This object keeps track of all available entities. NOTE: only the Engine class is allowed to create this object. More...

#include <EntitySystem.hpp>

Public Member Functions

void RemoveAllEntities ()
 This method allows you to clear the entire entity system and all the teams. More...
 
eastl::weak_ptr< EntityCreateEntity (eastl::string entityName="", int teamId=0)
 Allows you to create a new Entity. This method will also add the entity to the given team if that team id exists. If the given team id does not exist, or it's kept on 0, it'll add the entity to the last created team. If there are no excisting teams, it'll create a new team and add the entity to it. Use teamId -1 to not add a an entity to a team at all. NOTE: Using a teamId lower than -1 will revert the teamId to -1. More...
 
template<typename EntityType >
eastl::weak_ptr< EntityType > CreateEntity (eastl::string entityName="")
 Allows you to create a new Entity. This method will also add the entity to the given team if that team id exists. If the given team id does not exist, or it's kept on 0, it'll add the entity to the last created team. If there are no excisting teams, it'll create a new team and add the entity to it. Use teamId -1 to not add a an entity to a team at all. NOTE: Using a teamId lower than -1 will revert the teamId to -1. More...
 
template<class EntityType , class... Args>
eastl::weak_ptr< EntityType > CreateEntity (eastl::string entityName="", Args &&...args)
 Allows you to create a new Entity. This method will also add the entity to the given team if that team id exists. If the given team id does not exist, or it's kept on 0, it'll add the entity to the last created team. If there are no excisting teams, it'll create a new team and add the entity to it. Use teamId -1 to not add a an entity to a team at all. NOTE: Using a teamId lower than -1 will revert the teamId to -1. More...
 
eastl::weak_ptr< EntityGetEntity (uint64_t Id)
 Allows you to get the entity you want based on the id number. NOTE: if you know the team id of the entity, it's often faster to call the method with the team id defined. More...
 
eastl::vector< eastl::shared_ptr< Entity > > GetAllEntities () const
 This method will allow you to get all entities availible. More...
 
template<typename ComponentType >
eastl::vector< eastl::weak_ptr< ComponentType > > GetAllComponents ()
 This method allows you to get a vector of weak pointers with the component type you are looking for. More...
 
template<typename ComponentType >
eastl::vector< eastl::weak_ptr< Entity > > GetAllEntitiesWithComponent ()
 This method allows you to get a vector of weak pointer with entities that have the defined component attached to them. More...
 
void AddEntity (eastl::shared_ptr< Entity > entityToAdd)
 This method allows you to add a precreated entity to the entity system

Parameters
entityToAddThe entity you want to add to the entity system.
More...
 
void RemoveEntity (eastl::shared_ptr< Entity > entityToRemove)
 This method allows you to remove a specific entity from the entity system

Parameters
entityToRemoveThe entity you want to remove from the entity system.
More...
 
 ~EntitySystem ()
 

Friends

class Engine
 

Detailed Description

This object keeps track of all available entities. NOTE: only the Engine class is allowed to create this object.

Definition at line 13 of file EntitySystem.hpp.

Constructor & Destructor Documentation

Engine::EntitySystem::~EntitySystem ( )

Definition at line 8 of file EntitySystem.cpp.

Member Function Documentation

void Engine::EntitySystem::AddEntity ( eastl::shared_ptr< Entity entityToAdd)

This method allows you to add a precreated entity to the entity system

Parameters
entityToAddThe entity you want to add to the entity system.

Definition at line 47 of file EntitySystem.cpp.

eastl::weak_ptr< Entity > Engine::EntitySystem::CreateEntity ( eastl::string  entityName = "",
int  teamId = 0 
)

Allows you to create a new Entity. This method will also add the entity to the given team if that team id exists. If the given team id does not exist, or it's kept on 0, it'll add the entity to the last created team. If there are no excisting teams, it'll create a new team and add the entity to it. Use teamId -1 to not add a an entity to a team at all. NOTE: Using a teamId lower than -1 will revert the teamId to -1.

Parameters
entityNameThe name of the entity you want to create, this is empty by default.
teamIdThe team id you want to add the entity to. Default is 0
Returns
Returns the newly created entity as a weak pointer.

Definition at line 19 of file EntitySystem.cpp.

template<typename EntityType >
eastl::weak_ptr< EntityType > Engine::EntitySystem::CreateEntity ( eastl::string  entityName = "")

Allows you to create a new Entity. This method will also add the entity to the given team if that team id exists. If the given team id does not exist, or it's kept on 0, it'll add the entity to the last created team. If there are no excisting teams, it'll create a new team and add the entity to it. Use teamId -1 to not add a an entity to a team at all. NOTE: Using a teamId lower than -1 will revert the teamId to -1.

Parameters
entityNameThe name of the entity you want to create, this is empty by default.
Returns
Returns the newly created entity as a weak pointer.

Definition at line 112 of file EntitySystem.hpp.

template<class EntityType , class... Args>
eastl::weak_ptr< EntityType > Engine::EntitySystem::CreateEntity ( eastl::string  entityName = "",
Args &&...  args 
)

Allows you to create a new Entity. This method will also add the entity to the given team if that team id exists. If the given team id does not exist, or it's kept on 0, it'll add the entity to the last created team. If there are no excisting teams, it'll create a new team and add the entity to it. Use teamId -1 to not add a an entity to a team at all. NOTE: Using a teamId lower than -1 will revert the teamId to -1.

Parameters
entityNameThe name of the entity you want to create, this is empty by default.
...argsAny given argument you require for your entity.
Returns
Returns the newly created entity as a weak pointer.

Definition at line 122 of file EntitySystem.hpp.

template<typename ComponentType >
eastl::vector< eastl::weak_ptr< ComponentType > > Engine::EntitySystem::GetAllComponents ( )

This method allows you to get a vector of weak pointers with the component type you are looking for.

Returns
Returns a vector of weak pointers if any available entities have the components you are looking for. Otherwise returns an empty vector.

Definition at line 133 of file EntitySystem.hpp.

eastl::vector< eastl::shared_ptr< Entity > > Engine::EntitySystem::GetAllEntities ( ) const

This method will allow you to get all entities availible.

Returns
Returns a vector of all the entities availible.

Definition at line 71 of file EntitySystem.cpp.

template<typename ComponentType >
eastl::vector< eastl::weak_ptr< Entity > > Engine::EntitySystem::GetAllEntitiesWithComponent ( )

This method allows you to get a vector of weak pointer with entities that have the defined component attached to them.

Returns
Returns a vector of weak pointers if any available entities have the component you are looking for. Otherwise returns an empty vector.

Definition at line 149 of file EntitySystem.hpp.

eastl::weak_ptr< Entity > Engine::EntitySystem::GetEntity ( uint64_t  Id)

Allows you to get the entity you want based on the id number. NOTE: if you know the team id of the entity, it's often faster to call the method with the team id defined.

Parameters
IdThe entity you want to get.
Returns
Will return the entity with the given id if found. Otherwise will return an empty weak pointer.

Definition at line 27 of file EntitySystem.cpp.

void Engine::EntitySystem::RemoveAllEntities ( )

This method allows you to clear the entire entity system and all the teams.

Definition at line 13 of file EntitySystem.cpp.

void Engine::EntitySystem::RemoveEntity ( eastl::shared_ptr< Entity entityToRemove)

This method allows you to remove a specific entity from the entity system

Parameters
entityToRemoveThe entity you want to remove from the entity system.

Definition at line 56 of file EntitySystem.cpp.

Friends And Related Function Documentation

friend class Engine
friend

Definition at line 101 of file EntitySystem.hpp.


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