mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-21 01:39:32 +00:00
Notify subscribers before removing components from entity (#589)
This commit is contained in:
committed by
Dylan Wilson
parent
fd59442316
commit
7526606feb
@@ -98,15 +98,15 @@ namespace MonoGame.Extended.Entities
|
||||
|
||||
foreach (var entityId in _removedEntities)
|
||||
{
|
||||
// we must notify subscribers before removing it from the pool
|
||||
// otherwise an entity system could still be using the entity when the same id is obtained.
|
||||
EntityRemoved?.Invoke(entityId);
|
||||
|
||||
var entity = _entityBag[entityId];
|
||||
_entityBag[entityId] = null;
|
||||
_componentManager.Destroy(entityId);
|
||||
_entityToComponentBits[entityId] = default(BitVector32);
|
||||
ActiveCount--;
|
||||
|
||||
// we must notify subscribers before removing it from the pool
|
||||
// otherwise an entity system could still be using the entity when the same id is obtained.
|
||||
EntityRemoved?.Invoke(entityId);
|
||||
_entityPool.Free(entity);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user