expose some enumerable iterators on Renderer
continuous-integration/drone/push Build is passing Details

pull/15/head
Evan Hemsley 2020-08-05 12:22:03 -07:00
parent 73ea4568ab
commit 0a30dab3c2
4 changed files with 40 additions and 0 deletions

View File

@ -118,11 +118,21 @@ namespace Encompass
return Lookup<TComponent>().AllComponents();
}
public IEnumerable<TComponent> AllAsEnumerable<TComponent>() where TComponent : struct
{
return Lookup<TComponent>().AllComponentsAsEnumerable();
}
public ReadOnlySpan<Entity> AllEntities<TComponent>() where TComponent : struct
{
return Lookup<TComponent>().AllEntities();
}
public IEnumerable<Entity> AllEntitiesAsEnumerable<TComponent>() where TComponent : struct
{
return Lookup<TComponent>().AllEntitiesAsEnumerable();
}
public void Clear<TComponent>() where TComponent : struct
{
Lookup<TComponent>().Clear();

View File

@ -132,9 +132,19 @@ namespace Encompass
return new ReadOnlySpan<Entity>(_storageIndexToEntities, 0, _nextID);
}
public IEnumerable<Entity> AllEntitiesAsEnumerable()
{
return new ArraySegment<Entity>(_storageIndexToEntities, 0, _nextID);
}
public ReadOnlySpan<TComponent> AllComponents()
{
return new ReadOnlySpan<TComponent>(_components, 0, _nextID);
}
public IEnumerable<TComponent> AllComponentsAsEnumerable()
{
return new ArraySegment<TComponent>(_components, 0, _nextID);
}
}
}

View File

@ -140,6 +140,11 @@ namespace Encompass
return _existingComponentStore.AllEntities<TComponent>();
}
internal IEnumerable<Entity> GetExistingEntitiesAsEnumerable<TComponent>() where TComponent : struct
{
return _existingComponentStore.AllEntitiesAsEnumerable<TComponent>();
}
internal ref readonly Entity ExistingSingularEntity<TComponent>() where TComponent : struct
{
return ref _existingComponentStore.SingularEntity<TComponent>();
@ -231,6 +236,11 @@ namespace Encompass
return _existingComponentStore.All<TComponent>();
}
internal IEnumerable<TComponent> GetComponentsByTypeEnumerable<TComponent>() where TComponent : struct
{
return _existingComponentStore.AllAsEnumerable<TComponent>();
}
internal ref readonly TComponent GetComponentByEntityAndType<TComponent>(int entityID) where TComponent : struct
{
return ref _existingComponentStore.Get<TComponent>(entityID);

View File

@ -23,6 +23,11 @@ namespace Encompass
return _componentManager.GetExistingEntities<TComponent>();
}
protected IEnumerable<Entity> ReadEntitiesAsEnumerable<TComponent>() where TComponent : struct, IComponent
{
return _componentManager.GetExistingEntitiesAsEnumerable<TComponent>();
}
protected ref readonly Entity ReadEntity<TComponent>() where TComponent : struct, IComponent
{
return ref _componentManager.ExistingSingularEntity<TComponent>();
@ -33,6 +38,11 @@ namespace Encompass
return _componentManager.GetComponentsByType<TComponent>();
}
protected IEnumerable<TComponent> ReadComponentsAsEnumerable<TComponent>() where TComponent : struct, IComponent
{
return _componentManager.GetComponentsByTypeEnumerable<TComponent>();
}
protected ref readonly TComponent ReadComponent<TComponent>() where TComponent : struct, IComponent
{
return ref _componentManager.ExistingSingular<TComponent>();