mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'treeco/build-mode-fixes' into 'master'
Swapped block placement and destruction buttons See merge request veloren/veloren!995
This commit is contained in:
commit
bb85dab281
@ -180,22 +180,17 @@ impl PlayState for SessionState {
|
|||||||
|
|
||||||
let cam_dist = cam_ray.0;
|
let cam_dist = cam_ray.0;
|
||||||
|
|
||||||
if let Ok(Some(_)) = cam_ray.1 {
|
match cam_ray.1 {
|
||||||
// The ray hit something, is it within pickup range?
|
Ok(Some(_))
|
||||||
let select_pos = if player_pos.distance_squared(cam_pos + cam_dir * cam_dist)
|
if player_pos.distance_squared(cam_pos + cam_dir * cam_dist)
|
||||||
<= MAX_PICKUP_RANGE_SQR
|
<= MAX_PICKUP_RANGE_SQR =>
|
||||||
{
|
{
|
||||||
Some((cam_pos + cam_dir * cam_dist).map(|e| e.floor() as i32))
|
(
|
||||||
} else {
|
Some((cam_pos + cam_dir * (cam_dist - 0.01)).map(|e| e.floor() as i32)),
|
||||||
None
|
Some((cam_pos + cam_dir * cam_dist).map(|e| e.floor() as i32)),
|
||||||
};
|
)
|
||||||
|
},
|
||||||
(
|
_ => (None, None),
|
||||||
Some((cam_pos + cam_dir * (cam_dist - 0.01)).map(|e| e.floor() as i32)),
|
|
||||||
select_pos,
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
(None, None)
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -223,7 +218,7 @@ impl PlayState for SessionState {
|
|||||||
},
|
},
|
||||||
Event::InputUpdate(GameInput::Primary, state) => {
|
Event::InputUpdate(GameInput::Primary, state) => {
|
||||||
// Check the existence of CanBuild component. If it's here, use LMB to
|
// Check the existence of CanBuild component. If it's here, use LMB to
|
||||||
// place blocks, if not, use it to attack
|
// break blocks, if not, use it to attack
|
||||||
let mut client = self.client.borrow_mut();
|
let mut client = self.client.borrow_mut();
|
||||||
if state
|
if state
|
||||||
&& client
|
&& client
|
||||||
@ -232,8 +227,8 @@ impl PlayState for SessionState {
|
|||||||
.get(client.entity())
|
.get(client.entity())
|
||||||
.is_some()
|
.is_some()
|
||||||
{
|
{
|
||||||
if let Some(build_pos) = build_pos {
|
if let Some(select_pos) = select_pos {
|
||||||
client.place_block(build_pos, self.selected_block);
|
client.remove_block(select_pos);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.inputs.primary.set_state(state);
|
self.inputs.primary.set_state(state);
|
||||||
@ -252,8 +247,8 @@ impl PlayState for SessionState {
|
|||||||
.get(client.entity())
|
.get(client.entity())
|
||||||
.is_some()
|
.is_some()
|
||||||
{
|
{
|
||||||
if let Some(select_pos) = select_pos {
|
if let Some(build_pos) = build_pos {
|
||||||
client.remove_block(select_pos);
|
client.place_block(build_pos, self.selected_block);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.inputs.secondary.set_state(state);
|
self.inputs.secondary.set_state(state);
|
||||||
|
Loading…
Reference in New Issue
Block a user