Addressed comments

This commit is contained in:
Sam 2020-09-21 17:38:01 -05:00
parent 8ab0d5e5e0
commit 2ff59c9f60
10 changed files with 608 additions and 611 deletions

View File

@ -381,19 +381,21 @@ impl From<&CharacterAbility> for CharacterState {
max_speed_increase, max_speed_increase,
is_interruptible, is_interruptible,
} => CharacterState::ComboMelee(combo_melee::Data { } => CharacterState::ComboMelee(combo_melee::Data {
stage: 1, static_data: combo_melee::StaticData {
num_stages: stage_data.len() as u32, num_stages: stage_data.len() as u32,
combo: 0,
stage_data: stage_data.clone(), stage_data: stage_data.clone(),
initial_energy_gain: *initial_energy_gain, initial_energy_gain: *initial_energy_gain,
max_energy_gain: *max_energy_gain, max_energy_gain: *max_energy_gain,
energy_increase: *energy_increase, energy_increase: *energy_increase,
timer: Duration::default(),
stage_section: StageSection::Buildup,
next_stage: false,
speed_increase: 1.0 - *speed_increase, speed_increase: 1.0 - *speed_increase,
max_speed_increase: *max_speed_increase - 1.0, max_speed_increase: *max_speed_increase - 1.0,
is_interruptible: *is_interruptible, is_interruptible: *is_interruptible,
},
stage: 1,
combo: 0,
timer: Duration::default(),
stage_section: StageSection::Buildup,
next_stage: false,
}), }),
CharacterAbility::LeapMelee { CharacterAbility::LeapMelee {
energy_cost: _, energy_cost: _,

View File

@ -124,8 +124,9 @@ impl LoadoutBuilder {
}; };
let loadout = match body { let loadout = match body {
Body::Humanoid(_) => match is_giant { Body::Humanoid(_) => {
true => Loadout { if is_giant {
Loadout {
active_item, active_item,
second_item: None, second_item: None,
shoulder: Some(Item::new_from_asset_expect( shoulder: Some(Item::new_from_asset_expect(
@ -153,8 +154,9 @@ impl LoadoutBuilder {
glider: None, glider: None,
head: None, head: None,
tabard: None, tabard: None,
}, }
false => match alignment { } else {
match alignment {
Alignment::Npc => Loadout { Alignment::Npc => Loadout {
active_item, active_item,
second_item: None, second_item: None,
@ -220,13 +222,16 @@ impl LoadoutBuilder {
)), )),
ring: None, ring: None,
neck: None, neck: None,
lantern: Some(Item::new_from_asset_expect("common.items.lantern.black_0")), lantern: Some(Item::new_from_asset_expect(
"common.items.lantern.black_0",
)),
glider: None, glider: None,
head: None, head: None,
tabard: None, tabard: None,
}, },
_ => LoadoutBuilder::animal(body).build(), _ => LoadoutBuilder::animal(body).build(),
}, }
}
}, },
Body::Golem(golem) => match golem.species { Body::Golem(golem) => match golem.species {
golem::Species::StoneGolem => Loadout { golem::Species::StoneGolem => Loadout {

View File

@ -33,16 +33,11 @@ pub struct Stage {
pub forward_movement: f32, pub forward_movement: f32,
} }
/// A sequence of attacks that can incrementally become faster and more
/// damaging.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct Data { /// Separated out to condense update portions of character state
/// Indicates what stage the combo is in pub struct StaticData {
pub stage: u32,
/// Indicates number of stages in combo /// Indicates number of stages in combo
pub num_stages: u32, pub num_stages: u32,
/// Number of consecutive strikes
pub combo: u32,
/// Data for each stage /// Data for each stage
pub stage_data: Vec<Stage>, pub stage_data: Vec<Stage>,
/// Initial energy gain per strike /// Initial energy gain per strike
@ -51,12 +46,6 @@ pub struct Data {
pub max_energy_gain: u32, pub max_energy_gain: u32,
/// Energy gain increase per combo /// Energy gain increase per combo
pub energy_increase: u32, pub energy_increase: u32,
/// Timer for each stage
pub timer: Duration,
/// Checks what section a stage is in
pub stage_section: StageSection,
/// Whether the state should go onto the next stage
pub next_stage: bool,
/// (100% - speed_increase) is percentage speed increases from current to /// (100% - speed_increase) is percentage speed increases from current to
/// max when combo increases /// max when combo increases
pub speed_increase: f32, pub speed_increase: f32,
@ -65,6 +54,24 @@ pub struct Data {
/// Whether the state can be interrupted by other abilities /// Whether the state can be interrupted by other abilities
pub is_interruptible: bool, pub is_interruptible: bool,
} }
/// 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,
/// Indicates what stage the combo is in
pub stage: u32,
/// Number of consecutive strikes
pub combo: u32,
/// Timer for each stage
pub timer: Duration,
/// Checks what section a stage is in
pub stage_section: StageSection,
/// Whether the state should go onto the next stage
pub next_stage: bool,
}
impl CharacterBehavior for Data { impl CharacterBehavior for Data {
fn behavior(&self, data: &JoinData) -> StateUpdate { fn behavior(&self, data: &JoinData) -> StateUpdate {
@ -76,7 +83,7 @@ impl CharacterBehavior for Data {
let stage_index = (self.stage - 1) as usize; let stage_index = (self.stage - 1) as usize;
// Allows for other states to interrupt this state // Allows for other states to interrupt this state
if self.is_interruptible && !data.inputs.primary.is_pressed() { if self.static_data.is_interruptible && !data.inputs.primary.is_pressed() {
handle_interrupt(data, &mut update); handle_interrupt(data, &mut update);
match update.character { match update.character {
CharacterState::ComboMelee(_) => {}, CharacterState::ComboMelee(_) => {},
@ -86,182 +93,147 @@ impl CharacterBehavior for Data {
} }
} }
if self.stage_section == StageSection::Buildup match self.stage_section {
&& self.timer < self.stage_data[stage_index].base_buildup_duration StageSection::Buildup => {
{ if self.timer < self.static_data.stage_data[stage_index].base_buildup_duration {
// Build up // Build up
update.character = CharacterState::ComboMelee(Data { update.character = CharacterState::ComboMelee(Data {
static_data: self.static_data.clone(),
stage: self.stage, stage: self.stage,
num_stages: self.num_stages,
combo: self.combo, combo: self.combo,
stage_data: self.stage_data.clone(),
initial_energy_gain: self.initial_energy_gain,
max_energy_gain: self.max_energy_gain,
energy_increase: self.energy_increase,
timer: self timer: self
.timer .timer
.checked_add(Duration::from_secs_f32( .checked_add(Duration::from_secs_f32(
(1.0 + self.max_speed_increase (1.0 + self.static_data.max_speed_increase
* (1.0 - self.speed_increase.powi(self.combo as i32))) * (1.0
- self.static_data.speed_increase.powi(self.combo as i32)))
* data.dt.0, * data.dt.0,
)) ))
.unwrap_or_default(), .unwrap_or_default(),
stage_section: self.stage_section, stage_section: self.stage_section,
next_stage: self.next_stage, next_stage: self.next_stage,
speed_increase: self.speed_increase,
max_speed_increase: self.max_speed_increase,
is_interruptible: self.is_interruptible,
}); });
} else if self.stage_section == StageSection::Buildup { } else {
// Transitions to swing section of stage // Transitions to swing section of stage
update.character = CharacterState::ComboMelee(Data { update.character = CharacterState::ComboMelee(Data {
static_data: self.static_data.clone(),
stage: self.stage, stage: self.stage,
num_stages: self.num_stages,
combo: self.combo, combo: self.combo,
stage_data: self.stage_data.clone(),
initial_energy_gain: self.initial_energy_gain,
max_energy_gain: self.max_energy_gain,
energy_increase: self.energy_increase,
timer: Duration::default(), timer: Duration::default(),
stage_section: StageSection::Swing, stage_section: StageSection::Swing,
next_stage: self.next_stage, next_stage: self.next_stage,
speed_increase: self.speed_increase,
max_speed_increase: self.max_speed_increase,
is_interruptible: self.is_interruptible,
}); });
// Hit attempt // Hit attempt
data.updater.insert(data.entity, Attacking { data.updater.insert(data.entity, Attacking {
base_healthchange: -((self.stage_data[stage_index].max_damage.min( base_healthchange: -((self.static_data.stage_data[stage_index]
self.stage_data[stage_index].base_damage .max_damage
+ self.combo / self.num_stages .min(
* self.stage_data[stage_index].damage_increase, self.static_data.stage_data[stage_index].base_damage
+ self.combo / self.static_data.num_stages
* self.static_data.stage_data[stage_index].damage_increase,
)) as i32), )) as i32),
range: self.stage_data[stage_index].range, range: self.static_data.stage_data[stage_index].range,
max_angle: self.stage_data[stage_index].angle.to_radians(), max_angle: self.static_data.stage_data[stage_index].angle.to_radians(),
applied: false, applied: false,
hit_count: 0, hit_count: 0,
knockback: self.stage_data[stage_index].knockback, knockback: self.static_data.stage_data[stage_index].knockback,
}); });
} else if self.stage_section == StageSection::Swing }
&& self.timer < self.stage_data[stage_index].base_swing_duration },
{ StageSection::Swing => {
if self.timer < self.static_data.stage_data[stage_index].base_swing_duration {
// Forward movement // Forward movement
forward_move( forward_move(
data, data,
&mut update, &mut update,
0.3, 0.3,
self.stage_data[stage_index].forward_movement, self.static_data.stage_data[stage_index].forward_movement,
); );
// Swings // Swings
update.character = CharacterState::ComboMelee(Data { update.character = CharacterState::ComboMelee(Data {
static_data: self.static_data.clone(),
stage: self.stage, stage: self.stage,
num_stages: self.num_stages,
combo: self.combo, combo: self.combo,
stage_data: self.stage_data.clone(),
initial_energy_gain: self.initial_energy_gain,
max_energy_gain: self.max_energy_gain,
energy_increase: self.energy_increase,
timer: self timer: self
.timer .timer
.checked_add(Duration::from_secs_f32( .checked_add(Duration::from_secs_f32(
(1.0 + self.max_speed_increase (1.0 + self.static_data.max_speed_increase
* (1.0 - self.speed_increase.powi(self.combo as i32))) * (1.0
- self.static_data.speed_increase.powi(self.combo as i32)))
* data.dt.0, * data.dt.0,
)) ))
.unwrap_or_default(), .unwrap_or_default(),
stage_section: self.stage_section, stage_section: self.stage_section,
next_stage: self.next_stage, next_stage: self.next_stage,
speed_increase: self.speed_increase,
max_speed_increase: self.max_speed_increase,
is_interruptible: self.is_interruptible,
}); });
} else if self.stage_section == StageSection::Swing { } else {
// Transitions to recover section of stage // Transitions to recover section of stage
update.character = CharacterState::ComboMelee(Data { update.character = CharacterState::ComboMelee(Data {
static_data: self.static_data.clone(),
stage: self.stage, stage: self.stage,
num_stages: self.num_stages,
combo: self.combo, combo: self.combo,
stage_data: self.stage_data.clone(),
initial_energy_gain: self.initial_energy_gain,
max_energy_gain: self.max_energy_gain,
energy_increase: self.energy_increase,
timer: Duration::default(), timer: Duration::default(),
stage_section: StageSection::Recover, stage_section: StageSection::Recover,
next_stage: self.next_stage, next_stage: self.next_stage,
speed_increase: self.speed_increase,
max_speed_increase: self.max_speed_increase,
is_interruptible: self.is_interruptible,
}); });
} else if self.stage_section == StageSection::Recover }
&& self.timer < self.stage_data[stage_index].base_recover_duration },
{ StageSection::Recover => {
if self.timer < self.static_data.stage_data[stage_index].base_recover_duration {
// Recovers // Recovers
if data.inputs.primary.is_pressed() { if data.inputs.primary.is_pressed() {
// Checks if state will transition to next stage after recover // Checks if state will transition to next stage after recover
update.character = CharacterState::ComboMelee(Data { update.character = CharacterState::ComboMelee(Data {
static_data: self.static_data.clone(),
stage: self.stage, stage: self.stage,
num_stages: self.num_stages,
combo: self.combo, combo: self.combo,
stage_data: self.stage_data.clone(),
initial_energy_gain: self.initial_energy_gain,
max_energy_gain: self.max_energy_gain,
energy_increase: self.energy_increase,
timer: self timer: self
.timer .timer
.checked_add(Duration::from_secs_f32( .checked_add(Duration::from_secs_f32(
(1.0 + self.max_speed_increase (1.0 + self.static_data.max_speed_increase
* (1.0 - self.speed_increase.powi(self.combo as i32))) * (1.0
- self
.static_data
.speed_increase
.powi(self.combo as i32)))
* data.dt.0, * data.dt.0,
)) ))
.unwrap_or_default(), .unwrap_or_default(),
stage_section: self.stage_section, stage_section: self.stage_section,
next_stage: true, next_stage: true,
speed_increase: self.speed_increase,
max_speed_increase: self.max_speed_increase,
is_interruptible: self.is_interruptible,
}); });
} else { } else {
update.character = CharacterState::ComboMelee(Data { update.character = CharacterState::ComboMelee(Data {
static_data: self.static_data.clone(),
stage: self.stage, stage: self.stage,
num_stages: self.num_stages,
combo: self.combo, combo: self.combo,
stage_data: self.stage_data.clone(),
initial_energy_gain: self.initial_energy_gain,
max_energy_gain: self.max_energy_gain,
energy_increase: self.energy_increase,
timer: self timer: self
.timer .timer
.checked_add(Duration::from_secs_f32( .checked_add(Duration::from_secs_f32(
(1.0 + self.max_speed_increase (1.0 + self.static_data.max_speed_increase
* (1.0 - self.speed_increase.powi(self.combo as i32))) * (1.0
- self
.static_data
.speed_increase
.powi(self.combo as i32)))
* data.dt.0, * data.dt.0,
)) ))
.unwrap_or_default(), .unwrap_or_default(),
stage_section: self.stage_section, stage_section: self.stage_section,
next_stage: self.next_stage, next_stage: self.next_stage,
speed_increase: self.speed_increase,
max_speed_increase: self.max_speed_increase,
is_interruptible: self.is_interruptible,
}); });
} }
} else if self.next_stage { } else if self.next_stage {
// Transitions to buildup section of next stage // Transitions to buildup section of next stage
update.character = CharacterState::ComboMelee(Data { update.character = CharacterState::ComboMelee(Data {
stage: (self.stage % self.num_stages) + 1, static_data: self.static_data.clone(),
num_stages: self.num_stages, stage: (self.stage % self.static_data.num_stages) + 1,
combo: self.combo, combo: self.combo,
stage_data: self.stage_data.clone(),
initial_energy_gain: self.initial_energy_gain,
max_energy_gain: self.max_energy_gain,
energy_increase: self.energy_increase,
timer: Duration::default(), timer: Duration::default(),
stage_section: StageSection::Buildup, stage_section: StageSection::Buildup,
next_stage: false, next_stage: false,
speed_increase: self.speed_increase,
max_speed_increase: self.max_speed_increase,
is_interruptible: self.is_interruptible,
}); });
} else { } else {
// Done // Done
@ -269,28 +241,29 @@ impl CharacterBehavior for Data {
// Make sure attack component is removed // Make sure attack component is removed
data.updater.remove::<Attacking>(data.entity); data.updater.remove::<Attacking>(data.entity);
} }
},
_ => {
// If it somehow ends up in an incorrect stage section
update.character = CharacterState::Wielding;
// Make sure attack component is removed
data.updater.remove::<Attacking>(data.entity);
},
}
// Grant energy on successful hit // Grant energy on successful hit
if let Some(attack) = data.attacking { if let Some(attack) = data.attacking {
if attack.applied && attack.hit_count > 0 { if attack.applied && attack.hit_count > 0 {
let energy = self let energy = self.static_data.max_energy_gain.min(
.max_energy_gain self.static_data.initial_energy_gain
.min(self.initial_energy_gain + self.combo * self.energy_increase) + self.combo * self.static_data.energy_increase,
as i32; ) as i32;
update.character = CharacterState::ComboMelee(Data { update.character = CharacterState::ComboMelee(Data {
static_data: self.static_data.clone(),
stage: self.stage, stage: self.stage,
num_stages: self.num_stages,
combo: self.combo + 1, combo: self.combo + 1,
stage_data: self.stage_data.clone(),
initial_energy_gain: self.initial_energy_gain,
max_energy_gain: self.max_energy_gain,
energy_increase: self.energy_increase,
timer: self.timer, timer: self.timer,
stage_section: self.stage_section, stage_section: self.stage_section,
next_stage: self.next_stage, next_stage: self.next_stage,
speed_increase: self.speed_increase,
max_speed_increase: self.max_speed_increase,
is_interruptible: self.is_interruptible,
}); });
data.updater.remove::<Attacking>(data.entity); data.updater.remove::<Attacking>(data.entity);
update.energy.change_by(energy, EnergySource::HitEnemy); update.energy.change_by(energy, EnergySource::HitEnemy);

View File

@ -73,9 +73,9 @@ impl CharacterBehavior for Data {
} }
} }
if self.stage_section == StageSection::Buildup match self.stage_section {
&& self.timer < self.static_data.buildup_duration StageSection::Buildup => {
{ if self.timer < self.static_data.buildup_duration {
// Build up // Build up
update.character = CharacterState::DashMelee(Data { update.character = CharacterState::DashMelee(Data {
static_data: self.static_data, static_data: self.static_data,
@ -86,8 +86,8 @@ impl CharacterBehavior for Data {
.unwrap_or_default(), .unwrap_or_default(),
stage_section: self.stage_section, stage_section: self.stage_section,
exhausted: self.exhausted, exhausted: self.exhausted,
}) });
} else if self.stage_section == StageSection::Buildup { } else {
// Transitions to charge section of stage // Transitions to charge section of stage
update.character = CharacterState::DashMelee(Data { update.character = CharacterState::DashMelee(Data {
static_data: self.static_data, static_data: self.static_data,
@ -95,9 +95,11 @@ impl CharacterBehavior for Data {
timer: Duration::default(), timer: Duration::default(),
stage_section: StageSection::Charge, stage_section: StageSection::Charge,
exhausted: self.exhausted, exhausted: self.exhausted,
}) });
} else if self.stage_section == StageSection::Charge }
&& (self.timer < self.static_data.charge_duration },
StageSection::Charge => {
if (self.timer < self.static_data.charge_duration
|| (self.static_data.infinite_charge && data.inputs.secondary.is_pressed())) || (self.static_data.infinite_charge && data.inputs.secondary.is_pressed()))
&& update.energy.current() > 0 && update.energy.current() > 0
&& !self.end_charge && !self.end_charge
@ -114,7 +116,8 @@ impl CharacterBehavior for Data {
- self.static_data.base_damage as f32) - self.static_data.base_damage as f32)
* charge_frac * charge_frac
+ self.static_data.base_damage as f32; + self.static_data.base_damage as f32;
let knockback = (self.static_data.max_knockback - self.static_data.base_knockback) let knockback = (self.static_data.max_knockback
- self.static_data.base_knockback)
* charge_frac * charge_frac
+ self.static_data.base_knockback; + self.static_data.base_knockback;
data.updater.insert(data.entity, Attacking { data.updater.insert(data.entity, Attacking {
@ -193,7 +196,7 @@ impl CharacterBehavior for Data {
-(self.static_data.energy_drain as f32 * data.dt.0) as i32, -(self.static_data.energy_drain as f32 * data.dt.0) as i32,
EnergySource::Ability, EnergySource::Ability,
); );
} else if self.stage_section == StageSection::Charge { } else {
// Transitions to swing section of stage // Transitions to swing section of stage
update.character = CharacterState::DashMelee(Data { update.character = CharacterState::DashMelee(Data {
static_data: self.static_data, static_data: self.static_data,
@ -201,10 +204,11 @@ impl CharacterBehavior for Data {
timer: Duration::default(), timer: Duration::default(),
stage_section: StageSection::Swing, stage_section: StageSection::Swing,
exhausted: self.exhausted, exhausted: self.exhausted,
}) });
} else if self.stage_section == StageSection::Swing }
&& self.timer < self.static_data.swing_duration },
{ StageSection::Swing => {
if self.timer < self.static_data.swing_duration {
// Swings // Swings
update.character = CharacterState::DashMelee(Data { update.character = CharacterState::DashMelee(Data {
static_data: self.static_data, static_data: self.static_data,
@ -215,8 +219,8 @@ impl CharacterBehavior for Data {
.unwrap_or_default(), .unwrap_or_default(),
stage_section: self.stage_section, stage_section: self.stage_section,
exhausted: self.exhausted, exhausted: self.exhausted,
}) });
} else if self.stage_section == StageSection::Swing { } else {
// Transitions to recover section of stage // Transitions to recover section of stage
update.character = CharacterState::DashMelee(Data { update.character = CharacterState::DashMelee(Data {
static_data: self.static_data, static_data: self.static_data,
@ -224,10 +228,11 @@ impl CharacterBehavior for Data {
timer: Duration::default(), timer: Duration::default(),
stage_section: StageSection::Recover, stage_section: StageSection::Recover,
exhausted: self.exhausted, exhausted: self.exhausted,
}) });
} else if self.stage_section == StageSection::Recover }
&& self.timer < self.static_data.recover_duration },
{ StageSection::Recover => {
if self.timer < self.static_data.recover_duration {
// Recover // Recover
update.character = CharacterState::DashMelee(Data { update.character = CharacterState::DashMelee(Data {
static_data: self.static_data, static_data: self.static_data,
@ -238,13 +243,15 @@ impl CharacterBehavior for Data {
.unwrap_or_default(), .unwrap_or_default(),
stage_section: self.stage_section, stage_section: self.stage_section,
exhausted: self.exhausted, exhausted: self.exhausted,
}) });
} else { } else {
// Done // Done
update.character = CharacterState::Wielding; update.character = CharacterState::Wielding;
// Make sure attack component is removed // Make sure attack component is removed
data.updater.remove::<Attacking>(data.entity); data.updater.remove::<Attacking>(data.entity);
} }
},
}
update update
} }

View File

@ -70,9 +70,9 @@ impl CharacterBehavior for Data {
} }
} }
if self.stage_section == StageSection::Buildup match self.stage_section {
&& self.timer < self.static_data.buildup_duration StageSection::Buildup => {
{ if self.timer < self.static_data.buildup_duration {
// Build up // Build up
update.character = CharacterState::SpinMelee(Data { update.character = CharacterState::SpinMelee(Data {
static_data: self.static_data, static_data: self.static_data,
@ -84,7 +84,7 @@ impl CharacterBehavior for Data {
stage_section: self.stage_section, stage_section: self.stage_section,
exhausted: self.exhausted, exhausted: self.exhausted,
}); });
} else if self.stage_section == StageSection::Buildup { } else {
// Transitions to swing section of stage // Transitions to swing section of stage
update.character = CharacterState::SpinMelee(Data { update.character = CharacterState::SpinMelee(Data {
static_data: self.static_data, static_data: self.static_data,
@ -93,7 +93,10 @@ impl CharacterBehavior for Data {
stage_section: StageSection::Swing, stage_section: StageSection::Swing,
exhausted: self.exhausted, exhausted: self.exhausted,
}); });
} else if !self.exhausted { }
},
StageSection::Swing => {
if !self.exhausted {
update.character = CharacterState::SpinMelee(Data { update.character = CharacterState::SpinMelee(Data {
static_data: self.static_data, static_data: self.static_data,
timer: Duration::default(), timer: Duration::default(),
@ -110,9 +113,7 @@ impl CharacterBehavior for Data {
hit_count: 0, hit_count: 0,
knockback: self.static_data.knockback, knockback: self.static_data.knockback,
}); });
} else if self.stage_section == StageSection::Swing } else if self.timer < self.static_data.swing_duration {
&& self.timer < self.static_data.swing_duration
{
if !self.static_data.is_helicopter { if !self.static_data.is_helicopter {
forward_move(data, &mut update, 0.1, self.static_data.forward_speed); forward_move(data, &mut update, 0.1, self.static_data.forward_speed);
handle_orientation(data, &mut update, 1.0); handle_orientation(data, &mut update, 1.0);
@ -150,7 +151,7 @@ impl CharacterBehavior for Data {
-(self.static_data.energy_cost as i32), -(self.static_data.energy_cost as i32),
EnergySource::Ability, EnergySource::Ability,
); );
} else if self.stage_section == StageSection::Swing { } else {
// Transitions to recover section of stage // Transitions to recover section of stage
update.character = CharacterState::SpinMelee(Data { update.character = CharacterState::SpinMelee(Data {
static_data: self.static_data, static_data: self.static_data,
@ -158,10 +159,11 @@ impl CharacterBehavior for Data {
spins_remaining: self.spins_remaining, spins_remaining: self.spins_remaining,
stage_section: StageSection::Recover, stage_section: StageSection::Recover,
exhausted: self.exhausted, exhausted: self.exhausted,
}) });
} else if self.stage_section == StageSection::Recover }
&& self.timer < self.static_data.recover_duration },
{ StageSection::Recover => {
if self.timer < self.static_data.recover_duration {
// Recover // Recover
update.character = CharacterState::SpinMelee(Data { update.character = CharacterState::SpinMelee(Data {
static_data: self.static_data, static_data: self.static_data,
@ -172,13 +174,21 @@ impl CharacterBehavior for Data {
spins_remaining: self.spins_remaining, spins_remaining: self.spins_remaining,
stage_section: self.stage_section, stage_section: self.stage_section,
exhausted: self.exhausted, exhausted: self.exhausted,
}) });
} else { } else {
// Done // Done
update.character = CharacterState::Wielding; update.character = CharacterState::Wielding;
// Make sure attack component is removed // Make sure attack component is removed
data.updater.remove::<Attacking>(data.entity); data.updater.remove::<Attacking>(data.entity);
} }
},
_ => {
// If it somehow ends up in an incorrect stage section
update.character = CharacterState::Wielding;
// Make sure attack component is removed
data.updater.remove::<Attacking>(data.entity);
},
}
update update
} }

View File

@ -193,10 +193,6 @@ impl<'a> System<'a> for Sys {
continue; continue;
} }
if entity_other == entity {
continue;
}
let scale_other = scale_other.map(|s| s.0).unwrap_or(1.0); let scale_other = scale_other.map(|s| s.0).unwrap_or(1.0);
let radius_other = collider_other.map(|c| c.get_radius()).unwrap_or(0.5); let radius_other = collider_other.map(|c| c.get_radius()).unwrap_or(0.5);
let z_limits_other = collider_other let z_limits_other = collider_other

View File

@ -114,9 +114,8 @@ fn matches_ability_stage() {
let result = CombatEventMapper::map_event( let result = CombatEventMapper::map_event(
&CharacterState::ComboMelee(states::combo_melee::Data { &CharacterState::ComboMelee(states::combo_melee::Data {
stage: 1, static_data: states::combo_melee::StaticData {
num_stages: 1, num_stages: 1,
combo: 0,
stage_data: vec![states::combo_melee::Stage { stage_data: vec![states::combo_melee::Stage {
stage: 1, stage: 1,
base_damage: 100, base_damage: 100,
@ -133,12 +132,15 @@ fn matches_ability_stage() {
initial_energy_gain: 0, initial_energy_gain: 0,
max_energy_gain: 100, max_energy_gain: 100,
energy_increase: 20, energy_increase: 20,
timer: Duration::default(),
stage_section: states::utils::StageSection::Swing,
next_stage: false,
speed_increase: 0.05, speed_increase: 0.05,
max_speed_increase: 1.8, max_speed_increase: 1.8,
is_interruptible: true, is_interruptible: true,
},
stage: 1,
combo: 0,
timer: Duration::default(),
stage_section: states::utils::StageSection::Swing,
next_stage: false,
}), }),
&PreviousEntityState { &PreviousEntityState {
event: SfxEvent::Idle, event: SfxEvent::Idle,
@ -172,9 +174,8 @@ fn ignores_different_ability_stage() {
let result = CombatEventMapper::map_event( let result = CombatEventMapper::map_event(
&CharacterState::ComboMelee(states::combo_melee::Data { &CharacterState::ComboMelee(states::combo_melee::Data {
stage: 1, static_data: states::combo_melee::StaticData {
num_stages: 1, num_stages: 1,
combo: 0,
stage_data: vec![states::combo_melee::Stage { stage_data: vec![states::combo_melee::Stage {
stage: 1, stage: 1,
base_damage: 100, base_damage: 100,
@ -191,12 +192,15 @@ fn ignores_different_ability_stage() {
initial_energy_gain: 0, initial_energy_gain: 0,
max_energy_gain: 100, max_energy_gain: 100,
energy_increase: 20, energy_increase: 20,
timer: Duration::default(),
stage_section: states::utils::StageSection::Swing,
next_stage: false,
speed_increase: 0.05, speed_increase: 0.05,
max_speed_increase: 1.8, max_speed_increase: 1.8,
is_interruptible: true, is_interruptible: true,
},
stage: 1,
combo: 0,
timer: Duration::default(),
stage_section: states::utils::StageSection::Swing,
next_stage: false,
}), }),
&PreviousEntityState { &PreviousEntityState {
event: SfxEvent::Idle, event: SfxEvent::Idle,

View File

@ -267,7 +267,7 @@ image_ids! {
fire_spell_1: "voxygen.element.icons.fire_spell_0", fire_spell_1: "voxygen.element.icons.fire_spell_0",
snake_arrow_0: "voxygen.element.icons.snake", snake_arrow_0: "voxygen.element.icons.snake",
heal_0: "voxygen.element.icons.heal_0", heal_0: "voxygen.element.icons.heal_0",
sowrd_whirlwind: "voxygen.element.icons.sword_whirlwind", sword_whirlwind: "voxygen.element.icons.sword_whirlwind",
// Buttons // Buttons
button: "voxygen.element.buttons.button", button: "voxygen.element.buttons.button",

View File

@ -145,7 +145,7 @@ impl<'a> SlotKey<HotbarSource<'a>, HotbarImageSource<'a>> for HotbarSlot {
HotbarImage::Item(key) => item_imgs.img_id_or_not_found_img(key.clone()), HotbarImage::Item(key) => item_imgs.img_id_or_not_found_img(key.clone()),
HotbarImage::SnakeArrow => imgs.snake_arrow_0, HotbarImage::SnakeArrow => imgs.snake_arrow_0,
HotbarImage::Fireball => imgs.fire_spell_1, HotbarImage::Fireball => imgs.fire_spell_1,
HotbarImage::SwordWhirlwind => imgs.sowrd_whirlwind, HotbarImage::SwordWhirlwind => imgs.sword_whirlwind,
} }
} }
} }

View File

@ -978,19 +978,19 @@ impl FigureMgr {
let stage_progress = match s.stage_section { let stage_progress = match s.stage_section {
StageSection::Buildup => { StageSection::Buildup => {
stage_time stage_time
/ s.stage_data[stage_index] / s.static_data.stage_data[stage_index]
.base_buildup_duration .base_buildup_duration
.as_secs_f64() .as_secs_f64()
}, },
StageSection::Swing => { StageSection::Swing => {
stage_time stage_time
/ s.stage_data[stage_index] / s.static_data.stage_data[stage_index]
.base_swing_duration .base_swing_duration
.as_secs_f64() .as_secs_f64()
}, },
StageSection::Recover => { StageSection::Recover => {
stage_time stage_time
/ s.stage_data[stage_index] / s.static_data.stage_data[stage_index]
.base_recover_duration .base_recover_duration
.as_secs_f64() .as_secs_f64()
}, },