Fix lobby background not updating on join

This commit is contained in:
Sofia 2026-08-06 17:40:44 +03:00
parent e015978b9f
commit aa30e21ad1

View File

@ -36,6 +36,8 @@ impl INode3D for LobbyWorld {
self.spawn_player(player.id());
}
self.change_map(game.bind().selected_map_idx);
game.signals()
.on_new_player()
.connect_other(self, Self::on_new_player);
@ -61,11 +63,11 @@ impl INode3D for LobbyWorld {
impl LobbyWorld {
fn change_map(&mut self, map: u8) {
if let Some(mut background) = self.background.take() {
background.queue_free();
}
self.run_deferred(move |s| {
if let Some(mut background) = s.background.take() {
background.queue_free();
}
if let Some(map) = GameManager::singleton().bind().maps.get(map as usize) {
if let Some(scene) = &map.bind().static_scene {
let mut background = scene.instantiate_as::<StaticMap>();