diff --git a/encompass-cs/Collections/ComponentStore.cs b/encompass-cs/Collections/ComponentStore.cs index 986a5b0..99b85d3 100644 --- a/encompass-cs/Collections/ComponentStore.cs +++ b/encompass-cs/Collections/ComponentStore.cs @@ -118,11 +118,21 @@ namespace Encompass return Lookup().AllComponents(); } + public IEnumerable AllAsEnumerable() where TComponent : struct + { + return Lookup().AllComponentsAsEnumerable(); + } + public ReadOnlySpan AllEntities() where TComponent : struct { return Lookup().AllEntities(); } + public IEnumerable AllEntitiesAsEnumerable() where TComponent : struct + { + return Lookup().AllEntitiesAsEnumerable(); + } + public void Clear() where TComponent : struct { Lookup().Clear(); diff --git a/encompass-cs/Collections/TypedComponentStore.cs b/encompass-cs/Collections/TypedComponentStore.cs index 83cd785..5b837c6 100644 --- a/encompass-cs/Collections/TypedComponentStore.cs +++ b/encompass-cs/Collections/TypedComponentStore.cs @@ -132,9 +132,19 @@ namespace Encompass return new ReadOnlySpan(_storageIndexToEntities, 0, _nextID); } + public IEnumerable AllEntitiesAsEnumerable() + { + return new ArraySegment(_storageIndexToEntities, 0, _nextID); + } + public ReadOnlySpan AllComponents() { return new ReadOnlySpan(_components, 0, _nextID); } + + public IEnumerable AllComponentsAsEnumerable() + { + return new ArraySegment(_components, 0, _nextID); + } } } diff --git a/encompass-cs/ComponentManager.cs b/encompass-cs/ComponentManager.cs index 868ba05..da54e8e 100644 --- a/encompass-cs/ComponentManager.cs +++ b/encompass-cs/ComponentManager.cs @@ -140,6 +140,11 @@ namespace Encompass return _existingComponentStore.AllEntities(); } + internal IEnumerable GetExistingEntitiesAsEnumerable() where TComponent : struct + { + return _existingComponentStore.AllEntitiesAsEnumerable(); + } + internal ref readonly Entity ExistingSingularEntity() where TComponent : struct { return ref _existingComponentStore.SingularEntity(); @@ -231,6 +236,11 @@ namespace Encompass return _existingComponentStore.All(); } + internal IEnumerable GetComponentsByTypeEnumerable() where TComponent : struct + { + return _existingComponentStore.AllAsEnumerable(); + } + internal ref readonly TComponent GetComponentByEntityAndType(int entityID) where TComponent : struct { return ref _existingComponentStore.Get(entityID); diff --git a/encompass-cs/Renderer.cs b/encompass-cs/Renderer.cs index 697e377..7891489 100644 --- a/encompass-cs/Renderer.cs +++ b/encompass-cs/Renderer.cs @@ -23,6 +23,11 @@ namespace Encompass return _componentManager.GetExistingEntities(); } + protected IEnumerable ReadEntitiesAsEnumerable() where TComponent : struct, IComponent + { + return _componentManager.GetExistingEntitiesAsEnumerable(); + } + protected ref readonly Entity ReadEntity() where TComponent : struct, IComponent { return ref _componentManager.ExistingSingularEntity(); @@ -33,6 +38,11 @@ namespace Encompass return _componentManager.GetComponentsByType(); } + protected IEnumerable ReadComponentsAsEnumerable() where TComponent : struct, IComponent + { + return _componentManager.GetComponentsByTypeEnumerable(); + } + protected ref readonly TComponent ReadComponent() where TComponent : struct, IComponent { return ref _componentManager.ExistingSingular();