Merge pull request #150 from SHADE-DP/SP3-5-ECS
Sp3 5 ecs Removed Component event now runs after the component has been removed from the sparse set
This commit is contained in:
commit
2f94002561
|
@ -33,18 +33,18 @@ namespace SHADE
|
|||
return;
|
||||
}
|
||||
|
||||
std::vector<SHComponentRemovedEvent> eventVec;
|
||||
|
||||
for (uint32_t i = 0; i < componentSet.Size(); ++i)
|
||||
{
|
||||
SHComponent* comp = (SHComponent*) componentSet.GetElement(i, EntityHandleGenerator::GetIndex(entityID));
|
||||
if (comp)
|
||||
{
|
||||
comp->OnDestroy();
|
||||
|
||||
SHComponentRemovedEvent eventData;
|
||||
eventData.eid = entityID;
|
||||
eventData.removedComponentType = i;
|
||||
|
||||
SHEventManager::BroadcastEvent<SHComponentRemovedEvent>(eventData, SH_COMPONENT_REMOVED_EVENT);
|
||||
eventVec.push_back(eventData);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,6 +57,12 @@ namespace SHADE
|
|||
|
||||
componentSet.RemoveElements(EntityHandleGenerator::GetIndex(entityID));
|
||||
|
||||
for (auto& eventData : eventVec)
|
||||
{
|
||||
SHEventManager::BroadcastEvent<SHComponentRemovedEvent>(eventData, SH_COMPONENT_REMOVED_EVENT);
|
||||
}
|
||||
|
||||
|
||||
//entityHandle.RemoveHandle(entityID);
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue