In this below example, I've combined libgdx ashley and AI state machine. Do you think it's a good idea to handle the logic in state machine or stick on handling the data logic on System?
public enum TrollState implements State<Entity> {
MOVE_AWAY() {
@Override
public void enter(Entity entity) {
}
@Override
public void update(Entity entity) {
PositionComponent position = Mappers.position.get(entity);
...
}
@Override
public void exit(Entity entity) {
}
@Override
public boolean onMessage(Entity entity, Telegram telegram) {
if (telegram.message == 0) {
Gdx.app.log("Slime", "Waaaah, goo away, big daddy! yummmmmmy");
return true;
}
return false;
}
}
}