diff --git a/rust/src/game_manager.rs b/rust/src/game_manager.rs index 0232414..4a82021 100644 --- a/rust/src/game_manager.rs +++ b/rust/src/game_manager.rs @@ -176,7 +176,7 @@ pub struct Game { player_counter: u16, pub self_id: Option, pub players: Vec, - game_started: bool, + pub game_started: bool, pub current_map: Option>, pub world_ball: Option>, @@ -299,6 +299,8 @@ impl Game { } pub fn finish_game(&mut self) { + self.game_started = false; + for player in &mut self.players { if let Some(mut character) = player.character.take() { character.queue_free(); @@ -320,7 +322,6 @@ impl Game { ball.queue_free(); } self.current_map.take(); - self.game_started = false; self.run_deferred(|s| { if let Some(peer) = &mut NetworkManager::singleton().bind_mut().peer diff --git a/rust/src/player.rs b/rust/src/player.rs index 54374ee..f0b4b6d 100644 --- a/rust/src/player.rs +++ b/rust/src/player.rs @@ -530,7 +530,11 @@ impl ICharacterBody3D for LocalPlayer { } fn exit_tree(&mut self) { - self.set_lock(false); + if let Some(game) = Game::singleton() + && !game.bind().game_started + { + self.set_lock(false); + } } }