public class Aspect extends Object
Aspects define what sort of component types an entity must possess, or not possess.
This creates an aspect where an entity must possess A and B and C:
Aspect.getAspectForAll(A.class, B.class, C.class)
This creates an aspect where an entity must possess A and B and C, but must
not possess U or V.
Aspect.getAspectForAll(A.class, B.class, C.class).exclude(U.class, V.class)
This creates an aspect where an entity must possess A and B and C, but must
not possess U or V, but must possess one of X or Y or Z.
Aspect.getAspectForAll(A.class, B.class, C.class).exclude(U.class, V.class).one(X.class, Y.class, Z.class)
You can create and compose aspects in many ways:
Aspect.getEmpty().one(X.class, Y.class, Z.class).all(A.class, B.class, C.class).exclude(U.class, V.class)
is the same as:
Aspect.getAspectForAll(A.class, B.class, C.class).exclude(U.class, V.class).one(X.class, Y.class, Z.class)
| Modifier and Type | Method and Description |
|---|---|
Aspect |
all(Class<? extends Component>... types)
Returns an aspect where an entity must possess all of the specified
component types.
|
Aspect |
all(Collection<Class<? extends Component>> types)
Returns an aspect where an entity must possess all of the specified
component types.
|
Aspect |
exclude(Class<? extends Component>... types)
Excludes all of the specified component types from the aspect.
|
Aspect |
exclude(Collection<Class<? extends Component>> types)
Excludes all of the specified component types from the aspect.
|
BitSet |
getAllSet()
Get a BitSet containing bits of components the entity must all possess.
|
static Aspect |
getAspectForAll(Class<? extends Component>... types)
Creates an aspect where an entity must possess all of the specified
component types.
|
static Aspect |
getAspectForOne(Class<? extends Component>... types)
Creates an aspect where an entity must possess one of the specified
component types.
|
static Aspect |
getEmpty()
Creates and returns an empty aspect.
|
BitSet |
getExclusionSet()
Get a BitSet containing bits of components the entity must not possess.
|
BitSet |
getOneSet()
Get a BitSet containing bits of components of which the entity must
possess atleast one.
|
void |
initialize(World world) |
boolean |
isInterested(BitSet componentBits)
Returns whether this Aspect would accept the given set.
|
boolean |
isInterested(Entity e)
Returns whether this Aspect would accept the given Entity.
|
Aspect |
one(Class<? extends Component>... types)
Returns an aspect where an entity must possess one of the specified
component types.
|
Aspect |
one(Collection<Class<? extends Component>> types)
Returns an aspect where an entity must possess one of the specified
component types.
|
public void initialize(World world)
public BitSet getAllSet()
public BitSet getExclusionSet()
public BitSet getOneSet()
public boolean isInterested(Entity e)
public boolean isInterested(BitSet componentBits)
public Aspect all(Class<? extends Component>... types)
types - a required component typepublic Aspect all(Collection<Class<? extends Component>> types)
types - a required component typepublic Aspect exclude(Class<? extends Component>... types)
A system will not be interested in an entity that possesses one of the specified exclusion component types.
types - component type to excludepublic Aspect exclude(Collection<Class<? extends Component>> types)
A system will not be interested in an entity that possesses one of the specified exclusion component types.
types - component type to excludepublic Aspect one(Class<? extends Component>... types)
types - one of the types the entity must possesspublic Aspect one(Collection<Class<? extends Component>> types)
types - one of the types the entity must possesspublic static Aspect getAspectForAll(Class<? extends Component>... types)
types - a required component typepublic static Aspect getAspectForOne(Class<? extends Component>... types)
types - one of the types the entity must possesspublic static Aspect getEmpty()
This can be used if you want a system that processes no entities, but still gets invoked. Typical usages is when you need to create special purpose systems for debug rendering, like rendering FPS, how many entities are active in the world, etc.
You can also use the all, one and exclude methods on this aspect, so if
you wanted to create a system that processes only entities possessing
just one of the components A or B or C, then you can do:
Aspect.getEmpty().one(A,B,C);
Copyright © 2014. All Rights Reserved.