/
ObjectiveEntityFinder.cpp
56 lines (40 loc) · 1.38 KB
/
ObjectiveEntityFinder.cpp
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
#include "ObjectiveEntityFinder.h"
#include "ientity.h"
namespace objectives
{
bool ObjectiveEntityFinder::pre(const scene::INodePtr& node)
{
// Get the entity and check the classname
Entity* ePtr = Node_getEntity(node);
if (!ePtr)
return true;
// We have an entity at this point
if (ePtr->isWorldspawn())
{
_worldSpawn = ePtr;
return false; // Don't traverse worldspawn children
}
// Check for objective entity or worldspawn
for (std::vector<std::string>::iterator i = _classNames.begin();
i != _classNames.end();
++i)
{
if (ePtr->getKeyValue("classname") == *i)
{
// Construct the display string
std::string name = ePtr->getKeyValue("name");
// Add the entity to the list
wxutil::TreeModel::Row row = _store->AddItem();
row[_columns.displayName] = (boost::format(_("%s at [ %s ]")) % name % ePtr->getKeyValue("origin")).str();
row[_columns.entityName] = name;
row[_columns.startActive] = false;
row.SendItemAdded();
// Construct an ObjectiveEntity with the node, and add to the map
ObjectiveEntityPtr oe(new ObjectiveEntity(node));
_map.insert(ObjectiveEntityMap::value_type(name, oe));
break;
}
}
return false; // don't traverse entity children
}
}