diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index d1f7a5945b..4a086fb5d7 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -850,14 +850,8 @@ impl CharacterAbility { /// applicable. pub fn requirements_paid(&self, data: &JoinData, update: &mut StateUpdate) -> bool { let from_meta = { - let AbilityMeta { - requirements: AbilityRequirements { stance }, - .. - } = self.ability_meta(); - stance.map_or(true, |req_stance| { - data.stance - .map_or(false, |char_stance| req_stance == *char_stance) - }) + let AbilityMeta { requirements, .. } = self.ability_meta(); + requirements.requirements_met(data.stance) }; from_meta && match self { @@ -2894,6 +2888,15 @@ pub struct AbilityRequirements { pub stance: Option, } +impl AbilityRequirements { + pub fn requirements_met(&self, stance: Option<&Stance>) -> bool { + let AbilityRequirements { stance: req_stance } = self; + req_stance.map_or(true, |req_stance| { + stance.map_or(false, |char_stance| req_stance == *char_stance) + }) + } +} + #[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Hash, PartialOrd, Ord)] pub enum SwordStance { Crippling, diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index 1799795819..cc4866a9a5 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -3009,6 +3009,7 @@ impl Hud { context, combos.get(entity), char_states.get(entity), + stances.get(entity), ) .set(self.ids.skillbar, ui_widgets) { diff --git a/voxygen/src/hud/skillbar.rs b/voxygen/src/hud/skillbar.rs index 3b44645d39..54e0bae0e1 100644 --- a/voxygen/src/hud/skillbar.rs +++ b/voxygen/src/hud/skillbar.rs @@ -24,7 +24,7 @@ use std::borrow::Cow; use client::{self, Client}; use common::comp::{ self, - ability::AbilityInput, + ability::{AbilityInput, Stance}, item::{ tool::{AbilityContext, ToolKind}, ItemDesc, MaterialStatManifest, @@ -314,6 +314,7 @@ pub struct Skillbar<'a> { context: AbilityContext, combo: Option<&'a Combo>, char_state: Option<&'a CharacterState>, + stance: Option<&'a Stance>, } impl<'a> Skillbar<'a> { @@ -346,6 +347,7 @@ impl<'a> Skillbar<'a> { context: AbilityContext, combo: Option<&'a Combo>, char_state: Option<&'a CharacterState>, + stance: Option<&'a Stance>, ) -> Self { Self { client, @@ -376,6 +378,7 @@ impl<'a> Skillbar<'a> { context, combo, char_state, + stance, } } @@ -926,6 +929,7 @@ impl<'a> Skillbar<'a> { self.context, self.combo, self.char_state, + self.stance, ); let image_source = (self.item_imgs, self.imgs); @@ -1007,7 +1011,7 @@ impl<'a> Skillbar<'a> { // Helper let tooltip_text = |slot| { - let (hotbar, inventory, _, skill_set, active_abilities, _, context, _, _) = + let (hotbar, inventory, _, skill_set, active_abilities, _, context, _, _, _) = content_source; hotbar.get(slot).and_then(|content| match content { hotbar::SlotContents::Inventory(i, _) => inventory @@ -1154,6 +1158,7 @@ impl<'a> Skillbar<'a> { .map_or(false, |(a, _)| { self.energy.current() >= a.energy_cost() && self.combo.map_or(false, |c| c.counter() >= a.combo_cost()) + && a.ability_meta().requirements.requirements_met(self.stance) }) { Color::Rgba(1.0, 1.0, 1.0, 1.0) diff --git a/voxygen/src/hud/slots.rs b/voxygen/src/hud/slots.rs index 8dc84bce97..04e52acc6e 100644 --- a/voxygen/src/hud/slots.rs +++ b/voxygen/src/hud/slots.rs @@ -11,6 +11,7 @@ use common::{ item::tool::{AbilityContext, ToolKind}, slot::InvSlotId, ActiveAbilities, Body, CharacterState, Combo, Energy, Inventory, Item, ItemKey, SkillSet, + Stance, }, recipe::ComponentRecipeBook, }; @@ -131,6 +132,7 @@ type HotbarSource<'a> = ( AbilityContext, Option<&'a Combo>, Option<&'a CharacterState>, + Option<&'a Stance>, ); type HotbarImageSource<'a> = (&'a ItemImgs, &'a img_ids::Imgs); @@ -139,7 +141,18 @@ impl<'a> SlotKey, HotbarImageSource<'a>> for HotbarSlot { fn image_key( &self, - (hotbar, inventory, energy, skillset, active_abilities, body, context, combo, char_state): &HotbarSource<'a>, + ( + hotbar, + inventory, + energy, + skillset, + active_abilities, + body, + context, + combo, + char_state, + stance, + ): &HotbarSource<'a>, ) -> Option<(Self::ImageKey, Option)> { const GREYED_OUT: Color = Color::Rgba(0.3, 0.3, 0.3, 0.8); hotbar.get(*self).and_then(|contents| match contents { @@ -179,6 +192,10 @@ impl<'a> SlotKey, HotbarImageSource<'a>> for HotbarSlot { if energy.current() >= ability.energy_cost() && combo .map_or(false, |c| c.counter() >= ability.combo_cost()) + && ability + .ability_meta() + .requirements + .requirements_met(*stance) { Some(Color::Rgba(1.0, 1.0, 1.0, 1.0)) } else {