feat: GameRoot now calls GameMode::_begin and _end

stripped
Sara 2024-03-21 22:49:48 +01:00
parent a8153c3ec4
commit af4208f3b7
1 changed files with 2 additions and 0 deletions

View File

@ -122,6 +122,7 @@ void GameRoot::set_game_mode(Ref<GameMode> prototype) {
// allow "unsetting" the gamemode by passing an invalid gamemode // allow "unsetting" the gamemode by passing an invalid gamemode
// shorthand for this behaviour is reset_game_mode // shorthand for this behaviour is reset_game_mode
if(prototype.is_null() || !prototype.is_valid()) { if(prototype.is_null() || !prototype.is_valid()) {
this->game_mode->_end();
this->game_mode.unref(); this->game_mode.unref();
return; return;
} }
@ -129,6 +130,7 @@ void GameRoot::set_game_mode(Ref<GameMode> prototype) {
this->game_mode = prototype->duplicate(false); this->game_mode = prototype->duplicate(false);
// .. except for the game state, which should be cloned as well // .. except for the game state, which should be cloned as well
this->game_mode->set_game_state(prototype->get_game_state()->duplicate(false)); this->game_mode->set_game_state(prototype->get_game_state()->duplicate(false));
this->game_mode->_begin();
uint32_t new_player_id = this->find_empty_player_slot(); uint32_t new_player_id = this->find_empty_player_slot();
do { do {
IPlayer *player = this->spawn_player(new_player_id); IPlayer *player = this->spawn_player(new_player_id);