mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Colour reflects old poise state
This commit is contained in:
@ -54,7 +54,9 @@ pub struct Poise {
|
|||||||
/// Rate of poise regeneration per tick. Starts at zero and accelerates.
|
/// Rate of poise regeneration per tick. Starts at zero and accelerates.
|
||||||
pub regen_rate: f32,
|
pub regen_rate: f32,
|
||||||
/// Time that entity was last in a poise state
|
/// Time that entity was last in a poise state
|
||||||
last_stun_time: Option<Time>,
|
pub last_stun_time: Option<Time>,
|
||||||
|
/// The previous poise state
|
||||||
|
pub previous_state: PoiseState,
|
||||||
/// Next threshold for the poise change
|
/// Next threshold for the poise change
|
||||||
next_threshold: f32,
|
next_threshold: f32,
|
||||||
}
|
}
|
||||||
@ -148,7 +150,7 @@ impl Poise {
|
|||||||
const MAX_SCALED_POISE: u32 = Self::MAX_POISE as u32 * Self::SCALING_FACTOR_INT;
|
const MAX_SCALED_POISE: u32 = Self::MAX_POISE as u32 * Self::SCALING_FACTOR_INT;
|
||||||
/// The amount of time after being in a poise state before you can take
|
/// The amount of time after being in a poise state before you can take
|
||||||
/// poise damage again
|
/// poise damage again
|
||||||
const POISE_BUFFER_TIME: f64 = 1.0;
|
pub const POISE_BUFFER_TIME: f64 = 1.0;
|
||||||
/// Used when comparisons to poise are needed outside this module.
|
/// Used when comparisons to poise are needed outside this module.
|
||||||
// This value is chosen as anything smaller than this is more precise than our
|
// This value is chosen as anything smaller than this is more precise than our
|
||||||
// units of poise.
|
// units of poise.
|
||||||
@ -195,6 +197,7 @@ impl Poise {
|
|||||||
regen_rate: 0.0,
|
regen_rate: 0.0,
|
||||||
last_stun_time: None,
|
last_stun_time: None,
|
||||||
next_threshold: self::Poise::POISE_THRESHOLDS[0],
|
next_threshold: self::Poise::POISE_THRESHOLDS[0],
|
||||||
|
previous_state: PoiseState::Normal,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,6 +205,9 @@ impl Poise {
|
|||||||
match self.last_stun_time {
|
match self.last_stun_time {
|
||||||
Some(last_time) if last_time.0 + Poise::POISE_BUFFER_TIME > change.time.0 => {},
|
Some(last_time) if last_time.0 + Poise::POISE_BUFFER_TIME > change.time.0 => {},
|
||||||
_ => {
|
_ => {
|
||||||
|
// if self.previous_state != self.poise_state() {
|
||||||
|
self.previous_state = self.poise_state();
|
||||||
|
// };
|
||||||
self.current = (((self.current() + change.amount)
|
self.current = (((self.current() + change.amount)
|
||||||
.clamp(0.0, f32::from(Self::MAX_POISE))
|
.clamp(0.0, f32::from(Self::MAX_POISE))
|
||||||
* Self::SCALING_FACTOR_FLOAT) as u32)
|
* Self::SCALING_FACTOR_FLOAT) as u32)
|
||||||
|
@ -21,11 +21,14 @@ use i18n::Localization;
|
|||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use client::{self, Client};
|
use client::{self, Client};
|
||||||
use common::comp::{
|
use common::{
|
||||||
self,
|
comp::{
|
||||||
ability::AbilityInput,
|
self,
|
||||||
item::{ItemDesc, MaterialStatManifest},
|
ability::AbilityInput,
|
||||||
Ability, ActiveAbilities, Body, Energy, Health, Inventory, Poise, PoiseState, SkillSet,
|
item::{ItemDesc, MaterialStatManifest},
|
||||||
|
Ability, ActiveAbilities, Body, Energy, Health, Inventory, Poise, PoiseState, SkillSet,
|
||||||
|
},
|
||||||
|
resources::Time,
|
||||||
};
|
};
|
||||||
use conrod_core::{
|
use conrod_core::{
|
||||||
color,
|
color,
|
||||||
@ -482,7 +485,22 @@ impl<'a> Skillbar<'a> {
|
|||||||
state.ids.poise_tick_4,
|
state.ids.poise_tick_4,
|
||||||
];
|
];
|
||||||
|
|
||||||
let poise_colour = match self.poise.poise_state() {
|
// println!(.poise
|
||||||
|
// .last_stun_time
|
||||||
|
// .unwrap_or(Time(self::Poise::POISE_BUFFER_TIME))
|
||||||
|
// .0);
|
||||||
|
// let poise_state = if self
|
||||||
|
// .poise
|
||||||
|
// .last_stun_time
|
||||||
|
// .unwrap_or(Time(self::Poise::POISE_BUFFER_TIME))
|
||||||
|
// .0
|
||||||
|
// >= 2.0
|
||||||
|
// {
|
||||||
|
// self.poise.poise_state()
|
||||||
|
// } else {
|
||||||
|
// self.poise.previous_state
|
||||||
|
// };
|
||||||
|
let poise_colour = match self.poise.previous_state {
|
||||||
self::PoiseState::KnockedDown => BLACK,
|
self::PoiseState::KnockedDown => BLACK,
|
||||||
self::PoiseState::Dazed => Color::Rgba(0.25, 0.0, 0.15, 1.0),
|
self::PoiseState::Dazed => Color::Rgba(0.25, 0.0, 0.15, 1.0),
|
||||||
self::PoiseState::Stunned => Color::Rgba(0.40, 0.0, 0.30, 1.0),
|
self::PoiseState::Stunned => Color::Rgba(0.40, 0.0, 0.30, 1.0),
|
||||||
@ -502,6 +520,8 @@ impl<'a> Skillbar<'a> {
|
|||||||
.color(Some(poise_colour))
|
.color(Some(poise_colour))
|
||||||
.top_left_with_margins_on(state.ids.poise_alignment, 0.0, 0.0)
|
.top_left_with_margins_on(state.ids.poise_alignment, 0.0, 0.0)
|
||||||
.set(state.ids.poise_filling, ui);
|
.set(state.ids.poise_filling, ui);
|
||||||
|
// (ui.widget_graph().node(state.ids.poise_filling).unwrap().clone() as
|
||||||
|
// Image).color(color) ;
|
||||||
for (i, threshold) in self::Poise::POISE_THRESHOLDS.iter().enumerate() {
|
for (i, threshold) in self::Poise::POISE_THRESHOLDS.iter().enumerate() {
|
||||||
Image::new(self.imgs.poise_tick)
|
Image::new(self.imgs.poise_tick)
|
||||||
.w_h(3.0, 10.0)
|
.w_h(3.0, 10.0)
|
||||||
|
Reference in New Issue
Block a user