2020-09-04 01:54:59 +00:00
|
|
|
use crate::{
|
2021-02-02 18:02:40 +00:00
|
|
|
combat::{Attack, AttackDamage, AttackEffect, CombatBuff, CombatEffect, CombatRequirement},
|
2021-07-06 01:32:12 +00:00
|
|
|
comp::{
|
2021-10-13 02:03:18 +00:00
|
|
|
character_state::OutputEvents,
|
2021-07-06 01:32:12 +00:00
|
|
|
tool::{Stats, ToolKind},
|
|
|
|
CharacterState, Melee, StateUpdate,
|
|
|
|
},
|
2020-12-01 00:28:00 +00:00
|
|
|
states::{
|
|
|
|
behavior::{CharacterBehavior, JoinData},
|
|
|
|
utils::*,
|
2021-10-05 00:15:58 +00:00
|
|
|
wielding,
|
2020-12-01 00:28:00 +00:00
|
|
|
},
|
2021-05-06 18:50:16 +00:00
|
|
|
Damage, DamageKind, DamageSource, GroupTarget, Knockback, KnockbackDir,
|
2020-09-04 01:54:59 +00:00
|
|
|
};
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use std::time::Duration;
|
|
|
|
|
2020-11-13 03:24:19 +00:00
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
|
2020-11-11 01:49:05 +00:00
|
|
|
pub struct Stage<T> {
|
2020-09-04 01:54:59 +00:00
|
|
|
/// Specifies which stage the combo attack is in
|
|
|
|
pub stage: u32,
|
|
|
|
/// Initial damage of stage
|
2021-02-05 01:39:12 +00:00
|
|
|
pub base_damage: f32,
|
2020-09-04 01:54:59 +00:00
|
|
|
/// Damage scaling per combo
|
2021-02-05 01:39:12 +00:00
|
|
|
pub damage_increase: f32,
|
2020-12-05 18:23:45 +00:00
|
|
|
/// Initial poise damage of stage
|
2021-02-05 01:39:12 +00:00
|
|
|
pub base_poise_damage: f32,
|
2020-12-16 23:30:33 +00:00
|
|
|
/// Poise damage scaling per combo
|
2021-02-05 01:39:12 +00:00
|
|
|
pub poise_damage_increase: f32,
|
2020-09-04 01:54:59 +00:00
|
|
|
/// Knockback of stage
|
|
|
|
pub knockback: f32,
|
|
|
|
/// Range of attack
|
|
|
|
pub range: f32,
|
|
|
|
/// Angle of attack
|
|
|
|
pub angle: f32,
|
|
|
|
/// Initial buildup duration of stage (how long until state can deal damage)
|
2020-11-11 01:49:05 +00:00
|
|
|
pub base_buildup_duration: T,
|
2020-09-08 00:16:55 +00:00
|
|
|
/// Duration of stage spent in swing (controls animation stuff, and can also
|
|
|
|
/// be used to handle movement separately to buildup)
|
2020-11-11 01:49:05 +00:00
|
|
|
pub base_swing_duration: T,
|
2021-06-11 19:00:06 +00:00
|
|
|
/// At what fraction of the swing duration to apply the melee "hit"
|
|
|
|
pub hit_timing: f32,
|
2020-09-04 01:54:59 +00:00
|
|
|
/// Initial recover duration of stage (how long until character exits state)
|
2020-11-11 01:49:05 +00:00
|
|
|
pub base_recover_duration: T,
|
2020-09-09 00:28:59 +00:00
|
|
|
/// How much forward movement there is in the swing portion of the stage
|
|
|
|
pub forward_movement: f32,
|
2021-05-06 18:50:16 +00:00
|
|
|
/// What kind of damage this stage of the attack does
|
|
|
|
pub damage_kind: DamageKind,
|
2021-07-10 16:04:12 +00:00
|
|
|
/// Adds an effect onto the main damage of the attack
|
|
|
|
pub damage_effect: Option<CombatEffect>,
|
2020-09-06 21:46:53 +00:00
|
|
|
}
|
|
|
|
|
2021-02-05 01:39:12 +00:00
|
|
|
impl Stage<f32> {
|
2020-11-11 01:49:05 +00:00
|
|
|
pub fn to_duration(self) -> Stage<Duration> {
|
|
|
|
Stage::<Duration> {
|
|
|
|
stage: self.stage,
|
|
|
|
base_damage: self.base_damage,
|
|
|
|
damage_increase: self.damage_increase,
|
2020-12-05 18:23:45 +00:00
|
|
|
base_poise_damage: self.base_poise_damage,
|
2020-12-16 23:30:33 +00:00
|
|
|
poise_damage_increase: self.poise_damage_increase,
|
2020-11-11 01:49:05 +00:00
|
|
|
knockback: self.knockback,
|
|
|
|
range: self.range,
|
|
|
|
angle: self.angle,
|
2021-02-05 01:39:12 +00:00
|
|
|
base_buildup_duration: Duration::from_secs_f32(self.base_buildup_duration),
|
2021-06-11 19:00:06 +00:00
|
|
|
hit_timing: self.hit_timing,
|
2021-02-05 01:39:12 +00:00
|
|
|
base_swing_duration: Duration::from_secs_f32(self.base_swing_duration),
|
|
|
|
base_recover_duration: Duration::from_secs_f32(self.base_recover_duration),
|
2020-11-11 01:49:05 +00:00
|
|
|
forward_movement: self.forward_movement,
|
2021-05-06 18:50:16 +00:00
|
|
|
damage_kind: self.damage_kind,
|
2021-07-10 16:04:12 +00:00
|
|
|
damage_effect: self.damage_effect,
|
2020-11-11 01:49:05 +00:00
|
|
|
}
|
|
|
|
}
|
2020-11-13 03:24:19 +00:00
|
|
|
|
2021-12-21 20:19:23 +00:00
|
|
|
#[must_use]
|
2021-07-10 16:04:12 +00:00
|
|
|
pub fn adjusted_by_stats(mut self, stats: Stats) -> Self {
|
|
|
|
if let Some(CombatEffect::Buff(CombatBuff {
|
|
|
|
kind: _,
|
|
|
|
dur_secs: _,
|
|
|
|
ref mut strength,
|
|
|
|
chance: _,
|
|
|
|
})) = self.damage_effect
|
|
|
|
{
|
|
|
|
*strength *= stats.buff_strength;
|
|
|
|
}
|
2021-07-07 03:51:30 +00:00
|
|
|
Self {
|
|
|
|
stage: self.stage,
|
|
|
|
base_damage: self.base_damage * stats.power,
|
|
|
|
damage_increase: self.damage_increase * stats.power,
|
2021-07-11 04:22:00 +00:00
|
|
|
base_poise_damage: self.base_poise_damage * stats.effect_power,
|
|
|
|
poise_damage_increase: self.poise_damage_increase * stats.effect_power,
|
2021-07-07 03:51:30 +00:00
|
|
|
knockback: self.knockback,
|
|
|
|
range: self.range * stats.range,
|
|
|
|
angle: self.angle,
|
|
|
|
base_buildup_duration: self.base_buildup_duration / stats.speed,
|
|
|
|
base_swing_duration: self.base_swing_duration / stats.speed,
|
|
|
|
hit_timing: self.hit_timing,
|
|
|
|
base_recover_duration: self.base_recover_duration / stats.speed,
|
|
|
|
forward_movement: self.forward_movement,
|
|
|
|
damage_kind: self.damage_kind,
|
2021-07-10 16:04:12 +00:00
|
|
|
damage_effect: self.damage_effect,
|
2021-07-07 03:51:30 +00:00
|
|
|
}
|
2020-11-13 03:24:19 +00:00
|
|
|
}
|
2020-12-20 22:28:17 +00:00
|
|
|
|
2021-08-16 17:43:57 +00:00
|
|
|
// TODO: name it as using knockback
|
2021-12-21 20:19:23 +00:00
|
|
|
#[must_use]
|
2020-12-20 22:28:17 +00:00
|
|
|
pub fn modify_strike(mut self, knockback_mult: f32) -> Self {
|
|
|
|
self.knockback *= knockback_mult;
|
|
|
|
self
|
|
|
|
}
|
2020-11-11 01:49:05 +00:00
|
|
|
}
|
|
|
|
|
2022-01-18 01:41:24 +00:00
|
|
|
// TODO: Completely rewrite this with skill tree rework. Don't bother converting
|
|
|
|
// to melee constructor.
|
2020-09-04 01:54:59 +00:00
|
|
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
2020-09-21 22:38:01 +00:00
|
|
|
/// Separated out to condense update portions of character state
|
|
|
|
pub struct StaticData {
|
2020-09-04 01:54:59 +00:00
|
|
|
/// Indicates number of stages in combo
|
|
|
|
pub num_stages: u32,
|
2020-09-12 16:46:21 +00:00
|
|
|
/// Data for each stage
|
2020-11-11 01:49:05 +00:00
|
|
|
pub stage_data: Vec<Stage<Duration>>,
|
2020-09-04 01:54:59 +00:00
|
|
|
/// Initial energy gain per strike
|
2021-02-05 01:39:12 +00:00
|
|
|
pub initial_energy_gain: f32,
|
2020-09-04 01:54:59 +00:00
|
|
|
/// Max energy gain per strike
|
2021-02-05 01:39:12 +00:00
|
|
|
pub max_energy_gain: f32,
|
2020-09-04 01:54:59 +00:00
|
|
|
/// Energy gain increase per combo
|
2021-02-05 01:39:12 +00:00
|
|
|
pub energy_increase: f32,
|
2020-09-12 16:46:21 +00:00
|
|
|
/// (100% - speed_increase) is percentage speed increases from current to
|
2020-12-07 03:35:29 +00:00
|
|
|
/// max per combo increase
|
2020-09-11 19:24:55 +00:00
|
|
|
pub speed_increase: f32,
|
2020-12-07 03:35:29 +00:00
|
|
|
/// This value is the highest percentage speed can increase from the base
|
|
|
|
/// speed
|
2020-09-11 19:24:55 +00:00
|
|
|
pub max_speed_increase: f32,
|
2020-12-08 04:00:24 +00:00
|
|
|
/// Number of times damage scales with combo
|
|
|
|
pub scales_from_combo: u32,
|
2020-09-12 16:46:21 +00:00
|
|
|
/// Whether the state can be interrupted by other abilities
|
|
|
|
pub is_interruptible: bool,
|
2021-05-01 16:29:01 +00:00
|
|
|
/// Adjusts turning rate during the attack
|
2021-04-30 02:59:29 +00:00
|
|
|
pub ori_modifier: f32,
|
2020-10-31 18:44:00 +00:00
|
|
|
/// What key is used to press ability
|
2021-02-14 06:01:53 +00:00
|
|
|
pub ability_info: AbilityInfo,
|
2020-09-04 01:54:59 +00:00
|
|
|
}
|
2020-09-21 22:38:01 +00:00
|
|
|
/// A sequence of attacks that can incrementally become faster and more
|
|
|
|
/// damaging.
|
|
|
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
|
|
|
pub struct Data {
|
|
|
|
/// Struct containing data that does not change over the course of the
|
|
|
|
/// character state
|
|
|
|
pub static_data: StaticData,
|
2021-06-11 19:00:06 +00:00
|
|
|
/// Whether the attack was executed already
|
|
|
|
pub exhausted: bool,
|
2020-09-21 22:38:01 +00:00
|
|
|
/// Indicates what stage the combo is in
|
|
|
|
pub stage: u32,
|
|
|
|
/// Timer for each stage
|
|
|
|
pub timer: Duration,
|
|
|
|
/// Checks what section a stage is in
|
|
|
|
pub stage_section: StageSection,
|
|
|
|
}
|
2020-09-04 01:54:59 +00:00
|
|
|
|
|
|
|
impl CharacterBehavior for Data {
|
2021-10-13 02:03:18 +00:00
|
|
|
fn behavior(&self, data: &JoinData, output_events: &mut OutputEvents) -> StateUpdate {
|
2020-09-04 01:54:59 +00:00
|
|
|
let mut update = StateUpdate::from(data);
|
|
|
|
|
2022-01-20 20:26:35 +00:00
|
|
|
let combo_counter = data.combo.map_or(0, |c| c.counter());
|
|
|
|
|
2021-05-01 16:29:01 +00:00
|
|
|
handle_move(data, &mut update, 0.4);
|
2020-09-12 16:46:21 +00:00
|
|
|
|
2021-07-05 01:54:08 +00:00
|
|
|
// Index should be `self.stage - 1`, however in cases of client-server desync
|
|
|
|
// this can cause panics. This ensures that `self.stage - 1` is valid, and if it
|
|
|
|
// isn't, index of 0 is used, which is always safe.
|
|
|
|
let stage_index = self
|
|
|
|
.static_data
|
|
|
|
.stage_data
|
|
|
|
.get(self.stage as usize - 1)
|
|
|
|
.map_or(0, |_| self.stage as usize - 1);
|
2020-11-20 17:30:48 +00:00
|
|
|
|
2020-11-09 01:27:44 +00:00
|
|
|
let speed_modifer = 1.0
|
|
|
|
+ self.static_data.max_speed_increase
|
2022-01-20 20:26:35 +00:00
|
|
|
* (1.0 - self.static_data.speed_increase.powi(combo_counter as i32));
|
2020-11-09 00:11:53 +00:00
|
|
|
|
2020-09-21 22:38:01 +00:00
|
|
|
match self.stage_section {
|
|
|
|
StageSection::Buildup => {
|
|
|
|
if self.timer < self.static_data.stage_data[stage_index].base_buildup_duration {
|
2021-08-29 23:23:34 +00:00
|
|
|
handle_orientation(
|
|
|
|
data,
|
|
|
|
&mut update,
|
|
|
|
0.4 * self.static_data.ori_modifier,
|
|
|
|
None,
|
|
|
|
);
|
2021-04-30 02:59:29 +00:00
|
|
|
|
2020-09-21 22:38:01 +00:00
|
|
|
// Build up
|
|
|
|
update.character = CharacterState::ComboMelee(Data {
|
|
|
|
static_data: self.static_data.clone(),
|
2021-05-30 19:39:30 +00:00
|
|
|
timer: tick_attack_or_default(data, self.timer, Some(speed_modifer)),
|
2020-10-27 22:16:17 +00:00
|
|
|
..*self
|
2020-09-21 22:38:01 +00:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
// Transitions to swing section of stage
|
|
|
|
update.character = CharacterState::ComboMelee(Data {
|
|
|
|
static_data: self.static_data.clone(),
|
|
|
|
timer: Duration::default(),
|
2021-07-01 19:44:24 +00:00
|
|
|
stage_section: StageSection::Action,
|
2020-10-27 22:16:17 +00:00
|
|
|
..*self
|
2020-09-21 22:38:01 +00:00
|
|
|
});
|
2021-06-11 19:00:06 +00:00
|
|
|
}
|
|
|
|
},
|
2021-07-01 19:44:24 +00:00
|
|
|
StageSection::Action => {
|
2021-06-11 19:00:06 +00:00
|
|
|
if self.timer.as_secs_f32()
|
|
|
|
> self.static_data.stage_data[stage_index].hit_timing
|
|
|
|
* self.static_data.stage_data[stage_index]
|
|
|
|
.base_swing_duration
|
|
|
|
.as_secs_f32()
|
|
|
|
&& !self.exhausted
|
|
|
|
{
|
|
|
|
// Swing
|
|
|
|
update.character = CharacterState::ComboMelee(Data {
|
|
|
|
static_data: self.static_data.clone(),
|
|
|
|
timer: tick_attack_or_default(data, self.timer, None),
|
|
|
|
exhausted: true,
|
|
|
|
..*self
|
|
|
|
});
|
2020-09-11 18:29:42 +00:00
|
|
|
|
2020-12-08 04:00:24 +00:00
|
|
|
let damage = self.static_data.stage_data[stage_index].base_damage
|
2021-02-05 01:39:12 +00:00
|
|
|
+ (self
|
2020-12-08 04:00:24 +00:00
|
|
|
.static_data
|
|
|
|
.scales_from_combo
|
2022-01-20 20:26:35 +00:00
|
|
|
.min(combo_counter / self.static_data.num_stages)
|
2021-02-05 01:39:12 +00:00
|
|
|
as f32)
|
2020-12-08 04:00:24 +00:00
|
|
|
* self.static_data.stage_data[stage_index].damage_increase;
|
2021-02-05 01:39:12 +00:00
|
|
|
|
2021-01-30 04:40:03 +00:00
|
|
|
let poise = self.static_data.stage_data[stage_index].base_poise_damage
|
2021-02-05 01:39:12 +00:00
|
|
|
+ (self
|
2020-12-16 23:30:33 +00:00
|
|
|
.static_data
|
|
|
|
.scales_from_combo
|
2022-01-20 20:26:35 +00:00
|
|
|
.min(combo_counter / self.static_data.num_stages)
|
2021-02-05 01:39:12 +00:00
|
|
|
as f32)
|
2020-12-16 23:30:33 +00:00
|
|
|
* self.static_data.stage_data[stage_index].poise_damage_increase;
|
2021-02-02 18:02:40 +00:00
|
|
|
let poise = AttackEffect::new(
|
|
|
|
Some(GroupTarget::OutOfGroup),
|
2021-02-05 01:39:12 +00:00
|
|
|
CombatEffect::Poise(poise),
|
2021-02-02 18:02:40 +00:00
|
|
|
)
|
|
|
|
.with_requirement(CombatRequirement::AnyDamage);
|
2021-06-11 19:00:06 +00:00
|
|
|
|
2021-02-02 18:02:40 +00:00
|
|
|
let knockback = AttackEffect::new(
|
|
|
|
Some(GroupTarget::OutOfGroup),
|
|
|
|
CombatEffect::Knockback(Knockback {
|
|
|
|
strength: self.static_data.stage_data[stage_index].knockback,
|
|
|
|
direction: KnockbackDir::Away,
|
|
|
|
}),
|
|
|
|
)
|
|
|
|
.with_requirement(CombatRequirement::AnyDamage);
|
2021-06-11 19:00:06 +00:00
|
|
|
|
2021-01-26 17:58:52 +00:00
|
|
|
let energy = self.static_data.max_energy_gain.min(
|
|
|
|
self.static_data.initial_energy_gain
|
2022-01-20 20:26:35 +00:00
|
|
|
+ combo_counter as f32 * self.static_data.energy_increase,
|
2021-01-26 17:58:52 +00:00
|
|
|
);
|
2021-06-11 19:00:06 +00:00
|
|
|
|
2021-02-02 18:02:40 +00:00
|
|
|
let energy = AttackEffect::new(None, CombatEffect::EnergyReward(energy))
|
2021-01-28 18:50:56 +00:00
|
|
|
.with_requirement(CombatRequirement::AnyDamage);
|
2021-06-11 19:00:06 +00:00
|
|
|
|
2021-07-10 16:04:12 +00:00
|
|
|
let mut damage = AttackDamage::new(
|
2021-02-02 18:02:40 +00:00
|
|
|
Damage {
|
|
|
|
source: DamageSource::Melee,
|
2021-05-06 18:50:16 +00:00
|
|
|
kind: self.static_data.stage_data[stage_index].damage_kind,
|
2021-02-02 18:02:40 +00:00
|
|
|
value: damage as f32,
|
|
|
|
},
|
|
|
|
Some(GroupTarget::OutOfGroup),
|
2021-07-10 16:04:12 +00:00
|
|
|
);
|
|
|
|
if let Some(effect) = self.static_data.stage_data[stage_index].damage_effect {
|
|
|
|
damage = damage.with_effect(effect);
|
|
|
|
}
|
2021-06-11 19:00:06 +00:00
|
|
|
|
2021-03-09 03:53:58 +00:00
|
|
|
let (crit_chance, crit_mult) =
|
|
|
|
get_crit_data(data, self.static_data.ability_info);
|
2021-06-11 19:00:06 +00:00
|
|
|
|
2021-01-28 18:50:56 +00:00
|
|
|
let attack = Attack::default()
|
|
|
|
.with_damage(damage)
|
2021-03-09 03:53:58 +00:00
|
|
|
.with_crit(crit_chance, crit_mult)
|
2021-01-30 04:40:03 +00:00
|
|
|
.with_effect(energy)
|
2021-01-31 17:33:22 +00:00
|
|
|
.with_effect(poise)
|
2021-02-27 19:55:06 +00:00
|
|
|
.with_effect(knockback)
|
|
|
|
.with_combo_increment();
|
2021-01-26 03:53:52 +00:00
|
|
|
|
2021-02-02 18:02:40 +00:00
|
|
|
data.updater.insert(data.entity, Melee {
|
2021-01-26 02:50:16 +00:00
|
|
|
attack,
|
2020-09-21 22:38:01 +00:00
|
|
|
range: self.static_data.stage_data[stage_index].range,
|
|
|
|
max_angle: self.static_data.stage_data[stage_index].angle.to_radians(),
|
|
|
|
applied: false,
|
|
|
|
hit_count: 0,
|
2021-03-21 20:09:59 +00:00
|
|
|
break_block: data
|
|
|
|
.inputs
|
2021-09-14 01:51:54 +00:00
|
|
|
.break_block_pos
|
2021-03-21 17:45:01 +00:00
|
|
|
.map(|p| {
|
|
|
|
(
|
|
|
|
p.map(|e| e.floor() as i32),
|
|
|
|
self.static_data.ability_info.tool,
|
|
|
|
)
|
|
|
|
})
|
|
|
|
.filter(|(_, tool)| tool == &Some(ToolKind::Pick)),
|
2020-09-21 22:38:01 +00:00
|
|
|
});
|
2021-06-11 19:00:06 +00:00
|
|
|
} else if self.timer < self.static_data.stage_data[stage_index].base_swing_duration
|
|
|
|
{
|
2021-08-29 23:23:34 +00:00
|
|
|
handle_orientation(
|
|
|
|
data,
|
|
|
|
&mut update,
|
|
|
|
0.4 * self.static_data.ori_modifier,
|
|
|
|
None,
|
|
|
|
);
|
2021-04-30 02:59:29 +00:00
|
|
|
|
2020-09-21 22:38:01 +00:00
|
|
|
// Forward movement
|
2021-05-26 02:20:27 +00:00
|
|
|
handle_forced_movement(data, &mut update, ForcedMovement::Forward {
|
|
|
|
strength: self.static_data.stage_data[stage_index].forward_movement,
|
|
|
|
});
|
2020-09-10 02:58:28 +00:00
|
|
|
|
2020-09-21 22:38:01 +00:00
|
|
|
// Swings
|
|
|
|
update.character = CharacterState::ComboMelee(Data {
|
|
|
|
static_data: self.static_data.clone(),
|
2021-05-30 19:39:30 +00:00
|
|
|
timer: tick_attack_or_default(data, self.timer, Some(speed_modifer)),
|
2020-10-27 22:16:17 +00:00
|
|
|
..*self
|
2020-09-21 22:38:01 +00:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
// Transitions to recover section of stage
|
|
|
|
update.character = CharacterState::ComboMelee(Data {
|
|
|
|
static_data: self.static_data.clone(),
|
|
|
|
timer: Duration::default(),
|
|
|
|
stage_section: StageSection::Recover,
|
2020-10-27 22:16:17 +00:00
|
|
|
..*self
|
2020-09-21 22:38:01 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
StageSection::Recover => {
|
|
|
|
if self.timer < self.static_data.stage_data[stage_index].base_recover_duration {
|
2021-08-29 23:23:34 +00:00
|
|
|
handle_orientation(
|
|
|
|
data,
|
|
|
|
&mut update,
|
|
|
|
0.8 * self.static_data.ori_modifier,
|
|
|
|
None,
|
|
|
|
);
|
2020-09-21 22:38:01 +00:00
|
|
|
// Recovers
|
|
|
|
update.character = CharacterState::ComboMelee(Data {
|
|
|
|
static_data: self.static_data.clone(),
|
2021-05-30 19:39:30 +00:00
|
|
|
timer: tick_attack_or_default(data, self.timer, Some(speed_modifer)),
|
2021-03-12 21:01:30 +00:00
|
|
|
..*self
|
2020-09-21 22:38:01 +00:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
// Done
|
2021-03-14 18:42:39 +00:00
|
|
|
if input_is_pressed(data, self.static_data.ability_info.input) {
|
2021-10-13 02:03:18 +00:00
|
|
|
reset_state(self, data, output_events, &mut update);
|
2021-03-14 15:19:22 +00:00
|
|
|
} else {
|
2021-10-05 00:15:58 +00:00
|
|
|
update.character =
|
|
|
|
CharacterState::Wielding(wielding::Data { is_sneaking: false });
|
2021-03-12 21:01:30 +00:00
|
|
|
}
|
2020-09-21 22:38:01 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
_ => {
|
|
|
|
// If it somehow ends up in an incorrect stage section
|
2021-10-05 00:15:58 +00:00
|
|
|
update.character = CharacterState::Wielding(wielding::Data { is_sneaking: false });
|
2020-09-21 22:38:01 +00:00
|
|
|
// Make sure attack component is removed
|
2021-02-02 18:02:40 +00:00
|
|
|
data.updater.remove::<Melee>(data.entity);
|
2020-09-21 22:38:01 +00:00
|
|
|
},
|
2020-09-04 01:54:59 +00:00
|
|
|
}
|
|
|
|
|
2021-03-14 20:35:28 +00:00
|
|
|
// At end of state logic so an interrupt isn't overwritten
|
|
|
|
if !input_is_pressed(data, self.static_data.ability_info.input) {
|
|
|
|
handle_state_interrupt(data, &mut update, self.static_data.is_interruptible);
|
|
|
|
}
|
|
|
|
|
2021-03-12 21:01:30 +00:00
|
|
|
update
|
|
|
|
}
|
2020-09-04 01:54:59 +00:00
|
|
|
}
|
2021-03-12 21:01:30 +00:00
|
|
|
|
2021-10-13 02:03:18 +00:00
|
|
|
fn reset_state(
|
|
|
|
data: &Data,
|
|
|
|
join: &JoinData,
|
|
|
|
output_events: &mut OutputEvents,
|
|
|
|
update: &mut StateUpdate,
|
|
|
|
) {
|
|
|
|
handle_input(
|
|
|
|
join,
|
|
|
|
output_events,
|
|
|
|
update,
|
|
|
|
data.static_data.ability_info.input,
|
|
|
|
);
|
2021-03-12 21:01:30 +00:00
|
|
|
|
|
|
|
if let CharacterState::ComboMelee(c) = &mut update.character {
|
|
|
|
c.stage = (data.stage % data.static_data.num_stages) + 1;
|
|
|
|
}
|
|
|
|
}
|