Fix camera unlocking upon death
This commit is contained in:
parent
ec4a91722c
commit
5e0ff4336a
@ -176,7 +176,7 @@ pub struct Game {
|
|||||||
player_counter: u16,
|
player_counter: u16,
|
||||||
pub self_id: Option<u16>,
|
pub self_id: Option<u16>,
|
||||||
pub players: Vec<Player>,
|
pub players: Vec<Player>,
|
||||||
game_started: bool,
|
pub game_started: bool,
|
||||||
|
|
||||||
pub current_map: Option<Gd<Map>>,
|
pub current_map: Option<Gd<Map>>,
|
||||||
pub world_ball: Option<Gd<Ball>>,
|
pub world_ball: Option<Gd<Ball>>,
|
||||||
@ -299,6 +299,8 @@ impl Game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn finish_game(&mut self) {
|
pub fn finish_game(&mut self) {
|
||||||
|
self.game_started = false;
|
||||||
|
|
||||||
for player in &mut self.players {
|
for player in &mut self.players {
|
||||||
if let Some(mut character) = player.character.take() {
|
if let Some(mut character) = player.character.take() {
|
||||||
character.queue_free();
|
character.queue_free();
|
||||||
@ -320,7 +322,6 @@ impl Game {
|
|||||||
ball.queue_free();
|
ball.queue_free();
|
||||||
}
|
}
|
||||||
self.current_map.take();
|
self.current_map.take();
|
||||||
self.game_started = false;
|
|
||||||
|
|
||||||
self.run_deferred(|s| {
|
self.run_deferred(|s| {
|
||||||
if let Some(peer) = &mut NetworkManager::singleton().bind_mut().peer
|
if let Some(peer) = &mut NetworkManager::singleton().bind_mut().peer
|
||||||
|
|||||||
@ -530,8 +530,12 @@ impl ICharacterBody3D for LocalPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn exit_tree(&mut self) {
|
fn exit_tree(&mut self) {
|
||||||
|
if let Some(game) = Game::singleton()
|
||||||
|
&& !game.bind().game_started
|
||||||
|
{
|
||||||
self.set_lock(false);
|
self.set_lock(false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[godot_api]
|
#[godot_api]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user