CSEngine
Loading...
Searching...
No Matches
CSE::SCloneFactory Class Reference

Static Public Member Functions

static SComponentClone (SComponent *component, SGameObject *parent=nullptr)
 
static SGameObjectClone (SGameObject *object, SGameObject *parent=nullptr)
 

Detailed Description

Definition at line 11 of file SCloneFactory.h.

Member Function Documentation

◆ Clone() [1/2]

SComponent * SCloneFactory::Clone ( SComponent component,
SGameObject parent = nullptr 
)
static

Definition at line 24 of file SCloneFactory.cpp.

24 {
25 if(parent == nullptr) {
26 Scene* currentScene = CORE->GetCore(SceneMgr)->GetCurrentScene();
27 if(!dynamic_cast<SScene*>(currentScene)) return nullptr;
28
29 parent = static_cast<SScene*>(currentScene)->GetRoot();
30 }
31
32 SComponent* clone_component = component->Clone(parent);
33 clone_component->CopyReference(component, std::map<SGameObject*, SGameObject*>(), std::map<SComponent*, SComponent*>());
34
35 return clone_component;
36}

◆ Clone() [2/2]

SGameObject * SCloneFactory::Clone ( SGameObject object,
SGameObject parent = nullptr 
)
static

Definition at line 38 of file SCloneFactory.cpp.

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) {
56 SComponent* component = component_pair.second;
57 component->CopyReference(component_pair.first, clone_object, clone_component);
58 }
59
60 return cloneObject_root;
61}

The documentation for this class was generated from the following files: