Debian Codegraph @

plugins/dm.difficulty/DifficultyEntityFinder.h

raw
1 #pragma once
2
3 #include "ientity.h"
4 #include "gamelib.h"
5 #include "DifficultySettings.h"
6
7 namespace difficulty {
8
9 class DifficultyEntityFinder :
10 public scene::NodeVisitor
11 {
12 public:
13 // Found difficulty entities are stored in this list
14 typedef std::vector<Entity*> EntityList;
15
16 private:
17 // The entityClass name to search for
18 std::string _entityClassName;
19
20 // The list of found entities
21 EntityList _foundEntities;
22
23 public:
24 DifficultyEntityFinder() :
25 _entityClassName(game::current::getValue<std::string>(GKEY_DIFFICULTY_ENTITYDEF_MAP))
26 {}
27
28 // Return the list of found entites
29 const EntityList& getEntities() const {
30 return _foundEntities;
31 }
32
33 // Walker implementation
34 bool pre(const scene::INodePtr& node) {
35 // Check if we have an entity
36 Entity* entity = Node_getEntity(node);
37
38 if (entity != NULL) {
39 // Check for a classname match
40 if (entity->getKeyValue("classname") == _entityClassName) {
41 _foundEntities.push_back(entity);
42 }
43
44 // Don't traverse the children of entities
45 return false;
46 }
47
48 return true;
49 }
50 };
51
52 } // namespace difficulty