mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
avoid comparing to own entity when mounting; fix coding style
This commit is contained in:
parent
a3326b5744
commit
05cc6f222b
@ -15,7 +15,10 @@ use common::{
|
|||||||
assets::{load_expect, load_watched, watch},
|
assets::{load_expect, load_watched, watch},
|
||||||
clock::Clock,
|
clock::Clock,
|
||||||
comp,
|
comp,
|
||||||
comp::{ChatMsg, ChatType, InventoryUpdateEvent, Pos, Vel, MAX_MOUNT_RANGE_SQR, MAX_PICKUP_RANGE_SQR},
|
comp::{
|
||||||
|
ChatMsg, ChatType, InventoryUpdateEvent, Pos, Vel, MAX_MOUNT_RANGE_SQR,
|
||||||
|
MAX_PICKUP_RANGE_SQR,
|
||||||
|
},
|
||||||
event::EventBus,
|
event::EventBus,
|
||||||
msg::ClientState,
|
msg::ClientState,
|
||||||
terrain::{Block, BlockKind},
|
terrain::{Block, BlockKind},
|
||||||
@ -432,26 +435,30 @@ impl PlayState for SessionState {
|
|||||||
// Find closest mountable entity
|
// Find closest mountable entity
|
||||||
let mut closest_mountable: Option<(specs::Entity, i32)> = None;
|
let mut closest_mountable: Option<(specs::Entity, i32)> = None;
|
||||||
|
|
||||||
for (uid, pos, ms) in (
|
for (entity, pos, ms) in (
|
||||||
&client.state().ecs().entities(),
|
&client.state().ecs().entities(),
|
||||||
&client.state().ecs().read_storage::<comp::Pos>(),
|
&client.state().ecs().read_storage::<comp::Pos>(),
|
||||||
&client.state().ecs().read_storage::<comp::MountState>(),
|
&client.state().ecs().read_storage::<comp::MountState>(),
|
||||||
).join() {
|
)
|
||||||
|
.join()
|
||||||
|
.filter(|(entity, _, _)| *entity != client.entity())
|
||||||
|
{
|
||||||
if comp::MountState::Unmounted != *ms {
|
if comp::MountState::Unmounted != *ms {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let dist = (player_pos.0.distance_squared(pos.0) * 1000.0) as i32;
|
let dist =
|
||||||
if MAX_MOUNT_RANGE_SQR < dist {
|
(player_pos.0.distance_squared(pos.0) * 1000.0) as i32;
|
||||||
|
if dist > MAX_MOUNT_RANGE_SQR {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(previous) = closest_mountable.as_mut() {
|
if let Some(previous) = closest_mountable.as_mut() {
|
||||||
if dist < previous.1 {
|
if dist < previous.1 {
|
||||||
*previous = (uid, dist);
|
*previous = (entity, dist);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
closest_mountable = Some((uid, dist));
|
closest_mountable = Some((entity, dist));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user