mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Prefers picking up the highlighted item to the closest item
This commit is contained in:
parent
e382e992bd
commit
712152740f
@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Animation and terrain math were switched to use SIMD where possible, improving performance.
|
||||
- The way we cache glyphs was refactored, fixed, and optimized.
|
||||
- Colors for models and figures were adjusted to account for the saturation hack.
|
||||
- Fixed a bug where the closest item would be picked up instead of a selected item
|
||||
|
||||
### Removed
|
||||
|
||||
|
@ -496,19 +496,22 @@ impl PlayState for SessionState {
|
||||
.copied();
|
||||
|
||||
if let Some(player_pos) = player_pos {
|
||||
let entity = (
|
||||
&client.state().ecs().entities(),
|
||||
&client.state().ecs().read_storage::<comp::Pos>(),
|
||||
&client.state().ecs().read_storage::<comp::Item>(),
|
||||
)
|
||||
.join()
|
||||
.filter(|(_, pos, _)| {
|
||||
pos.0.distance_squared(player_pos.0) < MAX_PICKUP_RANGE_SQR
|
||||
})
|
||||
.min_by_key(|(_, pos, _)| {
|
||||
(pos.0.distance_squared(player_pos.0) * 1000.0) as i32
|
||||
})
|
||||
.map(|(entity, _, _)| entity);
|
||||
let entity = self.target_entity.or_else(|| {
|
||||
(
|
||||
&client.state().ecs().entities(),
|
||||
&client.state().ecs().read_storage::<comp::Pos>(),
|
||||
&client.state().ecs().read_storage::<comp::Item>(),
|
||||
)
|
||||
.join()
|
||||
.filter(|(_, pos, _)| {
|
||||
pos.0.distance_squared(player_pos.0)
|
||||
< MAX_PICKUP_RANGE_SQR
|
||||
})
|
||||
.min_by_key(|(_, pos, _)| {
|
||||
(pos.0.distance_squared(player_pos.0) * 1000.0) as i32
|
||||
})
|
||||
.map(|(entity, _, _)| entity)
|
||||
});
|
||||
|
||||
if let Some(entity) = entity {
|
||||
client.pick_up(entity);
|
||||
|
Loading…
Reference in New Issue
Block a user