fix some reads
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
ca9c9c84a3
commit
7c8154efdd
|
@ -113,6 +113,11 @@ namespace Encompass
|
||||||
return _upToDateComponentStore.AllEntities<TComponent>();
|
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
|
internal bool SomeExistingOrImmediateComponent<TComponent>() where TComponent : struct
|
||||||
{
|
{
|
||||||
return _upToDateComponentStore.Any<TComponent>();
|
return _upToDateComponentStore.Any<TComponent>();
|
||||||
|
@ -135,7 +140,7 @@ namespace Encompass
|
||||||
return _existingComponentStore.AllEntities<TComponent>();
|
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>();
|
return ref _existingComponentStore.SingularEntity<TComponent>();
|
||||||
}
|
}
|
||||||
|
@ -152,14 +157,19 @@ namespace Encompass
|
||||||
return _immediateComponentStore.All<TComponent>();
|
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
|
internal Span<Entity> GetImmediateEntities<TComponent>() where TComponent : struct
|
||||||
{
|
{
|
||||||
return _immediateComponentStore.AllEntities<TComponent>();
|
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
|
internal bool SomeImmediateComponent<TComponent>() where TComponent : struct
|
||||||
|
|
|
@ -210,23 +210,10 @@ namespace Encompass
|
||||||
return _entityManager.EntityExists(entityID);
|
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>
|
/// <summary>
|
||||||
/// Returns all Entities containing the specified Component type.
|
/// Returns all Entities containing the specified Component type.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected Span<Entity> ReadEntities<TComponent>() where TComponent : struct
|
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 immediateRead = ReadImmediateTypes.Contains(typeof(TComponent));
|
||||||
var existingRead = ReadTypes.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>
|
/// <summary>
|
||||||
/// Returns all of the Components with the specified Component Type.
|
/// Returns all of the Components with the specified Component Type.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace Encompass
|
||||||
|
|
||||||
protected ref readonly Entity ReadEntity<TComponent>() where TComponent : struct
|
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
|
protected Span<TComponent> ReadComponents<TComponent>() where TComponent : struct
|
||||||
|
|
Loading…
Reference in New Issue