veloren/common/src/states/basic_block.rs

34 lines
906 B
Rust
Raw Normal View History

2020-01-09 16:23:20 +00:00
use super::utils::*;
2020-03-14 21:17:27 +00:00
use crate::{
comp::StateUpdate,
sys::character_behavior::{CharacterBehavior, JoinData},
};
2020-03-07 19:55:15 +00:00
use std::collections::VecDeque;
2019-12-26 14:43:59 +00:00
2020-03-07 19:55:15 +00:00
// const BLOCK_ACCEL: f32 = 30.0;
// const BLOCK_SPEED: f32 = 75.0;
2020-01-07 15:49:08 +00:00
2020-03-14 21:17:27 +00:00
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
pub struct Data;
2019-12-26 14:43:59 +00:00
2020-03-14 21:17:27 +00:00
impl CharacterBehavior for Data {
fn behavior(&self, data: &JoinData) -> StateUpdate {
let mut update = StateUpdate {
pos: *data.pos,
vel: *data.vel,
ori: *data.ori,
energy: *data.energy,
character: data.character.clone(),
2020-03-14 21:17:27 +00:00
local_events: VecDeque::new(),
server_events: VecDeque::new(),
};
2020-03-14 21:17:27 +00:00
handle_move(&data, &mut update);
if !data.physics.on_ground || !data.inputs.secondary.is_pressed() {
attempt_wield(data, &mut update);
}
update
2019-12-26 14:43:59 +00:00
}
}