public void setCurrentState(AIState currentState) { try { if (currentState.getClass() == this.currentState.getClass()) return; if (this.currentState != null) doStateAction(this.currentState.onExit(this)); this.currentState = currentState; doStateAction(currentState.onEnter(this)); } catch (Exception e) { e.printStackTrace(); } }
public void scheduleRecovery() { scheduler.schedule( () -> { try { doStateAction(currentState.recover(AIActor.this)); } catch (Exception e) { e.printStackTrace(); } }, 2000, TimeUnit.MILLISECONDS); }
public void scheduleMovement() { scheduler.schedule( () -> { try { doStateAction(currentState.move(AIActor.this)); } catch (Exception e) { e.printStackTrace(); } }, 500, TimeUnit.MILLISECONDS); }