----------------------------------- EcsCommandBuffer::DuplicateEntity
| 62 | // EcsCommandBuffer::DuplicateEntity |
| 63 | // |
| 64 | T_EntityId EcsCommandBuffer::DuplicateEntity(T_EntityId const dupe) |
| 65 | { |
| 66 | // create a new entity with the same parent |
| 67 | T_EntityId const ret = m_Controller->AddEntityChild(m_Controller->GetParent(dupe)); |
| 68 | |
| 69 | // get the entities component list |
| 70 | T_CompTypeList const& compTypes = m_Controller->GetComponentTypes(dupe); |
| 71 | std::vector<RawComponentPtr> components; |
| 72 | for (T_CompTypeIdx const typeId : compTypes) |
| 73 | { |
| 74 | components.emplace_back(typeId, m_Controller->GetComponentData(dupe, typeId)); |
| 75 | } |
| 76 | |
| 77 | // copy those components and queue them for later merge into the newly created entity |
| 78 | AddComponentList(ret, components); |
| 79 | |
| 80 | // return the new entities ID |
| 81 | return ret; |
| 82 | } |
| 83 | |
| 84 | |
| 85 | // modify existing entities |