add component reader methods that include entities

pull/5/head
Evan Hemsley 2019-11-13 20:08:11 -08:00
parent 3b6d473aeb
commit c994e9d7fe
1 changed files with 18 additions and 1 deletions

View File

@ -242,7 +242,15 @@ namespace Encompass
}
/// <summary>
/// Returns a Component with the specified Component Type and ID. If multiples exist, an arbitrary Component is returned.
/// Returns all of the components of the specified type including an Entity reference for each Component.
/// </summary>
protected IEnumerable<(Guid, TComponent, Entity)> ReadComponentsIncludingEntity<TComponent>() where TComponent : struct, IComponent
{
return ReadComponents<TComponent>().Select((tuple) => (tuple.Item1, tuple.Item2, GetEntityByComponentID<TComponent>(tuple.Item1)));
}
/// <summary>
/// Returns a Component with the specified Component Type. If multiples exist, an arbitrary Component is returned.
/// </summary>
protected (Guid, TComponent) ReadComponent<TComponent>() where TComponent : struct, IComponent
{
@ -266,6 +274,15 @@ namespace Encompass
}
}
/// <summary>
/// Returns a component of the specified type including its Entity reference. If multiples exist, an arbitrary Component is returned.
/// </summary>
protected (Guid, TComponent, Entity) ReadComponentIncludingEntity<TComponent>() where TComponent : struct, IComponent
{
var (id, component) = ReadComponent<TComponent>();
return (id, component, GetEntityByComponentID<TComponent>(id));
}
/// <summary>
/// Returns true if any Component with the specified Component Type exists.
/// </summary>