Skip to content

Fluid Entity Interface

Daan van Yperen edited this page Sep 13, 2016 · 18 revisions

Basic API

Obtain fluid interface

In your systems, statically import com.artemis.E. This exposes E(entityId)

Usage

Fluid interface directly exposes methods to create, remove, and access and alter components it knows about. Method calls can be chained. E(entityId).pos(5,5).angle(10).anim("monkey").

Basic calls

Access component

Pos pos = E(entityId)._pos();

Conventions:

  • Returns null if no component exists.

Access component field

given Anim .. { public Cell cell; }

Getting:

Cell cell = E(Id).animCell();

Conventions:

  • This call creates missing components to avoid NPE checks.
  • See internals below for conventions generating field getters/setters.

Access component method

given Anim .. { public Vector getXY() { .. } }

Getting:

e = E(Id);
Vector v2 = e.posXY();

Conventions:

  • This call creates missing components to avoid NPE checks.
  • See internals below for conventions generating field getters/setters.

Check component exists

E(id).hasPos()

Call overview

Conventions for components

on component Exposed as if missing comments
Pos E ::pos() create chainable
Pos E ::pos(E e2) mirror e2 chainable
Pos Pos E::_pos() null Getter.
Pos.x int E::posX() create chainable
Pos.x E E::posX(x) create getter
public Pos::set(x,y) E E::pos(x,y) create chainable
public Pos::clear() E E::posClear() create chainable
public Pos::setX(x) E E::posX(x) create chainable
public int Pos::getX() int E::posX() create getter
public Pos::setDepth(z) E E::posDepth(z) create chainable
public float Pos::getDepth() float E::posDepth() create getter
Flag (empty) Invisible E ::invisible(boolean create) see parameter components with no public fields and methods are treated as flags. Additional to E::invisible()
Flag (empty) Invisible E ::isInvisible() - Returns true if has component `false if not.
Clone this wiki locally