add extra component store

pull/5/head
Evan Hemsley 2019-12-23 20:36:12 -08:00
parent 7029b9f52e
commit b644f4fb4b
1 changed files with 12 additions and 6 deletions

View File

@ -8,12 +8,14 @@ namespace Encompass
{
private readonly ComponentStore existingComponentStore;
private readonly ComponentStore immediateComponentStore;
public Dictionary<Type, int> TypeToIndex { get; }
private readonly ComponentStore existingAndImmediateComponentStore;
public ComponentStore UpToDateComponentStore { get; private set; }
public Dictionary<Type, int> TypeToIndex { get; }
public ComponentUpdateManager(Dictionary<Type, int> typeToIndex)
{
existingAndImmediateComponentStore = new ComponentStore(typeToIndex);
existingComponentStore = new ComponentStore(typeToIndex);
immediateComponentStore = new ComponentStore(typeToIndex);
UpToDateComponentStore = new ComponentStore(typeToIndex);
@ -22,6 +24,7 @@ namespace Encompass
public void RegisterComponentType<TComponent>() where TComponent : struct, IComponent
{
existingAndImmediateComponentStore.RegisterComponentType<TComponent>();
existingComponentStore.RegisterComponentType<TComponent>();
immediateComponentStore.RegisterComponentType<TComponent>();
UpToDateComponentStore.RegisterComponentType<TComponent>();
@ -29,6 +32,7 @@ namespace Encompass
internal void Clear()
{
existingAndImmediateComponentStore.ClearAll();
existingComponentStore.ClearAll();
immediateComponentStore.ClearAll();
UpToDateComponentStore.ClearAll();
@ -61,6 +65,7 @@ namespace Encompass
{
if (immediateComponentStore.Remove<TComponent>(entity.ID, priority))
{
existingAndImmediateComponentStore.Remove<TComponent>(entity.ID, priority);
UpToDateComponentStore.Remove<TComponent>(entity.ID, priority);
return true;
}
@ -81,6 +86,7 @@ namespace Encompass
private void RegisterExistingOrImmediateComponentMessage<TComponent>(Entity entity, TComponent component) where TComponent : struct, IComponent
{
existingAndImmediateComponentStore.Set(entity.ID, component);
UpToDateComponentStore.Set(entity.ID, component);
}
@ -93,7 +99,7 @@ namespace Encompass
internal IEnumerable<(TComponent, int)> ReadExistingAndImmediateComponentsByType<TComponent>() where TComponent : struct, IComponent
{
return UpToDateComponentStore.All<TComponent>();
return existingAndImmediateComponentStore.All<TComponent>();
}
internal IEnumerable<(TComponent, int)> ReadExistingComponentsByType<TComponent>() where TComponent : struct, IComponent
@ -136,7 +142,7 @@ namespace Encompass
internal bool SomeExistingOrImmediateComponent<TComponent>() where TComponent : struct, IComponent
{
return UpToDateComponentStore.Any<TComponent>();
return existingAndImmediateComponentStore.Any<TComponent>();
}
internal bool SomeExistingComponent<TComponent>() where TComponent : struct, IComponent
@ -165,12 +171,12 @@ namespace Encompass
internal bool HasExistingOrImmediateComponent<TComponent>(Entity entity) where TComponent : struct, IComponent
{
return UpToDateComponentStore.Has<TComponent>(entity.ID);
return existingAndImmediateComponentStore.Has<TComponent>(entity.ID);
}
internal bool HasExistingOrImmediateComponent(Entity entity, Type type)
{
return UpToDateComponentStore.Has(type, entity.ID);
return existingAndImmediateComponentStore.Has(type, entity.ID);
}
internal bool HasExistingComponent<TComponent>(Entity entity) where TComponent : struct, IComponent