feat: expose methods for game state event handling

This commit is contained in:
2021-05-18 14:14:23 +02:00
parent 2d33f150a8
commit 9fa5c554ef
4 changed files with 63 additions and 9 deletions

View File

@ -2,6 +2,7 @@ package uulm.teamname.marvelous.gamelibrary.gamelogic;
import uulm.teamname.marvelous.gamelibrary.IntVector2;
import uulm.teamname.marvelous.gamelibrary.events.Event;
import uulm.teamname.marvelous.gamelibrary.events.EventType;
import uulm.teamname.marvelous.gamelibrary.requests.Request;
import java.util.Observer;
@ -66,6 +67,22 @@ public class GameInstance {
return manager.processRequests(requests, false);
}
/**
* Produces a {@link EventType#GamestateEvent} for the current {@link GameState}.
* @return The resulting event
*/
public Event getGameStateEvent() {
return GameLogic.buildGameStateEvent(_state);
}
/**
* Restores the current {@link GameState} based on the given one.
* @param state The state to restore from
*/
public void setGameState(GameState state) {
_state.restore(state);
}
/**
* Applies an array of {@link Event}s to the game state.
* @param events The events to apply.