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

Method createEntity

radiantcore/entity/EntityModule.cpp:91–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89}
90
91IEntityNodePtr Doom3EntityModule::createEntity(const IEntityClassPtr& eclass)
92{
93 IEntityNodePtr node = createNodeForEntity(eclass);
94
95 if (GlobalMapModule().getRoot())
96 {
97 // All entities are created in the active layer by default
98 node->moveToLayer(GlobalMapModule().getRoot()->getLayerManager().getActiveLayer());
99 }
100
101 node->getEntity().setKeyValue("classname", eclass->getDeclName());
102
103 // If this is not a worldspawn or unrecognised entity, generate a unique
104 // name for it
105 const std::string& eclassName = eclass->getDeclName();
106
107 if (!eclassName.empty() &&
108 eclassName != "worldspawn" &&
109 eclassName != "UNKNOWN_CLASS")
110 {
111 /* Clean up the name of the entity that is about the created
112 * so that nothing bad can happen (for example, the colon character
113 * seems to be causing problems in Doom 3 Scripting)
114 */
115 std::string entityName = string::replace_all_copy(eclassName, ":", "_") + "_1";
116
117 node->getEntity().setKeyValue("name", entityName);
118 }
119
120 return node;
121}
122
123IEntityNodePtr Doom3EntityModule::createEntityFromSelection(const std::string& name, const Vector3& origin)
124{

Callers 15

TEST_FFunction · 0.45
TEST_FFunction · 0.45
TEST_FFunction · 0.45
TEST_FFunction · 0.45
createAndSelectLightFunction · 0.45
TEST_FFunction · 0.45
createByClassNameFunction · 0.45
setupTestEntityFunction · 0.45
TEST_FFunction · 0.45
TEST_FFunction · 0.45

Calls 9

createNodeForEntityFunction · 0.85
replace_all_copyFunction · 0.85
moveToLayerMethod · 0.80
getDeclNameMethod · 0.80
getRootMethod · 0.45
getActiveLayerMethod · 0.45
setKeyValueMethod · 0.45
getEntityMethod · 0.45
emptyMethod · 0.45

Tested by 1

TEST_FFunction · 0.36