MCPcopy Create free account
hub / github.com/codereader/DarkRadiant / setEntityClassname

Function setEntityClassname

radiantcore/selection/algorithm/Entity.cpp:74–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74void setEntityClassname(const std::string& classname)
75{
76 if (classname.empty())
77 {
78 throw cmd::ExecutionFailure(_("Cannot set classname to an empty string."));
79 }
80
81 if (classname == "worldspawn")
82 {
83 throw cmd::ExecutionFailure(_("Cannot change classname to worldspawn."));
84 }
85
86 std::set<scene::INodePtr> entitiesToProcess;
87
88 // Collect all entities that should have their classname set
89 GlobalSelectionSystem().foreachSelected([&](const scene::INodePtr& node)
90 {
91 // Check if we have an entity
92 Entity* entity = Node_getEntity(node);
93
94 if (entity != NULL && Node_isSelected(node))
95 {
96 if (!entity->isWorldspawn())
97 {
98 entitiesToProcess.insert(node);
99 }
100 else
101 {
102 throw cmd::ExecutionFailure(_("Cannot change classname of worldspawn entity."));
103 }
104 }
105 });
106
107 for (const scene::INodePtr& node : entitiesToProcess)
108 {
109 // "Rename" the entity, this deletes the old node and creates a new one
110 scene::INodePtr newNode = changeEntityClassname(node, classname);
111
112 // Select the new entity node
113 Node_setSelected(newNode, true);
114 }
115}
116
117void setEntityKeyValue(const std::string& key, const std::string& value)
118{

Callers 1

setEntityKeyValueFunction · 0.85

Calls 10

ExecutionFailureClass · 0.85
Node_getEntityFunction · 0.85
Node_isSelectedFunction · 0.85
changeEntityClassnameFunction · 0.85
Node_setSelectedFunction · 0.85
isWorldspawnMethod · 0.80
_Function · 0.50
emptyMethod · 0.45
foreachSelectedMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected