untrack destroyed entities

pull/5/head
Evan Hemsley 2019-12-28 16:16:21 -08:00
parent 936b97c4ec
commit 05fa578652
5 changed files with 10 additions and 6 deletions

View File

@ -718,5 +718,10 @@ namespace Encompass
withMask.Not()
);
}
internal void RegisterDestroyedEntity(Entity entity)
{
_trackedEntities.Remove(entity);
}
}
}

View File

@ -64,10 +64,11 @@ namespace Encompass
entitiesMarkedForDestroy.Add(entity);
}
public void DestroyMarkedEntities()
public void DestroyMarkedEntities(IEnumerable<Engine> engines)
{
foreach (var entity in entitiesMarkedForDestroy)
{
foreach (var engine in engines) { engine.RegisterDestroyedEntity(entity); }
componentManager.MarkAllComponentsOnEntityForRemoval(entity);
IDs.Remove(entity.ID);
idManager.Free(entity.ID);

View File

@ -70,7 +70,6 @@ namespace Encompass
foreach (var engine in _componentTypesToEngines[componentType])
{
_pairsToCheck.Add((entity, engine));
// engine.CheckTrackEntity(entity);
}
}
}
@ -83,7 +82,6 @@ namespace Encompass
foreach (var engine in _componentTypesToEngines[componentType])
{
_pairsToCheck.Add((entity, engine));
//engine.CheckUntrackEntity(entity);
}
}
}

View File

@ -60,7 +60,7 @@ namespace Encompass
}
messageManager.ClearMessages();
entityManager.DestroyMarkedEntities();
entityManager.DestroyMarkedEntities(enginesInOrder);
componentManager.WriteComponents();
componentManager.RemoveMarkedComponents();

View File

@ -48,12 +48,12 @@ namespace Encompass
this.entityCapacity = entityCapacity;
drawLayerManager = new DrawLayerManager(typeToIndex);
timeManager = new TimeManager();
trackingManager = new TrackingManager();
componentUpdateManager = new ComponentUpdateManager(typeToIndex);
componentManager = new ComponentManager(drawLayerManager, componentUpdateManager, typeToIndex);
messageManager = new MessageManager(timeManager);
entityManager = new EntityManager(componentManager, entityCapacity);
renderManager = new RenderManager(entityManager, drawLayerManager);
trackingManager = new TrackingManager();
startingComponentStoreForComponentManager = new ComponentStore(typeToIndex);
startingComponentStoreForComponentUpdateManager = new ComponentStore(typeToIndex);
@ -419,9 +419,9 @@ namespace Encompass
var dummyTimeManager = new TimeManager();
var dummyMessageManager = new MessageManager(dummyTimeManager);
var dummyDrawLayerManager = new DrawLayerManager(typeToIndex);
var dummyTrackingManager = new TrackingManager();
var dummyComponentUpdateManager = new ComponentUpdateManager(typeToIndex);
var dummyComponentManager = new ComponentManager(dummyDrawLayerManager, dummyComponentUpdateManager, typeToIndex);
var dummyTrackingManager = new TrackingManager();
var dummyEntityManager = new EntityManager(dummyComponentManager, entityCapacity);
var dummyRenderManager = new RenderManager(dummyEntityManager, dummyDrawLayerManager);