From 356f5cb47a18895b5f453a9e756fa443a0f6932b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Korg=C3=B3l?= Date: Thu, 4 Jul 2019 19:25:09 +0200 Subject: [PATCH 1/3] Fix not being able to respawn in build mode --- voxygen/src/session.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index 6aee2e34ef..d5f4fb0716 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -105,6 +105,7 @@ impl PlayState for SessionState { // Check the existence of CanBuild component. If it's here, use LMB to // place blocks, if not, use it to attack if state { + self.controller.respawn = state; let mut client = self.client.borrow_mut(); if client .state() @@ -131,8 +132,6 @@ impl PlayState for SessionState { } else { if let ClientState::Character = current_client_state { self.controller.attack = state - } else { - self.controller.respawn = state; // TODO: Don't do both } } } else { From e267ac7ed4b77be376e4b398877766dc0fd889b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Korg=C3=B3l?= Date: Thu, 4 Jul 2019 19:33:59 +0200 Subject: [PATCH 2/3] Resolve discussion --- voxygen/src/session.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index d5f4fb0716..63f1d794b2 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -105,7 +105,11 @@ impl PlayState for SessionState { // Check the existence of CanBuild component. If it's here, use LMB to // place blocks, if not, use it to attack if state { - self.controller.respawn = state; + // Check if the player is dead or not + if current_client_state != ClientState::Character { + self.controller.respawn = state; + } + let mut client = self.client.borrow_mut(); if client .state() From 203b3d4e76fb9c03c0c90fc03fe7401eeebe5bfc Mon Sep 17 00:00:00 2001 From: timokoesters Date: Thu, 4 Jul 2019 20:14:14 +0200 Subject: [PATCH 3/3] Fix attacking bug --- voxygen/src/session.rs | 49 +++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index 63f1d794b2..216632fd03 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -102,47 +102,38 @@ impl PlayState for SessionState { return PlayStateResult::Shutdown; } Event::InputUpdate(GameInput::Attack, state) => { + self.controller.respawn = state; // TODO: Move this into separate GameInput + // Check the existence of CanBuild component. If it's here, use LMB to // place blocks, if not, use it to attack - if state { - // Check if the player is dead or not - if current_client_state != ClientState::Character { - self.controller.respawn = state; - } - - let mut client = self.client.borrow_mut(); - if client + let mut client = self.client.borrow_mut(); + if state + && client .state() .read_storage::() .get(client.entity()) .is_some() - { - let cam_pos = self.scene.camera().compute_dependents(&client).2; - let cam_dir = - (self.scene.camera().get_focus_pos() - cam_pos).normalized(); + { + let cam_pos = self.scene.camera().compute_dependents(&client).2; + let cam_dir = + (self.scene.camera().get_focus_pos() - cam_pos).normalized(); - let (d, b) = { - let terrain = client.state().terrain(); - let ray = - terrain.ray(cam_pos, cam_pos + cam_dir * 100.0).cast(); - (ray.0, if let Ok(Some(_)) = ray.1 { true } else { false }) - }; + let (d, b) = { + let terrain = client.state().terrain(); + let ray = terrain.ray(cam_pos, cam_pos + cam_dir * 100.0).cast(); + (ray.0, if let Ok(Some(_)) = ray.1 { true } else { false }) + }; - if b { - let pos = - (cam_pos + cam_dir * (d - 0.01)).map(|e| e.floor() as i32); - client.place_block(pos, Block::new(1, Rgb::broadcast(255))); // TODO: Handle block color with a command - } - } else { - if let ClientState::Character = current_client_state { - self.controller.attack = state - } + if b { + let pos = + (cam_pos + cam_dir * (d - 0.01)).map(|e| e.floor() as i32); + client.place_block(pos, Block::new(1, Rgb::broadcast(255))); // TODO: Handle block color with a command } } else { - self.controller.attack = state; - self.controller.respawn = state; + self.controller.attack = state } } + Event::InputUpdate(GameInput::SecondAttack, state) => { if state { let mut client = self.client.borrow_mut();