| 89 | } |
| 90 | |
| 91 | IEntityNodePtr 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 | |
| 123 | IEntityNodePtr Doom3EntityModule::createEntityFromSelection(const std::string& name, const Vector3& origin) |
| 124 | { |