remove unnecessary component store

pull/5/head
Evan Hemsley 2019-12-28 22:20:17 -08:00
parent d4115b231c
commit 28f2ba969a
1 changed files with 6 additions and 14 deletions

View File

@ -1,21 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace Encompass
{
internal class ComponentUpdateManager
{
private readonly ComponentStore existingComponentStore;
private ComponentStore existingComponentStore;
private readonly ComponentStore immediateComponentStore;
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);
@ -24,7 +21,6 @@ namespace Encompass
public void RegisterComponentType<TComponent>() where TComponent : struct, IComponent
{
existingAndImmediateComponentStore.RegisterComponentType<TComponent>();
existingComponentStore.RegisterComponentType<TComponent>();
immediateComponentStore.RegisterComponentType<TComponent>();
UpToDateComponentStore.RegisterComponentType<TComponent>();
@ -32,7 +28,6 @@ namespace Encompass
internal void Clear()
{
existingAndImmediateComponentStore.ClearAll();
existingComponentStore.ClearAll();
immediateComponentStore.ClearAll();
UpToDateComponentStore.ClearAll();
@ -45,7 +40,6 @@ namespace Encompass
internal void AddExistingComponent<TComponent>(Entity entity, TComponent component) where TComponent : struct, IComponent
{
existingAndImmediateComponentStore.Set(entity.ID, component);
existingComponentStore.Set(entity.ID, component);
UpToDateComponentStore.Set(entity.ID, component);
}
@ -54,7 +48,6 @@ namespace Encompass
{
if (immediateComponentStore.Set(entity.ID, component, priority))
{
existingAndImmediateComponentStore.Set(entity.ID, component);
UpToDateComponentStore.Set(entity.ID, component);
return true;
}
@ -66,7 +59,6 @@ namespace Encompass
{
if (immediateComponentStore.Remove<TComponent>(entity.ID, priority))
{
existingAndImmediateComponentStore.Remove<TComponent>(entity.ID, priority);
UpToDateComponentStore.Remove<TComponent>(entity.ID, priority);
return true;
}
@ -88,7 +80,7 @@ namespace Encompass
internal IEnumerable<(TComponent, int)> ReadExistingAndImmediateComponentsByType<TComponent>() where TComponent : struct, IComponent
{
return existingAndImmediateComponentStore.All<TComponent>();
return UpToDateComponentStore.All<TComponent>();
}
internal IEnumerable<(TComponent, int)> ReadExistingComponentsByType<TComponent>() where TComponent : struct, IComponent
@ -131,7 +123,7 @@ namespace Encompass
internal bool SomeExistingOrImmediateComponent<TComponent>() where TComponent : struct, IComponent
{
return existingAndImmediateComponentStore.Any<TComponent>();
return UpToDateComponentStore.Any<TComponent>();
}
internal bool SomeExistingComponent<TComponent>() where TComponent : struct, IComponent
@ -148,7 +140,7 @@ namespace Encompass
internal TComponent ReadImmediateOrExistingComponentByEntityAndType<TComponent>(Entity entity) where TComponent : struct, IComponent
{
return existingAndImmediateComponentStore.Get<TComponent>(entity.ID);
return UpToDateComponentStore.Get<TComponent>(entity.ID);
}
internal TComponent ReadExistingComponentByEntityAndType<TComponent>(Entity entity) where TComponent : struct, IComponent
@ -165,12 +157,12 @@ namespace Encompass
internal bool HasExistingOrImmediateComponent<TComponent>(Entity entity) where TComponent : struct, IComponent
{
return existingAndImmediateComponentStore.Has<TComponent>(entity.ID);
return UpToDateComponentStore.Has<TComponent>(entity.ID);
}
internal bool HasExistingOrImmediateComponent(Entity entity, Type type)
{
return existingAndImmediateComponentStore.Has(type, entity.ID);
return UpToDateComponentStore.Has(type, entity.ID);
}
internal bool HasExistingComponent<TComponent>(Entity entity) where TComponent : struct, IComponent