Entitas  0.40.0
Entitas is a super fast Entity Component System (ECS) Framework specifically made for C# and Unity
ContextExtension.cs
1 namespace Entitas {
2 
3  public static class ContextExtension {
4 
5  /// Returns all entities matching the specified matcher.
6  public static TEntity[] GetEntities<TEntity>(this IContext<TEntity> context, IMatcher<TEntity> matcher)
7  where TEntity : class, IEntity, new() {
8  return context.GetGroup(matcher).GetEntities();
9  }
10 
11  /// Creates an Collector.
12  public static Collector<TEntity> CreateCollector<TEntity>(this IContext<TEntity> context, IMatcher<TEntity> matcher, GroupEvent groupEvent = GroupEvent.Added)
13  where TEntity : class, IEntity, new() {
14  return new Collector<TEntity>(context.GetGroup(matcher), groupEvent);
15  }
16 
17  /// Creates a new entity and adds copies of all
18  /// specified components to it.
19  /// If replaceExisting is true it will replace exisintg components.
20  public static TEntity CloneEntity<TEntity>(this IContext<TEntity> context,
21  IEntity entity,
22  bool replaceExisting = false,
23  params int[] indices)
24  where TEntity : class, IEntity, new() {
25  var target = context.CreateEntity();
26  entity.CopyTo(target, replaceExisting, indices);
27  return target;
28  }
29  }
30 }
static TEntity CloneEntity< TEntity >(this IContext< TEntity > context, IEntity entity, bool replaceExisting=false, params int[] indices)
static TEntity [] GetEntities< TEntity >(this IContext< TEntity > context, IMatcher< TEntity > matcher)
Returns all entities matching the specified matcher.
static Collector< TEntity > CreateCollector< TEntity >(this IContext< TEntity > context, IMatcher< TEntity > matcher, GroupEvent groupEvent=GroupEvent.Added)
Creates an Collector.