feat: changed ordering of signals in game root

main
Sara 2024-03-22 00:14:29 +01:00
parent d095d9f2de
commit f0bddcf074
1 changed files with 6 additions and 5 deletions

View File

@ -83,9 +83,9 @@ bool GameRoot::initialize_player(IPlayer *player, uint32_t id) {
found.second = player;
// set player id
player->player_id = id;
this->emit_signal("player_spawned", player->to_node());
this->add_child(player->to_node());
player->setup_player_input(found.first);
this->emit_signal("player_spawned", player->to_node());
return true;
}
@ -124,7 +124,8 @@ void GameRoot::set_game_mode(Ref<GameMode> prototype) {
// allow "unsetting" the gamemode by passing an invalid gamemode
// shorthand for this behaviour is reset_game_mode
if(prototype.is_null() || !prototype.is_valid()) {
this->game_mode->_end();
if(!this->game_mode.is_null() && this->game_mode.is_valid())
this->game_mode->_end();
this->game_mode.unref();
return;
}
@ -181,14 +182,14 @@ Level3D *GameRoot3D::load_level_at(Ref<PackedScene> level, Transform3D at) {
UtilityFunctions::push_error("Unexpected failure to instantiate level scene '", level->get_path(), "'.");
return nullptr;
}
// store and add to tree at desired transform
this->add_child(instance);
instance->set_global_transform(at);
this->levels.insert(level->get_path(), instance);
// store and add to tree at desired transform
// if this is the first level containing a game mode currently active use it's gamemode as a prototype
if(this->game_mode.is_null()) {
this->set_game_mode(instance->get_game_mode_prototype());
}
this->add_child(instance);
instance->set_global_transform(at);
return instance;
}