mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Clean Code
Remove option to mount if pet is told to stay
This commit is contained in:
parent
25f1f8f6cb
commit
0648ba1bc6
@ -132,7 +132,13 @@ pub fn handle_mount(server: &mut Server, rider: EcsEntity, mount: EcsEntity) {
|
||||
is_mountable(mount_body, state.ecs().read_storage().get(rider))
|
||||
});
|
||||
|
||||
if (is_pet_of(mount, rider_uid) || is_pet_of(rider, mount_uid)) && can_ride {
|
||||
let is_stay = state
|
||||
.ecs()
|
||||
.read_storage::<PetState>()
|
||||
.get(mount)
|
||||
.and_then(|x| x.stay_pos).is_some();
|
||||
|
||||
if (is_pet_of(mount, rider_uid) || is_pet_of(rider, mount_uid)) && can_ride && !is_stay {
|
||||
drop(uids);
|
||||
let _ = state.link(Mounting {
|
||||
mount: mount_uid,
|
||||
|
@ -2426,23 +2426,23 @@ impl Hud {
|
||||
));
|
||||
if !client.is_riding()
|
||||
&& is_mountable(body, bodies.get(client.entity()))
|
||||
&& pet_state.get(entity).and_then(|st| st.stay_pos).is_none()
|
||||
{
|
||||
options.push((
|
||||
GameInput::Mount,
|
||||
i18n.get_msg("hud-mount").to_string(),
|
||||
));
|
||||
}
|
||||
let pet_stay =
|
||||
pet_state.get(entity).and_then(|st| st.stay_pos).is_some();
|
||||
match pet_stay {
|
||||
false => options.push((
|
||||
GameInput::StayFollow,
|
||||
i18n.get_msg("hud-stay").to_string(),
|
||||
)),
|
||||
true => options.push((
|
||||
if pet_state.get(entity).and_then(|st| st.stay_pos).is_some() {
|
||||
options.push((
|
||||
GameInput::StayFollow,
|
||||
i18n.get_msg("hud-follow").to_string(),
|
||||
)),
|
||||
));
|
||||
} else {
|
||||
options.push((
|
||||
GameInput::StayFollow,
|
||||
i18n.get_msg("hud-stay").to_string(),
|
||||
));
|
||||
}
|
||||
}
|
||||
options
|
||||
|
@ -949,17 +949,14 @@ impl PlayState for SessionState {
|
||||
|
||||
let mut close_pet = None;
|
||||
if let Some(player_pos) = player_pos {
|
||||
let alignment =
|
||||
client.state().ecs().read_storage::<comp::Alignment>();
|
||||
let spatial_grid =
|
||||
client.state().ecs().read_resource::<CachedSpatialGrid>();
|
||||
close_pet = spatial_grid.0
|
||||
close_pet = client.state().ecs().read_resource::<CachedSpatialGrid>().0
|
||||
.in_circle_aabr(player_pos.0.xy(), MAX_MOUNT_RANGE)
|
||||
.filter(|e|
|
||||
*e != client.entity()
|
||||
)
|
||||
.filter(|e|
|
||||
matches!(alignment.get(*e), Some(comp::Alignment::Owned(owner)) if Some(*owner) == client.uid())
|
||||
matches!(client.state().ecs().read_storage::<comp::Alignment>().get(*e),
|
||||
Some(comp::Alignment::Owned(owner)) if Some(*owner) == client.uid())
|
||||
)
|
||||
.min_by_key(|e| {
|
||||
OrderedFloat(client
|
||||
|
Loading…
Reference in New Issue
Block a user