Fixed non-dismounting teleportation

This commit is contained in:
Joshua Barretto 2023-05-17 09:10:29 +01:00
parent 68491dde55
commit 5988237b3d

View File

@ -230,15 +230,15 @@ fn position_mut<T>(
dismount_volume: Option<bool>,
f: impl for<'a> FnOnce(&'a mut comp::Pos) -> T,
) -> CmdResult<T> {
let entity = if dismount_volume.unwrap_or(true) {
if dismount_volume.unwrap_or(true) {
server
.state
.ecs()
.write_storage::<Is<VolumeRider>>()
.remove(entity);
entity
} else {
server
}
let entity = server
.state
.read_storage::<Is<Rider>>()
.get(entity)
@ -249,7 +249,9 @@ fn position_mut<T>(
.read_resource::<UidAllocator>()
.retrieve_entity_internal(is_rider.mount.into())
})
.or(server
.map(Ok)
.or_else(|| {
server
.state
.read_storage::<Is<VolumeRider>>()
.get(entity)
@ -265,9 +267,8 @@ fn position_mut<T>(
.retrieve_entity_internal(uid.into())?),
})
})
.transpose()?)
.unwrap_or(entity)
};
})
.unwrap_or(Ok(entity))?;
let mut maybe_pos = None;