mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix attacking bug
This commit is contained in:
parent
e267ac7ed4
commit
203b3d4e76
@ -102,16 +102,13 @@ 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
|
||||
if state
|
||||
&& client
|
||||
.state()
|
||||
.read_storage::<comp::CanBuild>()
|
||||
.get(client.entity())
|
||||
@ -123,8 +120,7 @@ impl PlayState for SessionState {
|
||||
|
||||
let (d, b) = {
|
||||
let terrain = client.state().terrain();
|
||||
let ray =
|
||||
terrain.ray(cam_pos, cam_pos + cam_dir * 100.0).cast();
|
||||
let ray = terrain.ray(cam_pos, cam_pos + cam_dir * 100.0).cast();
|
||||
(ray.0, if let Ok(Some(_)) = ray.1 { true } else { false })
|
||||
};
|
||||
|
||||
@ -134,15 +130,10 @@ impl PlayState for SessionState {
|
||||
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
|
||||
}
|
||||
}
|
||||
} else {
|
||||
self.controller.attack = state;
|
||||
self.controller.respawn = state;
|
||||
}
|
||||
}
|
||||
|
||||
Event::InputUpdate(GameInput::SecondAttack, state) => {
|
||||
if state {
|
||||
let mut client = self.client.borrow_mut();
|
||||
|
Loading…
Reference in New Issue
Block a user