veloren/common/src/states/basic_block.rs

33 lines
833 B
Rust
Raw Normal View History

2020-01-09 16:23:20 +00:00
use super::utils::*;
2020-02-24 14:35:07 +00:00
use crate::{
2020-03-07 18:15:02 +00:00
comp::{CharacterEntityData, CharacterState, StateUpdate},
2020-02-24 14:35:07 +00:00
};
use std::{collections::VecDeque, time::Duration};
2019-12-26 18:01:19 +00:00
use vek::Vec2;
2020-03-07 19:02:54 +00:00
use crate::sys::character_behavior::JoinData;
2019-12-26 14:43:59 +00:00
2020-01-07 15:49:08 +00:00
const BLOCK_ACCEL: f32 = 30.0;
const BLOCK_SPEED: f32 = 75.0;
2019-12-26 14:43:59 +00:00
2020-03-07 18:15:02 +00:00
pub fn handle(data: &JoinData) -> StateUpdate {
2019-12-28 16:10:39 +00:00
let mut update = StateUpdate {
2020-03-07 18:15:02 +00:00
pos: *data.pos,
vel: *data.vel,
ori: *data.ori,
energy: *data.energy,
character: *data.character,
2020-02-24 14:35:07 +00:00
local_events: VecDeque::new(),
server_events: VecDeque::new(),
2019-12-26 14:43:59 +00:00
};
2019-12-26 18:01:19 +00:00
2020-03-07 18:15:02 +00:00
handle_move(&data, &mut update);
2020-03-07 18:15:02 +00:00
if !data.physics.on_ground || !data.inputs.secondary.is_pressed() {
update.character = CharacterState::Wielding{};
}
2020-01-12 23:14:08 +00:00
update
2019-12-26 14:43:59 +00:00
}
}