In the below code, there's a FSM for CharacterState
that will be handled also in CharacterSystem
. The problem was, I don't know what component should hold movements data to process in CharacterState
or CharacterSystem
public class CharacterState implements State<Entity> {
STANDING,
WALKING,
RUNNING,
IN_PAIN,
DEAD
}
public enum Movements {
STAND_STILL,
MOVE_UP,
MOVE_DOWN,
MOVE_LEFT,
MOVE_RIGHT,
MOVE_UP_RIGHT,
MOVE_UP_LEFT,
MOVE_DOWN_RIGHT,
MOVE_DOWN_LEFT;
}
CharacterComponent implements Component {
Movements movement
}
MovementComponent implements Component {
Movements movement
}
AnimationComponent implements Component {
IntMap<Animation> map = new IntMap<Animation>();
}
animation.map.put(Movements.MOVE_UP.order, ASSET.CHAR_MOVE_UP);