API Docs for:
Show:

Aspect Class

Defined in: ../src/Aspect.js:4
Module: ArtemiJS

An Aspects is used by systems as a matcher against entities, to check if a system is interested in an entity. 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)

Methods

all

(
  • type
)
chainable

Defined in ../src/Aspect.js:74

Returns an aspect where an entity must possess all of the specified component types.

Parameters:

  • type String multiple

    a required component type

exclude

(
  • type
)
chainable

Defined in ../src/Aspect.js:90

Excludes all of the specified component types from the aspect. A system will not be interested in an entity that possesses one of the specified exclusion component types.

Parameters:

  • type String multiple

    component type to exclude

getAllSet

() ArtemiJS.Utils.Bag

Defined in ../src/Aspect.js:50

Returns:

ArtemiJS.Utils.Bag:

getAspectForAll

(
  • type
)
ArtemiJS.Aspect

Creates an aspect where an entity must possess all of the specified component types.

Parameters:

  • type String multiple

    a required component type

Returns:

ArtemiJS.Aspect: an aspect that can be matched against entities

getAspectForOne

(
  • type
)
ArtemiJS.Aspect

Creates an aspect where an entity must possess one of the specified component types.

Parameters:

  • type String multiple

    one of the types the entity must possess

Returns:

ArtemiJS.Aspect: an aspect that can be matched against entities

getEmpty

() ArtemiJS.Aspect

Creates and returns an empty aspect. 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);

Returns:

ArtemiJS.Aspect: an empty Aspect that will reject all entities.

getExclusionSet

() ArtemiJS.Utils.Bag

Defined in ../src/Aspect.js:58

Returns:

ArtemiJS.Utils.Bag:

getOneSet

() ArtemiJS.Utils.Bag

Defined in ../src/Aspect.js:66

Returns:

ArtemiJS.Utils.Bag:

one

(
  • type
)
chainable

Returns an aspect where an entity must possess one of the specified component types.

Parameters:

  • type String multiple

    one of the types the entity must possess

Properties

allSet

ArtemiJS.Utils.Bag private

Defined in ../src/Aspect.js:29

exclusionSet

ArtemiJS.Utils.Bag private

Defined in ../src/Aspect.js:36

exclusionSet

ArtemiJS.Utils.Bag private

Defined in ../src/Aspect.js:43