From 6945ac73a53e56ac346e030c47ee06bf5bf10339 Mon Sep 17 00:00:00 2001 From: scott-c Date: Sun, 7 Feb 2021 02:13:40 +0800 Subject: [PATCH] add ability to target entities. --- voxygen/src/session.rs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index a0dc128cdb..10d20b79d9 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -663,6 +663,42 @@ impl PlayState for SessionState { }, }; + // to select entity: + // hover cursor over target, and press 'Y' to select an entity. + // TODO: make target selection easier, and ability to cycle through targets? + if let Some((se, inst)) = self.selected_entity { + + let v = + ( + self.client.borrow() + .state() + .ecs() + .read_storage::() + .get(se) + .expect("expected selected target pos").0 + - + self.client.borrow() + .state() + .ecs() + .read_storage::() + .get(self.client.borrow().entity()) + .expect("expected selected player pos").0 + ) + .normalized(); + + let x = self.client.borrow_mut() + .state() + .ecs() + .read_storage::() + .get(se) + .expect("expected selected target pos").0; + + self.scene.camera_mut().set_orientation(v); // TODO: fix janky camera + self.inputs.look_dir = Dir::from_unnormalized(v).expect("expected normalized dir"); + } + + + self.inputs.climb = self.key_state.climb(); self.inputs.fly.set_state(self.key_state.fly); self.inputs.move_z =