Can move around, so character state system runs

Hotbar now visible
Can't yet activate skillbar abilities, only M1 and M2
This commit is contained in:
Sam 2022-01-20 15:26:35 -05:00
parent edb0c87c29
commit fe1db1e9e0
8 changed files with 59 additions and 51 deletions

View File

@ -653,7 +653,8 @@ impl CharacterAbility {
scales_with_combo, scales_with_combo,
.. ..
} => { } => {
((*scales_with_combo && data.combo.counter() > 0) | !*scales_with_combo) ((*scales_with_combo && data.combo.map_or(false, |c| c.counter() > 0))
| !*scales_with_combo)
&& update.energy.try_change_by(-*energy_cost).is_ok() && update.energy.try_change_by(-*energy_cost).is_ok()
}, },
CharacterAbility::ComboMelee { .. } CharacterAbility::ComboMelee { .. }
@ -2096,7 +2097,7 @@ impl From<(&CharacterAbility, AbilityInfo, &JoinData<'_>)> for CharacterState {
range: *range, range: *range,
ability_info, ability_info,
scales_with_combo: *scales_with_combo, scales_with_combo: *scales_with_combo,
combo_at_cast: data.combo.counter(), combo_at_cast: data.combo.map_or(0, |c| c.counter()),
specifier: *specifier, specifier: *specifier,
}, },
timer: Duration::default(), timer: Duration::default(),

View File

@ -124,9 +124,9 @@ pub struct JoinData<'a> {
pub updater: &'a LazyUpdate, pub updater: &'a LazyUpdate,
pub stats: &'a Stats, pub stats: &'a Stats,
pub skill_set: &'a SkillSet, pub skill_set: &'a SkillSet,
pub active_abilities: &'a ActiveAbilities, pub active_abilities: Option<&'a ActiveAbilities>,
pub msm: &'a MaterialStatManifest, pub msm: &'a MaterialStatManifest,
pub combo: &'a Combo, pub combo: Option<&'a Combo>,
pub alignment: Option<&'a comp::Alignment>, pub alignment: Option<&'a comp::Alignment>,
pub terrain: &'a TerrainGrid, pub terrain: &'a TerrainGrid,
} }
@ -150,8 +150,8 @@ pub struct JoinStruct<'a> {
pub beam: Option<&'a Beam>, pub beam: Option<&'a Beam>,
pub stat: &'a Stats, pub stat: &'a Stats,
pub skill_set: &'a SkillSet, pub skill_set: &'a SkillSet,
pub active_abilities: &'a ActiveAbilities, pub active_abilities: Option<&'a ActiveAbilities>,
pub combo: &'a Combo, pub combo: Option<&'a Combo>,
pub alignment: Option<&'a comp::Alignment>, pub alignment: Option<&'a comp::Alignment>,
pub terrain: &'a TerrainGrid, pub terrain: &'a TerrainGrid,
} }

View File

