mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Make skillbar buttons account for energy cost reduction
Previously, the buttons would compare the current energy to the base cost of the ability, so they would sometimes be grayed out while the ability was usable. Now they ajust the ability with the character skillset before getting the energy cost for the purposes of setting the skillbar icon color.
This commit is contained in:
parent
fef68ad2a1
commit
4f71c621f4
@ -96,6 +96,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Server now denies any running trades when a user exits to the character selection screen.
|
- Server now denies any running trades when a user exits to the character selection screen.
|
||||||
- Sfx volume changes now also change the ambient sounds volume
|
- Sfx volume changes now also change the ambient sounds volume
|
||||||
- Staff fire shockwave ability no longer has an unlimited vertical range
|
- Staff fire shockwave ability no longer has an unlimited vertical range
|
||||||
|
- Skillbar buttons correctly account for skill points when checking if player has enough stamina for the ability.
|
||||||
|
|
||||||
## [0.9.0] - 2021-03-20
|
## [0.9.0] - 2021-03-20
|
||||||
|
|
||||||
|
@ -2267,6 +2267,7 @@ impl Hud {
|
|||||||
let healths = ecs.read_storage::<comp::Health>();
|
let healths = ecs.read_storage::<comp::Health>();
|
||||||
let inventories = ecs.read_storage::<comp::Inventory>();
|
let inventories = ecs.read_storage::<comp::Inventory>();
|
||||||
let energies = ecs.read_storage::<comp::Energy>();
|
let energies = ecs.read_storage::<comp::Energy>();
|
||||||
|
let skillsets = ecs.read_storage::<comp::SkillSet>();
|
||||||
let character_states = ecs.read_storage::<comp::CharacterState>();
|
let character_states = ecs.read_storage::<comp::CharacterState>();
|
||||||
let controllers = ecs.read_storage::<comp::Controller>();
|
let controllers = ecs.read_storage::<comp::Controller>();
|
||||||
let ability_map = ecs.fetch::<comp::item::tool::AbilityMap>();
|
let ability_map = ecs.fetch::<comp::item::tool::AbilityMap>();
|
||||||
@ -2289,12 +2290,14 @@ impl Hud {
|
|||||||
Some(health),
|
Some(health),
|
||||||
Some(inventory),
|
Some(inventory),
|
||||||
Some(energy),
|
Some(energy),
|
||||||
|
Some(skillset),
|
||||||
Some(_character_state),
|
Some(_character_state),
|
||||||
Some(_controller),
|
Some(_controller),
|
||||||
) = (
|
) = (
|
||||||
healths.get(entity),
|
healths.get(entity),
|
||||||
inventories.get(entity),
|
inventories.get(entity),
|
||||||
energies.get(entity),
|
energies.get(entity),
|
||||||
|
skillsets.get(entity),
|
||||||
character_states.get(entity),
|
character_states.get(entity),
|
||||||
controllers.get(entity).map(|c| &c.inputs),
|
controllers.get(entity).map(|c| &c.inputs),
|
||||||
) {
|
) {
|
||||||
@ -2308,6 +2311,7 @@ impl Hud {
|
|||||||
&health,
|
&health,
|
||||||
&inventory,
|
&inventory,
|
||||||
&energy,
|
&energy,
|
||||||
|
&skillset,
|
||||||
//&character_state,
|
//&character_state,
|
||||||
self.pulse,
|
self.pulse,
|
||||||
//&controller,
|
//&controller,
|
||||||
|
@ -26,7 +26,7 @@ use common::comp::{
|
|||||||
tool::{AbilityMap, Tool, ToolKind},
|
tool::{AbilityMap, Tool, ToolKind},
|
||||||
Hands, Item, ItemKind, MaterialStatManifest,
|
Hands, Item, ItemKind, MaterialStatManifest,
|
||||||
},
|
},
|
||||||
Energy, Health, Inventory,
|
Energy, Health, Inventory, SkillSet,
|
||||||
};
|
};
|
||||||
use conrod_core::{
|
use conrod_core::{
|
||||||
color,
|
color,
|
||||||
@ -142,6 +142,7 @@ pub struct Skillbar<'a> {
|
|||||||
health: &'a Health,
|
health: &'a Health,
|
||||||
inventory: &'a Inventory,
|
inventory: &'a Inventory,
|
||||||
energy: &'a Energy,
|
energy: &'a Energy,
|
||||||
|
skillset: &'a SkillSet,
|
||||||
// character_state: &'a CharacterState,
|
// character_state: &'a CharacterState,
|
||||||
// controller: &'a ControllerInputs,
|
// controller: &'a ControllerInputs,
|
||||||
hotbar: &'a hotbar::State,
|
hotbar: &'a hotbar::State,
|
||||||
@ -169,6 +170,7 @@ impl<'a> Skillbar<'a> {
|
|||||||
health: &'a Health,
|
health: &'a Health,
|
||||||
inventory: &'a Inventory,
|
inventory: &'a Inventory,
|
||||||
energy: &'a Energy,
|
energy: &'a Energy,
|
||||||
|
skillset: &'a SkillSet,
|
||||||
// character_state: &'a CharacterState,
|
// character_state: &'a CharacterState,
|
||||||
pulse: f32,
|
pulse: f32,
|
||||||
// controller: &'a ControllerInputs,
|
// controller: &'a ControllerInputs,
|
||||||
@ -191,6 +193,7 @@ impl<'a> Skillbar<'a> {
|
|||||||
health,
|
health,
|
||||||
inventory,
|
inventory,
|
||||||
energy,
|
energy,
|
||||||
|
skillset,
|
||||||
common: widget::CommonBuilder::default(),
|
common: widget::CommonBuilder::default(),
|
||||||
// character_state,
|
// character_state,
|
||||||
pulse,
|
pulse,
|
||||||
@ -449,6 +452,7 @@ impl<'a> Widget for Skillbar<'a> {
|
|||||||
self.hotbar,
|
self.hotbar,
|
||||||
self.inventory,
|
self.inventory,
|
||||||
self.energy,
|
self.energy,
|
||||||
|
self.skillset,
|
||||||
self.ability_map,
|
self.ability_map,
|
||||||
self.msm,
|
self.msm,
|
||||||
); // TODO: avoid this
|
); // TODO: avoid this
|
||||||
@ -739,6 +743,7 @@ impl<'a> Widget for Skillbar<'a> {
|
|||||||
>= tool
|
>= tool
|
||||||
.get_abilities(&self.msm, item.components(), self.ability_map)
|
.get_abilities(&self.msm, item.components(), self.ability_map)
|
||||||
.secondary
|
.secondary
|
||||||
|
.adjusted_by_skills(self.skillset, Some(tool.kind))
|
||||||
.get_energy_cost()
|
.get_energy_cost()
|
||||||
{
|
{
|
||||||
Color::Rgba(1.0, 1.0, 1.0, 1.0)
|
Color::Rgba(1.0, 1.0, 1.0, 1.0)
|
||||||
|
@ -10,7 +10,7 @@ use common::comp::{
|
|||||||
ItemKind, MaterialStatManifest,
|
ItemKind, MaterialStatManifest,
|
||||||
},
|
},
|
||||||
slot::InvSlotId,
|
slot::InvSlotId,
|
||||||
Energy, Inventory,
|
Energy, Inventory, SkillSet,
|
||||||
};
|
};
|
||||||
use conrod_core::{image, Color};
|
use conrod_core::{image, Color};
|
||||||
use specs::Entity as EcsEntity;
|
use specs::Entity as EcsEntity;
|
||||||
@ -126,6 +126,7 @@ type HotbarSource<'a> = (
|
|||||||
&'a hotbar::State,
|
&'a hotbar::State,
|
||||||
&'a Inventory,
|
&'a Inventory,
|
||||||
&'a Energy,
|
&'a Energy,
|
||||||
|
&'a SkillSet,
|
||||||
&'a AbilityMap,
|
&'a AbilityMap,
|
||||||
&'a MaterialStatManifest,
|
&'a MaterialStatManifest,
|
||||||
);
|
);
|
||||||
@ -136,7 +137,7 @@ impl<'a> SlotKey<HotbarSource<'a>, HotbarImageSource<'a>> for HotbarSlot {
|
|||||||
|
|
||||||
fn image_key(
|
fn image_key(
|
||||||
&self,
|
&self,
|
||||||
(hotbar, inventory, energy, ability_map, msm): &HotbarSource<'a>,
|
(hotbar, inventory, energy, skillset, ability_map, msm): &HotbarSource<'a>,
|
||||||
) -> Option<(Self::ImageKey, Option<Color>)> {
|
) -> Option<(Self::ImageKey, Option<Color>)> {
|
||||||
hotbar.get(*self).and_then(|contents| match contents {
|
hotbar.get(*self).and_then(|contents| match contents {
|
||||||
hotbar::SlotContents::Inventory(idx) => inventory
|
hotbar::SlotContents::Inventory(idx) => inventory
|
||||||
@ -173,7 +174,13 @@ impl<'a> SlotKey<HotbarSource<'a>, HotbarImageSource<'a>> for HotbarSlot {
|
|||||||
.abilities
|
.abilities
|
||||||
.get(0)
|
.get(0)
|
||||||
{
|
{
|
||||||
if energy.current() >= skill.1.get_energy_cost() {
|
if energy.current()
|
||||||
|
>= skill
|
||||||
|
.1
|
||||||
|
.clone()
|
||||||
|
.adjusted_by_skills(skillset, Some(tool.kind))
|
||||||
|
.get_energy_cost()
|
||||||
|
{
|
||||||
Some(Color::Rgba(1.0, 1.0, 1.0, 1.0))
|
Some(Color::Rgba(1.0, 1.0, 1.0, 1.0))
|
||||||
} else {
|
} else {
|
||||||
Some(Color::Rgba(0.3, 0.3, 0.3, 0.8))
|
Some(Color::Rgba(0.3, 0.3, 0.3, 0.8))
|
||||||
@ -217,7 +224,13 @@ impl<'a> SlotKey<HotbarSource<'a>, HotbarImageSource<'a>> for HotbarSlot {
|
|||||||
.abilities
|
.abilities
|
||||||
.get(skill_index)
|
.get(skill_index)
|
||||||
{
|
{
|
||||||
if energy.current() >= skill.1.get_energy_cost() {
|
if energy.current()
|
||||||
|
>= skill
|
||||||
|
.1
|
||||||
|
.clone()
|
||||||
|
.adjusted_by_skills(skillset, Some(tool.kind))
|
||||||
|
.get_energy_cost()
|
||||||
|
{
|
||||||
Some(Color::Rgba(1.0, 1.0, 1.0, 1.0))
|
Some(Color::Rgba(1.0, 1.0, 1.0, 1.0))
|
||||||
} else {
|
} else {
|
||||||
Some(Color::Rgba(0.3, 0.3, 0.3, 0.8))
|
Some(Color::Rgba(0.3, 0.3, 0.3, 0.8))
|
||||||
@ -232,7 +245,7 @@ impl<'a> SlotKey<HotbarSource<'a>, HotbarImageSource<'a>> for HotbarSlot {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn amount(&self, (hotbar, inventory, _, _, _): &HotbarSource<'a>) -> Option<u32> {
|
fn amount(&self, (hotbar, inventory, _, _, _, _): &HotbarSource<'a>) -> Option<u32> {
|
||||||
hotbar
|
hotbar
|
||||||
.get(*self)
|
.get(*self)
|
||||||
.and_then(|content| match content {
|
.and_then(|content| match content {
|
||||||
|
Loading…
Reference in New Issue
Block a user