Debian Codegraph @

plugins/dm.objectives/ObjectiveEntityFinder.cpp

raw
1 #include "ObjectiveEntityFinder.h"
2
3 #include "ientity.h"
4
5 namespace objectives
6 {
7
8 bool ObjectiveEntityFinder::pre(const scene::INodePtr& node)
9 {
10 // Get the entity and check the classname
11 Entity* ePtr = Node_getEntity(node);
12 if (!ePtr)
13 return true;
14
15 // We have an entity at this point
16
17 if (ePtr->isWorldspawn())
18 {
19 _worldSpawn = ePtr;
20 return false; // Don't traverse worldspawn children
21 }
22
23 // Check for objective entity or worldspawn
24 for (std::vector<std::string>::iterator i = _classNames.begin();
25 i != _classNames.end();
26 ++i)
27 {
28 if (ePtr->getKeyValue("classname") == *i)
29 {
30 // Construct the display string
31 std::string name = ePtr->getKeyValue("name");
32
33 // Add the entity to the list
34 wxutil::TreeModel::Row row = _store->AddItem();
35
36 row[_columns.displayName] = fmt::format(_("{0} at [ {1} ]"), name, ePtr->getKeyValue("origin"));
37 row[_columns.entityName] = name;
38 row[_columns.startActive] = false;
39
40 row.SendItemAdded();
41
42 // Construct an ObjectiveEntity with the node, and add to the map
43 ObjectiveEntityPtr oe(new ObjectiveEntity(node));
44 _map.insert(ObjectiveEntityMap::value_type(name, oe));
45
46 break;
47 }
48 }
49
50 return false; // don't traverse entity children
51 }
52
53 }
54
55
56