fix: game root now only spawns player if scene is assigned in game mode

stripped
Sara 2024-05-21 11:57:21 +02:00
parent 044164fa4b
commit 51f18f45b8
1 changed files with 9 additions and 7 deletions

View File

@ -171,6 +171,7 @@ void GameRoot3D::set_game_mode(Ref<GameMode> prototype) {
// .. 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(); this->game_mode->_begin();
if(this->game_mode->get_player_scene().is_valid()) {
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);
@ -179,6 +180,7 @@ void GameRoot3D::set_game_mode(Ref<GameMode> prototype) {
new_player_id = this->find_empty_player_slot(); new_player_id = this->find_empty_player_slot();
} while(new_player_id != 0); } while(new_player_id != 0);
} }
}
Ref<GameMode> GameRoot3D::get_game_mode() const { Ref<GameMode> GameRoot3D::get_game_mode() const {
return this->game_mode; return this->game_mode;