diff --git a/encompass-cs/ComponentUpdateManager.cs b/encompass-cs/ComponentUpdateManager.cs index db166d2..b5b181c 100644 --- a/encompass-cs/ComponentUpdateManager.cs +++ b/encompass-cs/ComponentUpdateManager.cs @@ -8,12 +8,14 @@ namespace Encompass { private readonly ComponentStore existingComponentStore; private readonly ComponentStore immediateComponentStore; - public Dictionary TypeToIndex { get; } - + private readonly ComponentStore existingAndImmediateComponentStore; public ComponentStore UpToDateComponentStore { get; private set; } + public Dictionary TypeToIndex { get; } + public ComponentUpdateManager(Dictionary 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() where TComponent : struct, IComponent { + existingAndImmediateComponentStore.RegisterComponentType(); existingComponentStore.RegisterComponentType(); immediateComponentStore.RegisterComponentType(); UpToDateComponentStore.RegisterComponentType(); @@ -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(entity.ID, priority)) { + existingAndImmediateComponentStore.Remove(entity.ID, priority); UpToDateComponentStore.Remove(entity.ID, priority); return true; } @@ -81,6 +86,7 @@ namespace Encompass private void RegisterExistingOrImmediateComponentMessage(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() where TComponent : struct, IComponent { - return UpToDateComponentStore.All(); + return existingAndImmediateComponentStore.All(); } internal IEnumerable<(TComponent, int)> ReadExistingComponentsByType() where TComponent : struct, IComponent @@ -136,7 +142,7 @@ namespace Encompass internal bool SomeExistingOrImmediateComponent() where TComponent : struct, IComponent { - return UpToDateComponentStore.Any(); + return existingAndImmediateComponentStore.Any(); } internal bool SomeExistingComponent() where TComponent : struct, IComponent @@ -165,12 +171,12 @@ namespace Encompass internal bool HasExistingOrImmediateComponent(Entity entity) where TComponent : struct, IComponent { - return UpToDateComponentStore.Has(entity.ID); + return existingAndImmediateComponentStore.Has(entity.ID); } internal bool HasExistingOrImmediateComponent(Entity entity, Type type) { - return UpToDateComponentStore.Has(type, entity.ID); + return existingAndImmediateComponentStore.Has(type, entity.ID); } internal bool HasExistingComponent(Entity entity) where TComponent : struct, IComponent