Search in sources :

Example 1 with State

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);
        }
    }
}
Also used : State(com.ebicep.warlords.game.state.State) ClosedState(com.ebicep.warlords.game.state.ClosedState) ClosedState(com.ebicep.warlords.game.state.ClosedState)

Aggregations

ClosedState (com.ebicep.warlords.game.state.ClosedState)1 State (com.ebicep.warlords.game.state.State)1