From 7b93ecc26cc6e86c8d0b3d1f76747185b948ad2d Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 18 Nov 2021 11:47:57 -0500 Subject: [PATCH] Show hunger status --- src/gui.rs | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/gui.rs b/src/gui.rs index e404e26..80be162 100644 --- a/src/gui.rs +++ b/src/gui.rs @@ -1,4 +1,6 @@ -use crate::components::{CombatStats, InBackpack, Name, Player, Position, Viewshed}; +use crate::components::{ + CombatStats, HungerClock, HungerState, InBackpack, Name, Player, Position, Viewshed, +}; use crate::{game_log::GameLog, Equipped, Map, RunState, State}; use rltk::{Point, Rltk, VirtualKeyCode, RGB}; use specs::prelude::*; @@ -15,9 +17,10 @@ pub fn draw_ui(ecs: &World, ctx: &mut Rltk) { let combat_stats = ecs.read_storage::(); let players = ecs.read_storage::(); + let hunger = ecs.read_storage::(); // Display player health - for (_player, stats) in (&players, &combat_stats).join() { + for (_player, stats, hc) in (&players, &combat_stats, &hunger).join() { let health = format!(" HP: {} / {} ", stats.hp, stats.max_hp); ctx.print_color( 12, @@ -36,6 +39,31 @@ pub fn draw_ui(ecs: &World, ctx: &mut Rltk) { RGB::named(rltk::RED), RGB::named(rltk::BLACK), ); + + match hc.state { + HungerState::WellFed => ctx.print_color( + 71, + 42, + RGB::named(rltk::GREEN), + RGB::named(rltk::BLACK), + "Well Fed", + ), + HungerState::Normal => {} + HungerState::Hungry => ctx.print_color( + 71, + 42, + RGB::named(rltk::ORANGE), + RGB::named(rltk::BLACK), + "Hungry", + ), + HungerState::Starving => ctx.print_color( + 71, + 42, + RGB::named(rltk::RED), + RGB::named(rltk::BLACK), + "Well Fed", + ), + } } let map = ecs.fetch::();