veloren/common/src/states/basic_block.rs

28 lines
722 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},
};
use serde::{Deserialize, Serialize};
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::from(data);
handle_move(&data, &mut update, 0.4);
2020-03-14 21:17:27 +00:00
2020-03-16 12:40:14 +00:00
if !data.physics.on_ground
|| !(data.inputs.secondary.is_pressed() || data.inputs.primary.is_pressed())
{
2020-03-14 21:17:27 +00:00
attempt_wield(data, &mut update);
}
update
2019-12-26 14:43:59 +00:00
}
}