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