Re-add blocking

This commit is contained in:
Adam Whitehurst 2020-03-07 11:55:15 -08:00
parent cb9e3859da
commit c678ca9540
4 changed files with 29 additions and 25 deletions

View File

@ -26,7 +26,7 @@ impl Default for AbilityPool {
fn default() -> Self {
Self {
primary: Some(AbilityState::BasicAttack),
secondary: Some(AbilityState::BasicAttack),
secondary: Some(AbilityState::BasicBlock),
block: None,
dodge: Some(AbilityState::Roll),
}

View File

@ -1,32 +1,35 @@
use super::utils::*;
use crate::{
comp::{CharacterEntityData, CharacterState, StateUpdate},
comp::{CharacterState, ItemKind, StateUpdate},
sys::character_behavior::JoinData,
};
use std::{collections::VecDeque, time::Duration};
use vek::Vec2;
use crate::sys::character_behavior::JoinData;
use std::collections::VecDeque;
const BLOCK_ACCEL: f32 = 30.0;
const BLOCK_SPEED: f32 = 75.0;
// const BLOCK_ACCEL: f32 = 30.0;
// const BLOCK_SPEED: f32 = 75.0;
pub fn behavior(data: &JoinData) -> StateUpdate {
let mut update = StateUpdate {
pos: *data.pos,
vel: *data.vel,
ori: *data.ori,
energy: *data.energy,
character: *data.character,
local_events: VecDeque::new(),
server_events: VecDeque::new(),
};
pub fn handle(data: &JoinData) -> StateUpdate {
let mut update = StateUpdate {
pos: *data.pos,
vel: *data.vel,
ori: *data.ori,
energy: *data.energy,
character: *data.character,
local_events: VecDeque::new(),
server_events: VecDeque::new(),
handle_move(&data, &mut update);
if !data.physics.on_ground || !data.inputs.secondary.is_pressed() {
if let Some(ItemKind::Tool(tool)) = data.stats.equipment.main.as_ref().map(|i| i.kind) {
update.character = CharacterState::Equipping {
tool,
time_left: tool.equip_time(),
};
} else {
update.character = CharacterState::Idle {};
};
handle_move(&data, &mut update);
if !data.physics.on_ground || !data.inputs.secondary.is_pressed() {
update.character = CharacterState::Wielding{};
}
update
}
update
}

View File

@ -1,6 +1,6 @@
// Module declarations
pub mod basic_attack;
// pub mod basic_block;
pub mod basic_block;
pub mod climb;
pub mod equipping;
pub mod glide;

View File

@ -168,6 +168,7 @@ impl<'a> System<'a> for Sys {
CharacterState::Wielding { .. } => states::wielding::behavior(&j),
CharacterState::Equipping { .. } => states::equipping::behavior(&j),
CharacterState::BasicAttack { .. } => states::basic_attack::behavior(&j),
CharacterState::BasicBlock { .. } => states::basic_block::behavior(&j),
CharacterState::Sit { .. } => states::sit::behavior(&j),
_ => StateUpdate {