@ -160,6 +160,8 @@ impl CharacterBehavior for Data {
fn behavior(&self, data: &JoinData, output_events: &mut OutputEvents) -> StateUpdate { fn behavior(&self, data: &JoinData, output_events: &mut OutputEvents) -> StateUpdate {
let mut update = StateUpdate::from(data); let mut update = StateUpdate::from(data);
let combo_counter = data.combo.map_or(0, |c| c.counter());
handle_move(data, &mut update, 0.4); handle_move(data, &mut update, 0.4);
// Index should be `self.stage - 1`, however in cases of client-server desync // Index should be `self.stage - 1`, however in cases of client-server desync
@ -173,11 +175,7 @@ impl CharacterBehavior for Data {
let speed_modifer = 1.0 let speed_modifer = 1.0
+ self.static_data.max_speed_increase + self.static_data.max_speed_increase
* (1.0 * (1.0 - self.static_data.speed_increase.powi(combo_counter as i32));
- self
.static_data
.speed_increase
.powi(data.combo.counter() as i32));
match self.stage_section { match self.stage_section {
StageSection::Buildup => { StageSection::Buildup => {
@ -225,7 +223,7 @@ impl CharacterBehavior for Data {
+ (self + (self
.static_data .static_data
.scales_from_combo .scales_from_combo
.min(data.combo.counter() / self.static_data.num_stages) .min(combo_counter / self.static_data.num_stages)
as f32) as f32)
* self.static_data.stage_data[stage_index].damage_increase; * self.static_data.stage_data[stage_index].damage_increase;
@ -233,7 +231,7 @@ impl CharacterBehavior for Data {
+ (self + (self
.static_data .static_data
.scales_from_combo .scales_from_combo
.min(data.combo.counter() / self.static_data.num_stages) .min(combo_counter / self.static_data.num_stages)
as f32) as f32)
* self.static_data.stage_data[stage_index].poise_damage_increase; * self.static_data.stage_data[stage_index].poise_damage_increase;
let poise = AttackEffect::new( let poise = AttackEffect::new(
@ -253,7 +251,7 @@ impl CharacterBehavior for Data {
let energy = self.static_data.max_energy_gain.min( let energy = self.static_data.max_energy_gain.min(
self.static_data.initial_energy_gain self.static_data.initial_energy_gain
+ data.combo.counter() as f32 * self.static_data.energy_increase, + combo_counter as f32 * self.static_data.energy_increase,
); );
let energy = AttackEffect::new(None, CombatEffect::EnergyReward(energy)) let energy = AttackEffect::new(None, CombatEffect::EnergyReward(energy))

View File

@ -861,12 +861,14 @@ fn handle_ability(data: &JoinData<'_>, update: &mut StateUpdate, input: InputKin
if let Some(ability_input) = input.into() { if let Some(ability_input) = input.into() {
if let Some((ability, from_offhand)) = data if let Some((ability, from_offhand)) = data
.active_abilities .active_abilities
.activate_ability( .and_then(|a| {
ability_input, a.activate_ability(
data.inventory, ability_input,
data.skill_set, data.inventory,
Some(data.body), data.skill_set,
) Some(data.body),
)
})
.filter(|(ability, _)| ability.requirements_paid(data, update)) .filter(|(ability, _)| ability.requirements_paid(data, update))
{ {
update.character = CharacterState::from(( update.character = CharacterState::from((

View File

@ -132,10 +132,10 @@ impl<'a> System<'a> for Sys {
( (
&read_data.stats, &read_data.stats,
&read_data.skill_sets, &read_data.skill_sets,
&read_data.active_abilities, read_data.active_abilities.maybe(),
read_data.is_riders.maybe(), read_data.is_riders.maybe(),
), ),
&read_data.combos, read_data.combos.maybe(),
) )
.join() .join()
{ {

View File

@ -2788,7 +2788,6 @@ impl Hud {
Some(inventory), Some(inventory),
Some(energy), Some(energy),
Some(skillset), Some(skillset),
Some(active_abilities),
Some(body), Some(body),
Some(_character_state), Some(_character_state),
Some(_controller), Some(_controller),
@ -2797,7 +2796,6 @@ impl Hud {
inventories.get(entity), inventories.get(entity),
energies.get(entity), energies.get(entity),
skillsets.get(entity), skillsets.get(entity),
active_abilities.get(entity),
bodies.get(entity), bodies.get(entity),
character_states.get(entity), character_states.get(entity),
controllers.get(entity).map(|c| &c.inputs), controllers.get(entity).map(|c| &c.inputs),
@ -2813,7 +2811,7 @@ impl Hud {
inventory, inventory,
energy, energy,
skillset, skillset,
active_abilities, active_abilities.get(entity),
body, body,
//&character_state, //&character_state,
self.pulse, self.pulse,

View File

@ -250,7 +250,7 @@ pub struct Skillbar<'a> {
inventory: &'a Inventory, inventory: &'a Inventory,
energy: &'a Energy, energy: &'a Energy,
skillset: &'a SkillSet, skillset: &'a SkillSet,
active_abilities: &'a ActiveAbilities, active_abilities: Option<&'a ActiveAbilities>,
body: &'a Body, body: &'a Body,
// character_state: &'a CharacterState, // character_state: &'a CharacterState,
// controller: &'a ControllerInputs, // controller: &'a ControllerInputs,
@ -279,7 +279,7 @@ impl<'a> Skillbar<'a> {
inventory: &'a Inventory, inventory: &'a Inventory,
energy: &'a Energy, energy: &'a Energy,
skillset: &'a SkillSet, skillset: &'a SkillSet,
active_abilities: &'a ActiveAbilities, active_abilities: Option<&'a ActiveAbilities>,
body: &'a Body, body: &'a Body,
// character_state: &'a CharacterState, // character_state: &'a CharacterState,
pulse: f32, pulse: f32,
@ -607,9 +607,11 @@ impl<'a> Skillbar<'a> {
.get_by_hash(i) .get_by_hash(i)
.map(|item| (item.name(), item.description())), .map(|item| (item.name(), item.description())),
hotbar::SlotContents::Ability(i) => active_abilities hotbar::SlotContents::Ability(i) => active_abilities
.auxiliary_set(Some(inventory), Some(skill_set)) .and_then(|a| {
.get(i) a.auxiliary_set(Some(inventory), Some(skill_set))
.and_then(|a| Ability::from(*a).ability_id(Some(inventory))) .get(i)
.and_then(|a| Ability::from(*a).ability_id(Some(inventory)))
})
.map(util::ability_description), .map(util::ability_description),
}) })
}; };
@ -679,8 +681,9 @@ impl<'a> Skillbar<'a> {
.right_from(state.ids.slot5, slot_offset) .right_from(state.ids.slot5, slot_offset)
.set(state.ids.m1_slot_bg, ui); .set(state.ids.m1_slot_bg, ui);
let primary_ability_id = let primary_ability_id = self
Ability::from(self.active_abilities.primary).ability_id(Some(self.inventory)); .active_abilities
.and_then(|a| Ability::from(a.primary).ability_id(Some(self.inventory)));
Button::image( Button::image(
primary_ability_id.map_or(self.imgs.nothing, |id| util::ability_image(self.imgs, id)), primary_ability_id.map_or(self.imgs.nothing, |id| util::ability_image(self.imgs, id)),
@ -694,8 +697,9 @@ impl<'a> Skillbar<'a> {
.right_from(state.ids.m1_slot_bg, slot_offset) .right_from(state.ids.m1_slot_bg, slot_offset)
.set(state.ids.m2_slot_bg, ui); .set(state.ids.m2_slot_bg, ui);
let secondary_ability_id = let secondary_ability_id = self
Ability::from(self.active_abilities.secondary).ability_id(Some(self.inventory)); .active_abilities
.and_then(|a| Ability::from(a.secondary).ability_id(Some(self.inventory)));
Button::image( Button::image(
secondary_ability_id.map_or(self.imgs.nothing, |id| util::ability_image(self.imgs, id)), secondary_ability_id.map_or(self.imgs.nothing, |id| util::ability_image(self.imgs, id)),
@ -706,12 +710,14 @@ impl<'a> Skillbar<'a> {
if self.energy.current() if self.energy.current()
>= self >= self
.active_abilities .active_abilities
.activate_ability( .and_then(|a| {
AbilityInput::Secondary, a.activate_ability(
Some(self.inventory), AbilityInput::Secondary,
self.skillset, Some(self.inventory),
Some(self.body), self.skillset,
) Some(self.body),
)
})
.map_or(0.0, |(a, _)| a.get_energy_cost()) .map_or(0.0, |(a, _)| a.get_energy_cost())
{ {
Color::Rgba(1.0, 1.0, 1.0, 1.0) Color::Rgba(1.0, 1.0, 1.0, 1.0)

View File

@ -120,7 +120,7 @@ type HotbarSource<'a> = (
&'a Inventory, &'a Inventory,
&'a Energy, &'a Energy,
&'a SkillSet, &'a SkillSet,
&'a ActiveAbilities, Option<&'a ActiveAbilities>,
&'a Body, &'a Body,
); );
type HotbarImageSource<'a> = (&'a ItemImgs, &'a img_ids::Imgs); type HotbarImageSource<'a> = (&'a ItemImgs, &'a img_ids::Imgs);
@ -142,21 +142,24 @@ impl<'a> SlotKey<HotbarSource<'a>, HotbarImageSource<'a>> for HotbarSlot {
} }
}, },
hotbar::SlotContents::Ability(i) => { hotbar::SlotContents::Ability(i) => {
let ability_id = active_abilities let ability_id = active_abilities.and_then(|a| {
.auxiliary_set(Some(inventory), Some(skillset)) a.auxiliary_set(Some(inventory), Some(skillset))
.get(i) .get(i)
.and_then(|a| Ability::from(*a).ability_id(Some(inventory))); .and_then(|a| Ability::from(*a).ability_id(Some(inventory)))
});
ability_id ability_id
.map(|id| HotbarImage::Ability(id.to_string())) .map(|id| HotbarImage::Ability(id.to_string()))
.and_then(|image| { .and_then(|image| {
active_abilities active_abilities
.activate_ability( .and_then(|a| {
AbilityInput::Auxiliary(i), a.activate_ability(
Some(inventory), AbilityInput::Auxiliary(i),
skillset, Some(inventory),
Some(body), skillset,
) Some(body),
)
})
.map(|(ability, _)| { .map(|(ability, _)| {
( (
image, image,