using System; using System.Collections.Generic; using EcsRx.Components; using EcsRx.Entities; namespace EcsRx.Groups { public class GroupBuilder { private List _withComponents; private List _withoutComponents; private Predicate _predicate; public GroupBuilder() { _withComponents = new List(); _withoutComponents = new List(); } public GroupBuilder Create() { _withComponents = new List(); _withoutComponents = new List(); return this; } public GroupBuilder WithComponent() where T : class, IComponent { _withComponents.Add(typeof(T)); return this; } public GroupBuilder WithoutComponent() where T : class, IComponent { _withoutComponents.Add(typeof(T)); return this; } public GroupBuilder WithPredicate(Predicate predicate) { _predicate = predicate; return this; } public IGroup Build() { return _predicate != null ? new GroupWithPredicate(_predicate, _withComponents, _withoutComponents) : new Group(_withComponents, _withoutComponents); } } }