Is there any way I can program (in Java or Python, but open to other solutions) some game logic based on events, timed and sent by player input, without dealing with it inside the game loop, by having a game state that has a number of scripts listening for events, and those scripts can themselves fire events that change the game states and by consequence the scripts listening for events? An example bellow
class BombScript {
private GameObject bombReference;
void bombDefused() {
// change the script listening for events
bombReference.destroy();
}
void bombExplode() {
// launch some events, change the script listening for events
stopListeningForEvent("bombDefused");
bombReference.destroy();
sendEvent("bombExplode", bombReference);
}
void bombPlanted() {
// if somehow the server receives a defuse command
onEvent("bombDefused").execute(bombDefused);
// else, if 6 seconds pass without an "bombDefused" event
onTimeout(6).execute(bombExplode);
}
}
I'm having trouble imagining a concrete implementation for that, specifically the timed based "if/else"