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

Method AddEntity

Engine/source/EtFramework/SceneGraph/UnifiedScene.cpp:212–244  ·  view source on GitHub ↗

------------------------- UnifiedScene::AddEntity Add an entity to the ECS and resolve dependency links - set parent to INVALID_ENTITY_ID to indicate a root entity

Source from the content-addressed store, hash-verified

210// - set parent to INVALID_ENTITY_ID to indicate a root entity
211//
212void UnifiedScene::AddEntity(EntityDescriptor const& entDesc, T_EntityId const parent)
213{
214 T_EntityId const id = m_Scene.AddEntityChild(parent);
215
216 // update all entity links referring to the assigned ID
217 EntityLinkResolver::Instance().OnEntityIdAssigned(entDesc.GetId(), id);
218 entDesc.SetAssignedId(id);
219
220 // create a component data list
221 std::vector<RawComponentPtr> components;
222 for (I_ComponentDescriptor* const compDesc : entDesc.GetComponents())
223 {
224 components.push_back(compDesc->MakeRawData());
225 }
226
227 // add the components to our new entity
228 // we copy the pointer list because the pointers are "repointed" to the constructed components, which doesn't allow us to free the original memory
229 m_Scene.AddComponents(id, std::vector<RawComponentPtr>(components));
230
231 // we can now free the memory of our raw component data - this needs to be done manually as we are using void*
232 for (RawComponentPtr& comp : components)
233 {
234 ComponentRegistry::Instance().GetFullDestructor(comp.typeIdx)(comp.data);
235 }
236
237 components.clear();
238
239 // add the child entities
240 for (EntityDescriptor const& childDesc : entDesc.GetChildren())
241 {
242 AddEntity(childDesc, id);
243 }
244}
245
246//------------------------------
247// UnifiedScene::PostLoadEntity

Callers

nothing calls this directly

Calls 8

OnEntityIdAssignedMethod · 0.80
SetAssignedIdMethod · 0.80
MakeRawDataMethod · 0.80
AddComponentsMethod · 0.80
GetFullDestructorMethod · 0.80
GetChildrenMethod · 0.80
AddEntityChildMethod · 0.45
GetIdMethod · 0.45

Tested by

no test coverage detected