35 lines
1 KiB
C#
35 lines
1 KiB
C#
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
|
||
|
namespace Gallium
|
||
|
{
|
||
|
public static class WhereAllComponentsExtensions
|
||
|
{
|
||
|
public static IEnumerable<Entity> WhereAllComponents<T1>(
|
||
|
this IEnumerable<Entity> entities)
|
||
|
{
|
||
|
return entities.Where(x => x.Has<T1>());
|
||
|
}
|
||
|
|
||
|
public static IEnumerable<Entity> WhereAllComponents<T1, T2>(
|
||
|
this IEnumerable<Entity> entities)
|
||
|
{
|
||
|
return entities.Where(x => x.Has<T1>() && x.Has<T2>());
|
||
|
}
|
||
|
|
||
|
public static IEnumerable<Entity> WhereAllComponents<T1, T2, T3>(
|
||
|
this IEnumerable<Entity> entities)
|
||
|
{
|
||
|
return entities.Where(
|
||
|
x => x.Has<T1>() && x.Has<T2>() && x.Has<T3>());
|
||
|
}
|
||
|
|
||
|
public static IEnumerable<Entity> WhereAllComponents<T1, T2, T3, T4>(
|
||
|
this IEnumerable<Entity> entities)
|
||
|
{
|
||
|
return entities.Where(
|
||
|
x => x.Has<T1>() && x.Has<T2>() && x.Has<T3>() && x.Has<T4>());
|
||
|
}
|
||
|
}
|
||
|
}
|