@@ -23,7 +23,7 @@ class Entity {
23
23
24
24
template <typename T, typename ... Args, typename std::enable_if<std::is_base_of<Component, T>::value>::type* = nullptr >
25
25
T* addComponent (Args... args) {
26
- auto ret = components .insert_or_assign (typeid (T), std::make_unique<T>(args...));
26
+ auto ret = _components .insert_or_assign (typeid (T), std::make_unique<T>(args...));
27
27
28
28
_world._activeComponents [typeid (T)].push_back (this );
29
29
@@ -33,17 +33,17 @@ class Entity {
33
33
template <typename T, typename std::enable_if<std::is_base_of<Component, T>::value>::type* = nullptr >
34
34
T* getComponent () {
35
35
T* component = nullptr ;
36
- auto it = components .find (typeid (T));
36
+ auto it = _components .find (typeid (T));
37
37
38
- if (it != components .end ())
38
+ if (it != _components .end ())
39
39
component = static_cast <T*>(it->second .get ());
40
40
41
41
return component;
42
42
}
43
43
44
44
template <typename T, typename std::enable_if<std::is_base_of<Component, T>::value>::type* = nullptr >
45
45
void removeComponent () {
46
- components .erase (typeid (T));
46
+ _components .erase (typeid (T));
47
47
auto & ents = _world._activeComponents [typeid (T)];
48
48
ents.erase (std::find (ents.begin (), ents.end (), this ));
49
49
}
@@ -54,13 +54,13 @@ class Entity {
54
54
inline std::string& getName () { return _name; }
55
55
inline void makeDead () { _dead = true ; }
56
56
inline bool isDead () { return _dead; }
57
- inline std::map<std::type_index, std::unique_ptr<Component>>& getComponents () { return components ; }
57
+ inline std::map<std::type_index, std::unique_ptr<Component>>& getComponents () { return _components ; }
58
58
inline bool & getHide () { return _hide; }
59
59
60
60
private:
61
61
World& _world;
62
62
std::string _name;
63
- std::map<std::type_index, std::unique_ptr<Component>> components ;
63
+ std::map<std::type_index, std::unique_ptr<Component>> _components ;
64
64
65
65
bool _dead = false ;
66
66
bool _hide = false ;
0 commit comments