fix some reads
continuous-integration/drone/push Build is passing Details

pull/3/head
Evan Hemsley 2020-03-22 19:20:55 -07:00
parent ca9c9c84a3
commit 7c8154efdd
3 changed files with 39 additions and 17 deletions

View File

@ -113,6 +113,11 @@ namespace Encompass
return _upToDateComponentStore.AllEntities<TComponent>();
}
internal ref readonly Entity ExistingOrImmediateSingularEntity<TComponent>() where TComponent : struct
{
return ref _upToDateComponentStore.SingularEntity<TComponent>();
}
internal bool SomeExistingOrImmediateComponent<TComponent>() where TComponent : struct
{
return _upToDateComponentStore.Any<TComponent>();
@ -135,7 +140,7 @@ namespace Encompass
return _existingComponentStore.AllEntities<TComponent>();
}
internal ref readonly Entity SingularEntity<TComponent>() where TComponent : struct
internal ref readonly Entity ExistingSingularEntity<TComponent>() where TComponent : struct
{
return ref _existingComponentStore.SingularEntity<TComponent>();
}
@ -152,14 +157,19 @@ namespace Encompass
return _immediateComponentStore.All<TComponent>();
}
internal ref readonly TComponent ImmediateSingular<TComponent>() where TComponent : struct
{
return ref _immediateComponentStore.Singular<TComponent>();
}
internal Span<Entity> GetImmediateEntities<TComponent>() where TComponent : struct
{
return _immediateComponentStore.AllEntities<TComponent>();
}
internal ref readonly TComponent ImmediateSingular<TComponent>() where TComponent : struct
internal ref readonly Entity ImmediateSingularEntity<TComponent>() where TComponent : struct
{
return ref _immediateComponentStore.Singular<TComponent>();
return ref _immediateComponentStore.SingularEntity<TComponent>();
}
internal bool SomeImmediateComponent<TComponent>() where TComponent : struct

View File

@ -210,23 +210,10 @@ namespace Encompass
return _entityManager.EntityExists(entityID);
}
/// <summary>
/// Returns an Entity containing the specified Component type.
/// </summary>
protected ref readonly Entity ReadEntity<TComponent>() where TComponent : struct
{
return ref _componentManager.SingularEntity<TComponent>();
}
/// <summary>
/// Returns all Entities containing the specified Component type.
/// </summary>
protected Span<Entity> ReadEntities<TComponent>() where TComponent : struct
{
return ReadEntitiesHelper<TComponent>();
}
private Span<Entity> ReadEntitiesHelper<TComponent>() where TComponent : struct
{
var immediateRead = ReadImmediateTypes.Contains(typeof(TComponent));
var existingRead = ReadTypes.Contains(typeof(TComponent));
@ -248,6 +235,31 @@ namespace Encompass
}
}
/// <summary>
/// Returns an Entity containing the specified Component type.
/// </summary>
protected ref readonly Entity ReadEntity<TComponent>() where TComponent : struct
{
var immediateRead = ReadImmediateTypes.Contains(typeof(TComponent));
var existingRead = ReadTypes.Contains(typeof(TComponent));
if (existingRead && immediateRead)
{
return ref _componentManager.ExistingOrImmediateSingularEntity<TComponent>();
}
else if (existingRead)
{
return ref _componentManager.ExistingSingularEntity<TComponent>();
}
else if (immediateRead)
{
return ref _componentManager.ImmediateSingularEntity<TComponent>();
}
else
{
throw new IllegalReadException("Engine {0} tried to read undeclared Component {1}", GetType().Name, typeof(TComponent).Name);
}
}
/// <summary>
/// Returns all of the Components with the specified Component Type.
/// </summary>

View File

@ -25,7 +25,7 @@ namespace Encompass
protected ref readonly Entity ReadEntity<TComponent>() where TComponent : struct
{
return ref _componentManager.SingularEntity<TComponent>();
return ref _componentManager.ExistingSingularEntity<TComponent>();
}
protected Span<TComponent> ReadComponents<TComponent>() where TComponent : struct