60 auto* cloned =
new Entity();
69 cloned->setName(
name());
78 for (
const auto& [typeId, srcComponent] : _components) {
79 auto* system = srcComponent->system();
85 system =
engine->systems()->getByComponentTypeInfo(
typeid(*srcComponent));
91 auto newComponent = system->addComponent(cloned);
97 newComponent->cloneFrom(srcComponent);
99 auto* raw = newComponent.get();
100 cloned->_components[typeId] = raw;
101 cloned->_componentStorage.push_back(std::move(newComponent));
110 for (
const auto* child :
children()) {
111 const auto* childEntity =
dynamic_cast<const Entity*
>(child);
113 auto* clonedChild = childEntity->clone();
114 cloned->addChild(clonedChild);