Add server side check to stop stay when mounted

Add filter to allow telling other pets to stay when mounted
This commit is contained in:
TelepathicWalrus 2023-05-06 10:38:40 +01:00 committed by Maxicarlos08
parent 0648ba1bc6
commit 6a080c242c
No known key found for this signature in database
2 changed files with 5 additions and 1 deletions

View File

@ -230,7 +230,8 @@ pub fn handle_toggle_stay(server: &mut Server, command_giver: EcsEntity, pet: Ec
if prev_pet_pos.is_none() { if prev_pet_pos.is_none() {
new_pet_pos = state.ecs().read_storage::<Pos>().get(pet).copied(); new_pet_pos = state.ecs().read_storage::<Pos>().get(pet).copied();
} }
if is_owner && within_mounting_range(positions.get(command_giver), positions.get(pet)) { if is_owner && within_mounting_range(positions.get(command_giver), positions.get(pet))
&& state.ecs().read_storage::<Is<Mount>>().get(pet).is_none() {
let _ = state let _ = state
.ecs() .ecs()
.write_storage::<PetState>() .write_storage::<PetState>()

View File

@ -958,6 +958,9 @@ impl PlayState for SessionState {
matches!(client.state().ecs().read_storage::<comp::Alignment>().get(*e), matches!(client.state().ecs().read_storage::<comp::Alignment>().get(*e),
Some(comp::Alignment::Owned(owner)) if Some(*owner) == client.uid()) Some(comp::Alignment::Owned(owner)) if Some(*owner) == client.uid())
) )
.filter(|e|
client.state().ecs().read_storage::<Is<Mount>>().get(*e).is_none()
)
.min_by_key(|e| { .min_by_key(|e| {
OrderedFloat(client OrderedFloat(client
.state() .state()