atomising item use: refactors BUC
This commit is contained in:
parent
a00b7ae805
commit
6677181a4e
4 changed files with 36 additions and 10 deletions
|
|
@ -1,12 +1,20 @@
|
|||
use super::EffectSpawner;
|
||||
use super::{
|
||||
triggers::{BLESSED, CURSED, UNCURSED},
|
||||
EffectSpawner, EffectType,
|
||||
};
|
||||
use crate::{HungerClock, HungerState};
|
||||
use specs::prelude::*;
|
||||
|
||||
const SATIATED_DURATION: i32 = 200;
|
||||
|
||||
pub fn restore_food(ecs: &mut World, _damage: &EffectSpawner, target: Entity) {
|
||||
pub fn restore_food(ecs: &mut World, effect: &EffectSpawner, target: Entity) {
|
||||
let buc = if let EffectType::RestoreNutrition { buc } = effect.effect_type { buc } else { UNCURSED };
|
||||
if let Some(hc) = ecs.write_storage::<HungerClock>().get_mut(target) {
|
||||
hc.state = HungerState::Satiated;
|
||||
hc.duration = SATIATED_DURATION;
|
||||
if buc == BLESSED || buc == UNCURSED {
|
||||
hc.state = HungerState::Satiated;
|
||||
hc.duration = SATIATED_DURATION;
|
||||
} else {
|
||||
hc.duration = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue