remove unnecessary component store
parent
d4115b231c
commit
28f2ba969a
|
@ -1,21 +1,18 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace Encompass
|
namespace Encompass
|
||||||
{
|
{
|
||||||
internal class ComponentUpdateManager
|
internal class ComponentUpdateManager
|
||||||
{
|
{
|
||||||
private readonly ComponentStore existingComponentStore;
|
private ComponentStore existingComponentStore;
|
||||||
private readonly ComponentStore immediateComponentStore;
|
private readonly ComponentStore immediateComponentStore;
|
||||||
private readonly ComponentStore existingAndImmediateComponentStore;
|
|
||||||
public ComponentStore UpToDateComponentStore { get; private set; }
|
public ComponentStore UpToDateComponentStore { get; private set; }
|
||||||
|
|
||||||
public Dictionary<Type, int> TypeToIndex { get; }
|
public Dictionary<Type, int> TypeToIndex { get; }
|
||||||
|
|
||||||
public ComponentUpdateManager(Dictionary<Type, int> typeToIndex)
|
public ComponentUpdateManager(Dictionary<Type, int> typeToIndex)
|
||||||
{
|
{
|
||||||
existingAndImmediateComponentStore = new ComponentStore(typeToIndex);
|
|
||||||
existingComponentStore = new ComponentStore(typeToIndex);
|
existingComponentStore = new ComponentStore(typeToIndex);
|
||||||
immediateComponentStore = new ComponentStore(typeToIndex);
|
immediateComponentStore = new ComponentStore(typeToIndex);
|
||||||
UpToDateComponentStore = new ComponentStore(typeToIndex);
|
UpToDateComponentStore = new ComponentStore(typeToIndex);
|
||||||
|
@ -24,7 +21,6 @@ namespace Encompass
|
||||||
|
|
||||||
public void RegisterComponentType<TComponent>() where TComponent : struct, IComponent
|
public void RegisterComponentType<TComponent>() where TComponent : struct, IComponent
|
||||||
{
|
{
|
||||||
existingAndImmediateComponentStore.RegisterComponentType<TComponent>();
|
|
||||||
existingComponentStore.RegisterComponentType<TComponent>();
|
existingComponentStore.RegisterComponentType<TComponent>();
|
||||||
immediateComponentStore.RegisterComponentType<TComponent>();
|
immediateComponentStore.RegisterComponentType<TComponent>();
|
||||||
UpToDateComponentStore.RegisterComponentType<TComponent>();
|
UpToDateComponentStore.RegisterComponentType<TComponent>();
|
||||||
|
@ -32,7 +28,6 @@ namespace Encompass
|
||||||
|
|
||||||
internal void Clear()
|
internal void Clear()
|
||||||
{
|
{
|
||||||
existingAndImmediateComponentStore.ClearAll();
|
|
||||||
existingComponentStore.ClearAll();
|
existingComponentStore.ClearAll();
|
||||||
immediateComponentStore.ClearAll();
|
immediateComponentStore.ClearAll();
|
||||||
UpToDateComponentStore.ClearAll();
|
UpToDateComponentStore.ClearAll();
|
||||||
|
@ -45,7 +40,6 @@ namespace Encompass
|
||||||
|
|
||||||
internal void AddExistingComponent<TComponent>(Entity entity, TComponent component) where TComponent : struct, IComponent
|
internal void AddExistingComponent<TComponent>(Entity entity, TComponent component) where TComponent : struct, IComponent
|
||||||
{
|
{
|
||||||
existingAndImmediateComponentStore.Set(entity.ID, component);
|
|
||||||
existingComponentStore.Set(entity.ID, component);
|
existingComponentStore.Set(entity.ID, component);
|
||||||
UpToDateComponentStore.Set(entity.ID, component);
|
UpToDateComponentStore.Set(entity.ID, component);
|
||||||
}
|
}
|
||||||
|
@ -54,7 +48,6 @@ namespace Encompass
|
||||||
{
|
{
|
||||||
if (immediateComponentStore.Set(entity.ID, component, priority))
|
if (immediateComponentStore.Set(entity.ID, component, priority))
|
||||||
{
|
{
|
||||||
existingAndImmediateComponentStore.Set(entity.ID, component);
|
|
||||||
UpToDateComponentStore.Set(entity.ID, component);
|
UpToDateComponentStore.Set(entity.ID, component);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -66,7 +59,6 @@ namespace Encompass
|
||||||
{
|
{
|
||||||
if (immediateComponentStore.Remove<TComponent>(entity.ID, priority))
|
if (immediateComponentStore.Remove<TComponent>(entity.ID, priority))
|
||||||
{
|
{
|
||||||
existingAndImmediateComponentStore.Remove<TComponent>(entity.ID, priority);
|
|
||||||
UpToDateComponentStore.Remove<TComponent>(entity.ID, priority);
|
UpToDateComponentStore.Remove<TComponent>(entity.ID, priority);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -88,7 +80,7 @@ namespace Encompass
|
||||||
|
|
||||||
internal IEnumerable<(TComponent, int)> ReadExistingAndImmediateComponentsByType<TComponent>() where TComponent : struct, IComponent
|
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
|
internal IEnumerable<(TComponent, int)> ReadExistingComponentsByType<TComponent>() where TComponent : struct, IComponent
|
||||||
|
@ -131,7 +123,7 @@ namespace Encompass
|
||||||
|
|
||||||
internal bool SomeExistingOrImmediateComponent<TComponent>() where TComponent : struct, IComponent
|
internal bool SomeExistingOrImmediateComponent<TComponent>() where TComponent : struct, IComponent
|
||||||
{
|
{
|
||||||
return existingAndImmediateComponentStore.Any<TComponent>();
|
return UpToDateComponentStore.Any<TComponent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal bool SomeExistingComponent<TComponent>() where TComponent : struct, IComponent
|
internal bool SomeExistingComponent<TComponent>() where TComponent : struct, IComponent
|
||||||
|
@ -148,7 +140,7 @@ namespace Encompass
|
||||||
|
|
||||||
internal TComponent ReadImmediateOrExistingComponentByEntityAndType<TComponent>(Entity entity) where TComponent : struct, IComponent
|
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
|
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
|
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)
|
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
|
internal bool HasExistingComponent<TComponent>(Entity entity) where TComponent : struct, IComponent
|
||||||
|
|
Loading…
Reference in New Issue