mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Go to idle state when picking items up
This commit is contained in:
parent
df858cb370
commit
44ec09a8e7
@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
comp::{ControlEvent, Controller},
|
||||
comp::{CharacterState, ControlEvent, Controller},
|
||||
event::{EventBus, LocalEvent, ServerEvent},
|
||||
state::DeltaTime,
|
||||
sync::{Uid, UidAllocator},
|
||||
@ -22,15 +22,27 @@ impl<'a> System<'a> for Sys {
|
||||
Read<'a, EventBus<LocalEvent>>,
|
||||
Read<'a, DeltaTime>,
|
||||
WriteStorage<'a, Controller>,
|
||||
WriteStorage<'a, CharacterState>,
|
||||
ReadStorage<'a, Uid>,
|
||||
);
|
||||
|
||||
fn run(
|
||||
&mut self,
|
||||
(entities, uid_allocator, server_bus, _local_bus, _dt, mut controllers, uids): Self::SystemData,
|
||||
(
|
||||
entities,
|
||||
uid_allocator,
|
||||
server_bus,
|
||||
_local_bus,
|
||||
_dt,
|
||||
mut controllers,
|
||||
mut character_states,
|
||||
uids,
|
||||
): Self::SystemData,
|
||||
) {
|
||||
let mut server_emitter = server_bus.emitter();
|
||||
for (entity, _uid, controller) in (&entities, &uids, &mut controllers).join() {
|
||||
for (entity, _uid, controller, character_state) in
|
||||
(&entities, &uids, &mut controllers, &mut character_states).join()
|
||||
{
|
||||
let inputs = &mut controller.inputs;
|
||||
|
||||
// Update `inputs.move_dir`.
|
||||
@ -59,6 +71,7 @@ impl<'a> System<'a> for Sys {
|
||||
},
|
||||
ControlEvent::Unmount => server_emitter.emit(ServerEvent::Unmount(entity)),
|
||||
ControlEvent::InventoryManip(manip) => {
|
||||
*character_state = CharacterState::Idle;
|
||||
server_emitter.emit(ServerEvent::InventoryManip(entity, manip))
|
||||
}, /*ControlEvent::Respawn =>
|
||||
* server_emitter.emit(ServerEvent::Unmount(entity)), */
|
||||
|
@ -126,6 +126,8 @@ impl Scene {
|
||||
/// Set the block position that the player is interacting with
|
||||
pub fn set_select_pos(&mut self, pos: Option<Vec3<i32>>) { self.select_pos = pos; }
|
||||
|
||||
pub fn select_pos(&self) -> Option<Vec3<i32>> { self.select_pos }
|
||||
|
||||
/// Handle an incoming user input event (e.g.: cursor moved, key pressed,
|
||||
/// window closed).
|
||||
///
|
||||
|
@ -269,7 +269,8 @@ impl PlayState for SessionState {
|
||||
} else {
|
||||
self.inputs.secondary.set_state(state);
|
||||
|
||||
if let Some(select_pos) = select_pos {
|
||||
// Check for select_block that is highlighted
|
||||
if let Some(select_pos) = self.scene.select_pos() {
|
||||
client.collect_block(select_pos);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user