mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Remove char_state from active_auxiliary_key
This commit is contained in:
parent
4dcf6215d2
commit
3ad227545a
@ -40,9 +40,7 @@ use super::shockwave::ShockwaveDodgeable;
|
||||
|
||||
pub const BASE_ABILITY_LIMIT: usize = 5;
|
||||
|
||||
// FIXME: different AbilitySpec on same ToolKind share the same key
|
||||
// FIXME: only really works with weapons, glider just fallback to (None, None),
|
||||
// but maybe that's ok?
|
||||
// NOTE: different AbilitySpec on same ToolKind share the same key
|
||||
/// Descriptor to pick the right (auxiliary) ability set
|
||||
pub type AuxiliaryKey = (Option<ToolKind>, Option<ToolKind>);
|
||||
|
||||
@ -136,38 +134,27 @@ impl ActiveAbilities {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn active_auxiliary_key(
|
||||
inv: Option<&Inventory>,
|
||||
char_state: Option<&CharacterState>,
|
||||
) -> AuxiliaryKey {
|
||||
let source = AbilitySource::determine(char_state);
|
||||
pub fn active_auxiliary_key(inv: Option<&Inventory>) -> AuxiliaryKey {
|
||||
let tool_kind = |slot| {
|
||||
inv.and_then(|inv| inv.equipped(slot))
|
||||
.and_then(|item| match &*item.kind() {
|
||||
ItemKind::Tool(tool) => Some(tool.kind),
|
||||
_ => None,
|
||||
})
|
||||
};
|
||||
|
||||
match source {
|
||||
AbilitySource::Weapons => {
|
||||
let tool_kind = |slot| {
|
||||
inv.and_then(|inv| inv.equipped(slot))
|
||||
.and_then(|item| match &*item.kind() {
|
||||
ItemKind::Tool(tool) => Some(tool.kind),
|
||||
_ => None,
|
||||
})
|
||||
};
|
||||
|
||||
(
|
||||
tool_kind(EquipSlot::ActiveMainhand),
|
||||
tool_kind(EquipSlot::ActiveOffhand),
|
||||
)
|
||||
},
|
||||
AbilitySource::Glider => (None, None),
|
||||
}
|
||||
(
|
||||
tool_kind(EquipSlot::ActiveMainhand),
|
||||
tool_kind(EquipSlot::ActiveOffhand),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn auxiliary_set(
|
||||
&self,
|
||||
inv: Option<&Inventory>,
|
||||
skill_set: Option<&SkillSet>,
|
||||
char_state: Option<&CharacterState>,
|
||||
) -> Cow<Vec<AuxiliaryAbility>> {
|
||||
let aux_key = Self::active_auxiliary_key(inv, char_state);
|
||||
let aux_key = Self::active_auxiliary_key(inv);
|
||||
|
||||
self.auxiliary_sets
|
||||
.get(&aux_key)
|
||||
@ -180,7 +167,6 @@ impl ActiveAbilities {
|
||||
input: AbilityInput,
|
||||
inventory: Option<&Inventory>,
|
||||
skill_set: Option<&SkillSet>,
|
||||
char_state: Option<&CharacterState>,
|
||||
) -> Ability {
|
||||
match input {
|
||||
AbilityInput::Guard => self.guard.into(),
|
||||
@ -188,7 +174,7 @@ impl ActiveAbilities {
|
||||
AbilityInput::Secondary => self.secondary.into(),
|
||||
AbilityInput::Movement => self.movement.into(),
|
||||
AbilityInput::Auxiliary(index) => self
|
||||
.auxiliary_set(inventory, skill_set, char_state)
|
||||
.auxiliary_set(inventory, skill_set)
|
||||
.get(index)
|
||||
.copied()
|
||||
.map(|a| a.into())
|
||||
@ -208,7 +194,7 @@ impl ActiveAbilities {
|
||||
context: &AbilityContext,
|
||||
// bool is from_offhand
|
||||
) -> Option<(CharacterAbility, bool, SpecifiedAbility)> {
|
||||
let ability = self.get_ability(input, inv, Some(skill_set), char_state);
|
||||
let ability = self.get_ability(input, inv, Some(skill_set));
|
||||
|
||||
let ability_set = |equip_slot| {
|
||||
inv.and_then(|inv| inv.equipped(equip_slot))
|
||||
|
@ -434,8 +434,7 @@ impl<'a> AgentData<'a> {
|
||||
|
||||
agent.combat_state.int_counters[IntCounters::Tactics as usize] = tactic as u8;
|
||||
|
||||
let auxiliary_key =
|
||||
ActiveAbilities::active_auxiliary_key(Some(self.inventory), Some(self.char_state));
|
||||
let auxiliary_key = ActiveAbilities::active_auxiliary_key(Some(self.inventory));
|
||||
let set_sword_ability = |controller: &mut Controller, slot, skill| {
|
||||
controller.push_event(ControlEvent::ChangeAbility {
|
||||
slot,
|
||||
@ -1220,8 +1219,7 @@ impl<'a> AgentData<'a> {
|
||||
|
||||
agent.combat_state.int_counters[IntCounters::Tactic as usize] = tactic as u8;
|
||||
|
||||
let auxiliary_key =
|
||||
ActiveAbilities::active_auxiliary_key(Some(self.inventory), Some(self.char_state));
|
||||
let auxiliary_key = ActiveAbilities::active_auxiliary_key(Some(self.inventory));
|
||||
let set_axe_ability = |controller: &mut Controller, slot, skill| {
|
||||
controller.push_event(ControlEvent::ChangeAbility {
|
||||
slot,
|
||||
|
@ -855,7 +855,6 @@ impl<'a> Widget for Diary<'a> {
|
||||
AbilityInput::Auxiliary(i),
|
||||
Some(self.inventory),
|
||||
Some(self.skill_set),
|
||||
Some(self.char_state),
|
||||
)
|
||||
.ability_id(
|
||||
Some(self.char_state),
|
||||
|
@ -81,10 +81,6 @@ impl State {
|
||||
.state()
|
||||
.read_storage::<comp::SkillSet>()
|
||||
.get(info.viewpoint_entity),
|
||||
client
|
||||
.state()
|
||||
.read_storage::<comp::CharacterState>()
|
||||
.get(info.viewpoint_entity),
|
||||
)
|
||||
.iter()
|
||||
.enumerate()
|
||||
|
@ -4005,20 +4005,12 @@ impl Hud {
|
||||
let me = info.viewpoint_entity;
|
||||
if let Some(active_abilities) = active_abilities.get(me) {
|
||||
let ability_a = active_abilities
|
||||
.auxiliary_set(
|
||||
inventories.get(me),
|
||||
skill_sets.get(me),
|
||||
char_states.get(me),
|
||||
)
|
||||
.auxiliary_set(inventories.get(me), skill_sets.get(me))
|
||||
.get(a)
|
||||
.copied()
|
||||
.unwrap_or(AuxiliaryAbility::Empty);
|
||||
let ability_b = active_abilities
|
||||
.auxiliary_set(
|
||||
inventories.get(me),
|
||||
skill_sets.get(me),
|
||||
char_states.get(me),
|
||||
)
|
||||
.auxiliary_set(inventories.get(me), skill_sets.get(me))
|
||||
.get(b)
|
||||
.copied()
|
||||
.unwrap_or(AuxiliaryAbility::Empty);
|
||||
@ -4163,20 +4155,12 @@ impl Hud {
|
||||
let me = info.viewpoint_entity;
|
||||
if let Some(active_abilities) = active_abilities.get(me) {
|
||||
let ability_a = active_abilities
|
||||
.auxiliary_set(
|
||||
inventories.get(me),
|
||||
skill_sets.get(me),
|
||||
char_states.get(me),
|
||||
)
|
||||
.auxiliary_set(inventories.get(me), skill_sets.get(me))
|
||||
.get(a)
|
||||
.copied()
|
||||
.unwrap_or(AuxiliaryAbility::Empty);
|
||||
let ability_b = active_abilities
|
||||
.auxiliary_set(
|
||||
inventories.get(me),
|
||||
skill_sets.get(me),
|
||||
char_states.get(me),
|
||||
)
|
||||
.auxiliary_set(inventories.get(me), skill_sets.get(me))
|
||||
.get(b)
|
||||
.copied()
|
||||
.unwrap_or(AuxiliaryAbility::Empty);
|
||||
|
@ -1028,7 +1028,7 @@ impl<'a> Skillbar<'a> {
|
||||
|
||||
// Helper
|
||||
let tooltip_text = |slot| {
|
||||
let (hotbar, inventory, _, skill_set, active_abilities, _, contexts, _, char_state, _) =
|
||||
let (hotbar, inventory, _, skill_set, active_abilities, _, contexts, _, _, _) =
|
||||
content_source;
|
||||
hotbar.get(slot).and_then(|content| match content {
|
||||
hotbar::SlotContents::Inventory(i, _) => inventory.get_by_hash(i).map(|item| {
|
||||
@ -1039,7 +1039,7 @@ impl<'a> Skillbar<'a> {
|
||||
}),
|
||||
hotbar::SlotContents::Ability(i) => active_abilities
|
||||
.and_then(|a| {
|
||||
a.auxiliary_set(Some(inventory), Some(skill_set), char_state)
|
||||
a.auxiliary_set(Some(inventory), Some(skill_set))
|
||||
.get(i)
|
||||
.and_then(|a| {
|
||||
Ability::from(*a).ability_id(
|
||||
|
@ -165,7 +165,7 @@ impl<'a> SlotKey<HotbarSource<'a>, HotbarImageSource<'a>> for HotbarSlot {
|
||||
},
|
||||
hotbar::SlotContents::Ability(i) => {
|
||||
let ability_id = active_abilities.and_then(|a| {
|
||||
a.auxiliary_set(Some(inventory), Some(skillset), *char_state)
|
||||
a.auxiliary_set(Some(inventory), Some(skillset))
|
||||
.get(i)
|
||||
.and_then(|a| {
|
||||
Ability::from(*a).ability_id(
|
||||
@ -262,7 +262,6 @@ impl<'a> SlotKey<AbilitiesSource<'a>, img_ids::Imgs> for AbilitySlot {
|
||||
AbilityInput::Auxiliary(*index),
|
||||
Some(inventory),
|
||||
Some(skillset),
|
||||
*char_state,
|
||||
)
|
||||
.ability_id(*char_state, Some(inventory), Some(skillset), contexts),
|
||||
Self::Ability(ability) => Ability::from(*ability).ability_id(
|
||||
|
Loading…
Reference in New Issue
Block a user