diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2018-02-11 12:34:52 -0500 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2018-02-11 12:34:52 -0500 |
commit | 77be863f4f15d2481a64e4e8dadb4060a6e4e590 (patch) | |
tree | ca571702d2148a75b5b847e77d26270257f54ebc /src/entity_manager.h | |
parent | 1400ade977e13e3b535d3c2fddb6e15de3c9b5a5 (diff) | |
download | therapy-77be863f4f15d2481a64e4e8dadb4060a6e4e590.tar.gz therapy-77be863f4f15d2481a64e4e8dadb4060a6e4e590.tar.bz2 therapy-77be863f4f15d2481a64e4e8dadb4060a6e4e590.zip |
Implemented map rendering and basic collision
Only wall and platform collision currently works, and map edges are not currently implemented.
Diffstat (limited to 'src/entity_manager.h')
-rw-r--r-- | src/entity_manager.h | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/entity_manager.h b/src/entity_manager.h index 9068fe3..7fd82fc 100644 --- a/src/entity_manager.h +++ b/src/entity_manager.h | |||
@@ -106,7 +106,7 @@ public: | |||
106 | { | 106 | { |
107 | if ((entity >= entities.size()) || slotAvailable[entity]) | 107 | if ((entity >= entities.size()) || slotAvailable[entity]) |
108 | { | 108 | { |
109 | throw std::invalid_argument("Cannot delete non-existent entity"); | 109 | throw std::invalid_argument("Cannot get non-existent entity"); |
110 | } | 110 | } |
111 | 111 | ||
112 | EntityData& data = entities[entity]; | 112 | EntityData& data = entities[entity]; |
@@ -138,7 +138,7 @@ public: | |||
138 | { | 138 | { |
139 | if ((entity >= entities.size()) || slotAvailable[entity]) | 139 | if ((entity >= entities.size()) || slotAvailable[entity]) |
140 | { | 140 | { |
141 | throw std::invalid_argument("Cannot delete non-existent entity"); | 141 | throw std::invalid_argument("Cannot get non-existent entity"); |
142 | } | 142 | } |
143 | 143 | ||
144 | EntityData& data = entities[entity]; | 144 | EntityData& data = entities[entity]; |
@@ -167,7 +167,7 @@ public: | |||
167 | { | 167 | { |
168 | if ((entity >= entities.size()) || slotAvailable[entity]) | 168 | if ((entity >= entities.size()) || slotAvailable[entity]) |
169 | { | 169 | { |
170 | throw std::invalid_argument("Cannot delete non-existent entity"); | 170 | throw std::invalid_argument("Cannot get non-existent entity"); |
171 | } | 171 | } |
172 | 172 | ||
173 | EntityData& data = entities[entity]; | 173 | EntityData& data = entities[entity]; |
@@ -181,6 +181,20 @@ public: | |||
181 | return *dynamic_cast<T*>(data.components[componentType].get()); | 181 | return *dynamic_cast<T*>(data.components[componentType].get()); |
182 | } | 182 | } |
183 | 183 | ||
184 | template <class T> | ||
185 | bool hasComponent(id_type entity) | ||
186 | { | ||
187 | if ((entity >= entities.size()) || slotAvailable[entity]) | ||
188 | { | ||
189 | throw std::invalid_argument("Cannot get non-existent entity"); | ||
190 | } | ||
191 | |||
192 | EntityData& data = entities[entity]; | ||
193 | std::type_index componentType = typeid(T); | ||
194 | |||
195 | return data.components.count(componentType); | ||
196 | } | ||
197 | |||
184 | template <class... R> | 198 | template <class... R> |
185 | std::set<id_type> getEntitiesWithComponents() | 199 | std::set<id_type> getEntitiesWithComponents() |
186 | { | 200 | { |