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

Method AddComponents

Engine/source/EtFramework/ECS/EcsController.cpp:317–340  ·  view source on GitHub ↗

----------------------------- EcsController::AddComponent Add a list of components to an entity

Source from the content-addressed store, hash-verified

315// Add a list of components to an entity
316//
317void EcsController::AddComponents(T_EntityId const entity, std::vector<RawComponentPtr>& components)
318{
319 // get referred entity
320 EntityData& ent = m_Entities[entity];
321
322 std::vector<RawComponentPtr> currentComponents;
323 T_CompTypeList compTypes = GetComponentsAndTypes(ent, currentComponents);
324
325 // add the new components
326 for (RawComponentPtr const& comp : components)
327 {
328 compTypes.emplace_back(comp.typeIdx);
329 currentComponents.emplace_back(comp);
330 }
331
332 MoveArchetype(entity, ent, compTypes, currentComponents);
333
334 // reassign the component pointers and emit component add events
335 for (RawComponentPtr& comp : components)
336 {
337 comp.data = ent.archetype->GetPool(comp.typeIdx).At(ent.index);
338 m_ComponentEvents[comp.typeIdx].Notify(detail::E_EcsEvent::Added, new detail::ComponentEventData(this, comp.data, entity));
339 }
340}
341
342//---------------------------------
343// EcsController::RemoveComponents

Callers 9

ProcessMethod · 0.80
OnInitMethod · 0.80
RegisterEcsEventsMethod · 0.80
LoadSceneMethod · 0.80
AddEntityMethod · 0.80
OnComponentAddedMethod · 0.80
MergeMethod · 0.80
ProcessMethod · 0.80

Calls 1

AtMethod · 0.80

Tested by 1

ProcessMethod · 0.64