mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
fix: block
This commit is contained in:
parent
1f4065ae32
commit
2fa902270e
@ -10,9 +10,7 @@ pub enum AbilityActionKind {
|
|||||||
// UpdatePool?
|
// UpdatePool?
|
||||||
}
|
}
|
||||||
impl Default for AbilityActionKind {
|
impl Default for AbilityActionKind {
|
||||||
fn default() -> Self {
|
fn default() -> Self { Self::Primary }
|
||||||
Self::Primary
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
#[derive(Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
||||||
pub struct AbilityAction(pub AbilityActionKind);
|
pub struct AbilityAction(pub AbilityActionKind);
|
||||||
@ -33,7 +31,7 @@ impl Default for AbilityPool {
|
|||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
primary: Some(comp::CharacterState::BasicAttack(None)),
|
primary: Some(comp::CharacterState::BasicAttack(None)),
|
||||||
secondary: None,
|
secondary: Some(comp::CharacterState::BasicBlock(None)),
|
||||||
block: None,
|
block: None,
|
||||||
dodge: Some(comp::CharacterState::Roll(None)),
|
dodge: Some(comp::CharacterState::Roll(None)),
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ pub enum CharacterState {
|
|||||||
Wielded(Option<wielded::State>),
|
Wielded(Option<wielded::State>),
|
||||||
Glide(Option<glide::State>),
|
Glide(Option<glide::State>),
|
||||||
BasicAttack(Option<basic_attack::State>),
|
BasicAttack(Option<basic_attack::State>),
|
||||||
//BasicBlock(Option<basic_block::State>),
|
BasicBlock(Option<basic_block::State>),
|
||||||
//Charge(Option<charge_attack::State>),
|
//Charge(Option<charge_attack::State>),
|
||||||
Roll(Option<roll::State>),
|
Roll(Option<roll::State>),
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ impl CharacterState {
|
|||||||
|
|
||||||
pub fn is_block(&self) -> bool {
|
pub fn is_block(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
//CharacterState::BasicBlock(_) => true,
|
CharacterState::BasicBlock(_) => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -102,11 +102,11 @@ impl CharacterState {
|
|||||||
CharacterState::BasicAttack(opt_state) => opt_state
|
CharacterState::BasicAttack(opt_state) => opt_state
|
||||||
.unwrap_or_else(|| basic_attack::State::new(ecs_data))
|
.unwrap_or_else(|| basic_attack::State::new(ecs_data))
|
||||||
.handle(ecs_data),
|
.handle(ecs_data),
|
||||||
/*CharacterState::Charge(opt_state) => opt_state
|
|
||||||
.unwrap_or_else(|| charge_attack::State::new(ecs_data))
|
|
||||||
.handle(ecs_data),
|
|
||||||
CharacterState::BasicBlock(opt_state) => opt_state
|
CharacterState::BasicBlock(opt_state) => opt_state
|
||||||
.unwrap_or_else(|| basic_block::State::new(ecs_data))
|
.unwrap_or_else(|| basic_block::State::new(ecs_data))
|
||||||
|
.handle(ecs_data),
|
||||||
|
/*CharacterState::Charge(opt_state) => opt_state
|
||||||
|
.unwrap_or_else(|| charge_attack::State::new(ecs_data))
|
||||||
.handle(ecs_data),*/
|
.handle(ecs_data),*/
|
||||||
CharacterState::Roll(opt_state) => opt_state
|
CharacterState::Roll(opt_state) => opt_state
|
||||||
.unwrap_or_else(|| roll::State::new(ecs_data))
|
.unwrap_or_else(|| roll::State::new(ecs_data))
|
||||||
|
@ -1,24 +1,19 @@
|
|||||||
use super::utils::*;
|
use super::utils::*;
|
||||||
use crate::comp::{EcsStateData, StateUpdate};
|
use crate::{
|
||||||
use crate::states::StateHandler;
|
comp::{EcsStateData, StateUpdate},
|
||||||
use std::time::Duration;
|
states::StateHandler,
|
||||||
|
};
|
||||||
|
use std::{collections::VecDeque, time::Duration};
|
||||||
use vek::Vec2;
|
use vek::Vec2;
|
||||||
|
|
||||||
const BLOCK_ACCEL: f32 = 30.0;
|
const BLOCK_ACCEL: f32 = 30.0;
|
||||||
const BLOCK_SPEED: f32 = 75.0;
|
const BLOCK_SPEED: f32 = 75.0;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
||||||
pub struct State {
|
pub struct State {}
|
||||||
/// How long the blocking state has been active
|
|
||||||
pub active_duration: Duration,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl StateHandler for State {
|
impl StateHandler for State {
|
||||||
fn new(_ecs_data: &EcsStateData) -> Self {
|
fn new(_ecs_data: &EcsStateData) -> Self { Self {} }
|
||||||
Self {
|
|
||||||
active_duration: Duration::default(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate {
|
fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate {
|
||||||
let mut update = StateUpdate {
|
let mut update = StateUpdate {
|
||||||
@ -26,23 +21,10 @@ impl StateHandler for State {
|
|||||||
vel: *ecs_data.vel,
|
vel: *ecs_data.vel,
|
||||||
ori: *ecs_data.ori,
|
ori: *ecs_data.ori,
|
||||||
character: *ecs_data.character,
|
character: *ecs_data.character,
|
||||||
|
local_events: VecDeque::new(),
|
||||||
|
server_events: VecDeque::new(),
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Apply simple move speed debuff instead
|
|
||||||
|
|
||||||
// Update movement
|
|
||||||
update.vel.0 += Vec2::broadcast(ecs_data.dt.0)
|
|
||||||
* ecs_data.inputs.move_dir
|
|
||||||
* match ecs_data.physics.on_ground {
|
|
||||||
true if update.vel.0.magnitude_squared() < BLOCK_SPEED.powf(2.0) => BLOCK_ACCEL,
|
|
||||||
_ => 0.0,
|
|
||||||
};
|
|
||||||
|
|
||||||
if !ecs_data.inputs.secondary.is_pressed() {
|
|
||||||
update.character.action_state = attempt_wield(ecs_data.stats);
|
|
||||||
return update;
|
|
||||||
}
|
|
||||||
|
|
||||||
update
|
update
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
// Module declarations
|
// Module declarations
|
||||||
pub mod basic_attack;
|
pub mod basic_attack;
|
||||||
|
pub mod basic_block;
|
||||||
pub mod climb;
|
pub mod climb;
|
||||||
pub mod glide;
|
pub mod glide;
|
||||||
pub mod idle;
|
pub mod idle;
|
||||||
|
@ -105,6 +105,16 @@ pub fn handle_primary(ecs_data: &EcsStateData, update: &mut StateUpdate) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn handle_secondary(ecs_data: &EcsStateData, update: &mut StateUpdate) {
|
||||||
|
if let Some(state) = ecs_data.ability_pool.secondary {
|
||||||
|
if let CharacterState::Wielded(_) = update.character {
|
||||||
|
if ecs_data.inputs.secondary.is_pressed() {
|
||||||
|
update.character = state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn handle_dodge(ecs_data: &EcsStateData, update: &mut StateUpdate) {
|
pub fn handle_dodge(ecs_data: &EcsStateData, update: &mut StateUpdate) {
|
||||||
if let Some(state) = ecs_data.ability_pool.dodge {
|
if let Some(state) = ecs_data.ability_pool.dodge {
|
||||||
if let CharacterState::Idle(_) | CharacterState::Wielded(_) = update.character {
|
if let CharacterState::Idle(_) | CharacterState::Wielded(_) = update.character {
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
use super::utils::*;
|
use super::utils::*;
|
||||||
use crate::comp::{EcsStateData, ItemKind::Tool, StateUpdate, ToolData};
|
use crate::{
|
||||||
use crate::states::StateHandler;
|
comp::{EcsStateData, ItemKind::Tool, StateUpdate, ToolData},
|
||||||
use std::collections::VecDeque;
|
states::StateHandler,
|
||||||
use std::time::Duration;
|
};
|
||||||
|
use std::{collections::VecDeque, time::Duration};
|
||||||
|
|
||||||
#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
#[derive(Clone, Copy, Default, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
||||||
pub struct State {
|
pub struct State {
|
||||||
@ -41,6 +42,7 @@ impl StateHandler for State {
|
|||||||
handle_glide(&ecs_data, &mut update);
|
handle_glide(&ecs_data, &mut update);
|
||||||
handle_unwield(&ecs_data, &mut update);
|
handle_unwield(&ecs_data, &mut update);
|
||||||
handle_primary(&ecs_data, &mut update);
|
handle_primary(&ecs_data, &mut update);
|
||||||
|
handle_secondary(&ecs_data, &mut update);
|
||||||
handle_dodge(&ecs_data, &mut update);
|
handle_dodge(&ecs_data, &mut update);
|
||||||
|
|
||||||
update
|
update
|
||||||
|
@ -170,9 +170,9 @@ impl<Skel: Skeleton> FigureModelCache<Skel> {
|
|||||||
if camera_mode != CameraMode::FirstPerson
|
if camera_mode != CameraMode::FirstPerson
|
||||||
|| character_state
|
|| character_state
|
||||||
.map(|cs| match cs {
|
.map(|cs| match cs {
|
||||||
//CharacterState::BasicAttack(_) // TODO: enable
|
CharacterState::BasicAttack(_)
|
||||||
//| CharacterState::BasicBlock(_)
|
| CharacterState::BasicBlock(_)
|
||||||
CharacterState::Wielding(_)
|
| CharacterState::Wielding(_)
|
||||||
| CharacterState::Wielded(_) => true,
|
| CharacterState::Wielded(_) => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
})
|
})
|
||||||
|
@ -457,15 +457,16 @@ impl FigureMgr {
|
|||||||
skeleton_attr,
|
skeleton_attr,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
/*CharacterState::Block(_) => {
|
CharacterState::BasicBlock(_) => {
|
||||||
anim::character::BlockIdleAnimation::update_skeleton(
|
anim::character::BlockIdleAnimation::update_skeleton(
|
||||||
&target_base,
|
&CharacterSkeleton::new(),
|
||||||
(active_tool_kind, time),
|
(active_tool_kind, time),
|
||||||
state.state_time,
|
state.state_time,
|
||||||
&mut state_animation_rate,
|
&mut state_animation_rate,
|
||||||
skeleton_attr,
|
skeleton_attr,
|
||||||
)
|
)
|
||||||
}
|
},
|
||||||
|
/*
|
||||||
CharacterState::Charge(_) => {
|
CharacterState::Charge(_) => {
|
||||||
anim::character::ChargeAnimation::update_skeleton(
|
anim::character::ChargeAnimation::update_skeleton(
|
||||||
&target_base,
|
&target_base,
|
||||||
|
@ -220,20 +220,8 @@ impl PlayState for SessionState {
|
|||||||
if let Some(select_pos) = select_pos {
|
if let Some(select_pos) = select_pos {
|
||||||
client.remove_block(select_pos);
|
client.remove_block(select_pos);
|
||||||
}
|
}
|
||||||
} else if client
|
|
||||||
.state()
|
|
||||||
.read_storage::<comp::CharacterState>()
|
|
||||||
.get(client.entity())
|
|
||||||
.map(|cs| match cs {
|
|
||||||
/*ActionState::Attack(_) // TODO: uncomment
|
|
||||||
| ActionState::Block(_)
|
|
||||||
| ActionState::Wield(_) => true,*/
|
|
||||||
_ => false,
|
|
||||||
})
|
|
||||||
.unwrap_or(false)
|
|
||||||
{
|
|
||||||
self.inputs.secondary.set_state(state);
|
|
||||||
} else {
|
} else {
|
||||||
|
self.inputs.secondary.set_state(state);
|
||||||
if let Some(select_pos) = select_pos {
|
if let Some(select_pos) = select_pos {
|
||||||
client.collect_block(select_pos);
|
client.collect_block(select_pos);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user