38 {
39 if(parent == nullptr) {
40 Scene* currentScene = CORE->GetCore(
SceneMgr)->GetCurrentScene();
41 if(!
dynamic_cast<SScene*
>(currentScene))
return nullptr;
42
43 parent =
static_cast<SScene*
>(currentScene)->GetRoot();
44 }
45
46
47 std::map<SComponent*, SComponent*> clone_component;
48 std::map<SGameObject*, SGameObject*> clone_object;
49
50 CloningObjects(object, clone_component, clone_object, parent);
51
52 SGameObject* cloneObject_root = clone_object[object];
53
54
55 for(const auto& component_pair : clone_component) {
57 component->CopyReference(component_pair.first, clone_object, clone_component);
58 }
59
60 return cloneObject_root;
61}