MCPcopy Create free account
hub / github.com/Illation/ETEngine / DuplicateEntity

Method DuplicateEntity

Engine/source/EtFramework/ECS/EcsCommandBuffer.cpp:64–82  ·  view source on GitHub ↗

----------------------------------- EcsCommandBuffer::DuplicateEntity

Source from the content-addressed store, hash-verified

62// EcsCommandBuffer::DuplicateEntity
63//
64T_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

Callers 2

InitCameraMethod · 0.80
ProcessMethod · 0.80

Calls 3

GetComponentDataMethod · 0.80
AddEntityChildMethod · 0.45
GetParentMethod · 0.45

Tested by 1

ProcessMethod · 0.64