forked from therocode/featherkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentitycontroller.hpp
More file actions
85 lines (81 loc) · 3.78 KB
/
entitycontroller.hpp
File metadata and controls
85 lines (81 loc) · 3.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#pragma once
#include <fea/config.hpp>
#include <unordered_map>
#include <fea/entity/entity.hpp>
namespace fea
{
class FEA_API EntityController
{
public:
void entityCreated(EntityPtr entity);
void entityRemoved(EntityId entityId);
virtual bool keepEntity(EntityPtr entity) const;
virtual void entityKept(EntityPtr entity);
virtual void entityDestroyed(EntityPtr entity);
virtual void update(float deltaTime);
const std::unordered_map<EntityId, EntityPtr>& getEntities() const;
virtual ~EntityController();
protected:
std::unordered_map<EntityId, EntityPtr> mEntities;
};
/** @addtogroup EntitySystem
*@{
* @class EntityController
*@}
***
* @class EntityController
* @brief Class to inherit to create entity components
*
* This class is the base for creating entity components. An entity component is simply a subsystem for processing an entity in a specific way. For example, you might want a PhysicsController dealing with physics, a PlayerControlController to implement player control behavior or a CameraFollowController which makes the camera follow a specific entity.
*
* Controllers are created by inheriting this class and then specializing their behavior.
*
* When entities are created and removed, all components must be notified using the EntityController::entityCreated and EntityController::entityRemoved functions.
***
* @fn void EntityController::entityCreated(EntityPtr entity)
* @brief Let the component know that an entity has been created.
*
* This will pass the entity to the EntityController::keepEntity function and if that one returns true, the entity will be stored in EntityController::mEntities.
* @param entity Created entity.
***
* @fn void EntityController::entityRemoved(EntityId entityId)
* @brief Let the component know that an entity has been removed.
*
* If the entity exists in the member variable EntityController::mEntities, then it will be removed from there.
***
* @fn virtual bool EntityController::keepEntity(EntityPtr entity) const
* @brief Decide if an entity should be kept or not.
*
* Override this function to specify which entities the component should keep track of. In the case that the entity should be kept, then it will be put in the EntityController::mEntities variable.
* @param entity Entity to investigate.
* @return True if the entity should be kept.
***
* @fn virtual void EntityController::entityKept(EntityPtr entity)
* @brief Handle a newly kept entity.
*
* Override this function to specify what the component should do with an entity that is kept.
* @param entity kept Entity.
***
* @fn virtual void EntityController::entityDestroyed(EntityPtr entity)
* @brief Handle an entity that is destroyed.
*
* Override this function to specify what the component should do with an entity that is destroyed.
* @param entity destroyed Entity.
***
* @fn virtual void EntityController::update(float deltaTime)
* @brief Let the controller know that time has passed.
*
* Override this function to define what this controller should do every frame.
* @param deltaTime amount of time passed.
***
* @fn const std::unordered_map<EntityId, EntityPtr>& EntityController::getEntities() const
* @brief Get the entities that this component is keeping track of.
* @return Map with entities.
***
* @fn virtual EntityController::~EntityController()
* @brief Destructor.
***
* @var EntityController::mEntities
* @brief Set containing all entities.
***/
}