add component reader methods that include entities
parent
3b6d473aeb
commit
c994e9d7fe
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue