atomising item use: refactors BUC

This commit is contained in:
Llywelwyn 2023-08-17 02:00:05 +01:00
parent a00b7ae805
commit 6677181a4e
4 changed files with 36 additions and 10 deletions

View file

@ -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;
}
}
}