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.all(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.all(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.all(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.one(X.class, Y.class, Z.class).all(A.class, B.class, C.class).exclude(U.class, V.class)
is the same as:
Aspect.all(A.class, B.class, C.class).exclude(U.class, V.class).one(X.class, Y.class, Z.class)
Modifier and Type | Class and Description |
---|---|
static class |
Aspect.Builder
Constructs instances of
Aspect . |
Modifier and Type | Method and Description |
---|---|
static Aspect.Builder |
all()
Returns an aspect that matches all entities.
|
static Aspect.Builder |
all(Class<? extends Component>... types)
Returns an aspect where an entity must possess all of the specified
component types.
|
static Aspect.Builder |
all(Collection<Class<? extends Component>> types)
Returns an aspect where an entity must possess all of the specified
component types.
|
static Aspect.Builder |
exclude(Class<? extends Component>... types)
Excludes all of the specified component types from the aspect.
|
static Aspect.Builder |
exclude(Collection<Class<? extends Component>> types)
Excludes all of the specified component types from the aspect.
|
BitVector |
getAllSet()
Get a BitVector containing bits of components the entity must all possess.
|
BitVector |
getExclusionSet()
Get a BitVector containing bits of components the entity must not possess.
|
BitVector |
getOneSet()
Get a BitVector containing bits of components of which the entity must
possess atleast one.
|
boolean |
isInterested(BitVector componentBits)
Returns whether this Aspect would accept the given set.
|
boolean |
isInterested(Entity e)
Returns whether this Aspect would accept the given Entity.
|
static Aspect.Builder |
one(Class<? extends Component>... types)
Returns an aspect where an entity must possess one of the specified
component types.
|
static Aspect.Builder |
one(Collection<Class<? extends Component>> types)
Returns an aspect where an entity must possess one of the specified
component types.
|
public BitVector getAllSet()
public BitVector getExclusionSet()
public BitVector getOneSet()
public boolean isInterested(Entity e)
public boolean isInterested(BitVector componentBits)
public static Aspect.Builder all()
@SafeVarargs public static Aspect.Builder all(Class<? extends Component>... types)
types
- a required component typepublic static Aspect.Builder all(Collection<Class<? extends Component>> types)
types
- a required component type@SafeVarargs public static Aspect.Builder 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 static Aspect.Builder 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 exclude@SafeVarargs public static Aspect.Builder one(Class<? extends Component>... types)
types
- one of the types the entity must possesspublic static Aspect.Builder one(Collection<Class<? extends Component>> types)
types
- one of the types the entity must possessCopyright © 2019. All rights reserved.