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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<SHComponentRemovedEvent> eventVec;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < componentSet.Size(); ++i)
|
for (uint32_t i = 0; i < componentSet.Size(); ++i)
|
||||||
{
|
{
|
||||||
SHComponent* comp = (SHComponent*) componentSet.GetElement(i, EntityHandleGenerator::GetIndex(entityID));
|
SHComponent* comp = (SHComponent*) componentSet.GetElement(i, EntityHandleGenerator::GetIndex(entityID));
|
||||||
if (comp)
|
if (comp)
|
||||||
{
|
{
|
||||||
comp->OnDestroy();
|
comp->OnDestroy();
|
||||||
|
|
||||||
SHComponentRemovedEvent eventData;
|
SHComponentRemovedEvent eventData;
|
||||||
eventData.eid = entityID;
|
eventData.eid = entityID;
|
||||||
eventData.removedComponentType = i;
|
eventData.removedComponentType = i;
|
||||||
|
eventVec.push_back(eventData);
|
||||||
SHEventManager::BroadcastEvent<SHComponentRemovedEvent>(eventData, SH_COMPONENT_REMOVED_EVENT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,6 +57,12 @@ namespace SHADE
|
||||||
|
|
||||||
componentSet.RemoveElements(EntityHandleGenerator::GetIndex(entityID));
|
componentSet.RemoveElements(EntityHandleGenerator::GetIndex(entityID));
|
||||||
|
|
||||||
|
for (auto& eventData : eventVec)
|
||||||
|
{
|
||||||
|
SHEventManager::BroadcastEvent<SHComponentRemovedEvent>(eventData, SH_COMPONENT_REMOVED_EVENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//entityHandle.RemoveHandle(entityID);
|
//entityHandle.RemoveHandle(entityID);
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue