This commit is contained in:
timokoesters 2020-01-22 13:48:55 +01:00
parent 7b558b4542
commit 6515daddce
5 changed files with 18 additions and 16 deletions

View File

@ -70,10 +70,10 @@ impl CharacterState {
}
}
/// Compares `action_state`s for shallow equality (does not check internal struct equality)
/// Compares for shallow equality (does not check internal struct equality)
pub fn equals(&self, other: &Self) -> bool {
// Check if state is the same without looking at the inner data
std::mem::discriminant(&self) == std::mem::discriminant(&other)
std::mem::discriminant(self) == std::mem::discriminant(other)
}
/// Passes data to variant or subvariant handlers

View File

@ -16,7 +16,6 @@ impl StateHandler for State {
}
fn handle(&self, ecs_data: &EcsStateData) -> StateUpdate {
dbg!();
let mut update = StateUpdate {
pos: *ecs_data.pos,
vel: *ecs_data.vel,

View File

@ -46,15 +46,19 @@ impl StateHandler for State {
.unwrap_or_default()
* ROLL_SPEED;
// Otherwise, tick down remaining_duration
update.character = CharacterState::Roll(Some(State {
remaining_duration: self
.remaining_duration
.checked_sub(Duration::from_secs_f32(ecs_data.dt.0))
.unwrap_or_default(),
}));
if self.remaining_duration == Duration::default() {
// Roll duration has expired
update.character = CharacterState::Idle(None);
} else {
// Otherwise, tick down remaining_duration
update.character = CharacterState::Roll(Some(State {
remaining_duration: self
.remaining_duration
.checked_sub(Duration::from_secs_f32(ecs_data.dt.0))
.unwrap_or_default(),
}));
}
// Keep rolling
update
}
}

View File

@ -188,7 +188,6 @@ pub fn handle_glide(ecs_data: &EcsStateData, update: &mut StateUpdate) {
&& !ecs_data.physics.on_ground
&& ecs_data.body.is_humanoid()
{
dbg!();
update.character = CharacterState::Glide(None);
}
}

View File

@ -408,18 +408,18 @@ impl FigureMgr {
skeleton_attr,
),
CharacterState::Wielding(_) => {
anim::character::CidleAnimation::update_skeleton(
anim::character::WieldAnimation::update_skeleton(
&target_base,
(active_tool_kind, time),
(active_tool_kind, vel.0.magnitude(), time),
state.state_time,
&mut state_animation_rate,
skeleton_attr,
)
}
CharacterState::Wielded(_) => {
anim::character::CidleAnimation::update_skeleton(
anim::character::WieldAnimation::update_skeleton(
&target_base,
(active_tool_kind, time),
(active_tool_kind, vel.0.magnitude(), time),
state.state_time,
&mut state_animation_rate,
skeleton_attr,