Removed Component event now runs after the component has been removed from the sparse set
This commit is contained in:
parent
a9c1bd7e7a
commit
d5cadfe8ed
|
@ -33,19 +33,19 @@ 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;
|
||||
eventVec.push_back(eventData);
|
||||
}
|
||||
SHComponentRemovedEvent eventData;
|
||||
eventData.eid = entityID;
|
||||
eventData.removedComponentType = i;
|
||||
|
||||
SHEventManager::BroadcastEvent<SHComponentRemovedEvent>(eventData, SH_COMPONENT_REMOVED_EVENT);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -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