use of com.ebicep.warlords.game.state.State in project Warlords by ebicep.
the class Game method run.
@Override
public void run() {
if (this.nextState == null && this.state != null) {
this.nextState = this.state.run();
}
while (this.nextState != null) {
for (GameAddon addon : this.addons) {
nextState = addon.stateWillChange(this, this.state, nextState);
if (nextState == null) {
return;
}
}
if (this.state != null) {
this.state.end();
}
State newState = nextState == null ? new ClosedState(this) : nextState;
nextState = null;
// System.out.println("DEBUG OLD TO NEW STATE");
// this.printDebuggingInformation();
State oldState = this.state;
this.state = newState;
newState.begin();
for (GameAddon addon : this.addons) {
addon.stateHasChanged(this, oldState, newState);
}
}
}
Aggregations