Add hunger
This commit is contained in:
@@ -4,13 +4,9 @@ use rltk::{FontCharType, RandomNumberGenerator, RGB};
|
||||
use specs::prelude::*;
|
||||
use specs::saveload::{MarkedBuilder, SimpleMarker};
|
||||
|
||||
use crate::{AreaOfEffect, BlocksTile, CombatStats, Confusion, Consumable, DefenseBonus, EquipmentSlot, Equippable, HungerClock, HungerState, InflictsDamage, Item, MAP_WIDTH, MAX_MONSTER, MeleePowerBonus, Monster, Name, Player, Position, ProvidesFood, ProvidesHealing, Ranged, Renderable, SerializeMe, Viewshed};
|
||||
use crate::random_table::RandomTable;
|
||||
use crate::rect::Rect;
|
||||
use crate::{
|
||||
AreaOfEffect, BlocksTile, CombatStats, Confusion, Consumable, DefenseBonus, EquipmentSlot,
|
||||
Equippable, InflictsDamage, Item, MeleePowerBonus, Monster, Name, Player, Position,
|
||||
ProvidesHealing, Ranged, Renderable, SerializeMe, Viewshed, MAP_WIDTH, MAX_MONSTER,
|
||||
};
|
||||
|
||||
pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity {
|
||||
ecs.create_entity()
|
||||
@@ -39,6 +35,10 @@ pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity {
|
||||
defense: 2,
|
||||
power: 5,
|
||||
})
|
||||
.with(HungerClock {
|
||||
duration: 20,
|
||||
state: HungerState::WellFed,
|
||||
})
|
||||
.marked::<SimpleMarker<SerializeMe>>()
|
||||
.build()
|
||||
}
|
||||
@@ -125,6 +125,7 @@ pub fn spawn_room(ecs: &mut World, room: &Rect, map_depth: i32) {
|
||||
"Breastplate" => breastplate(ecs, x, y),
|
||||
"Leggings" => leggings(ecs, x, y),
|
||||
"Sabatons" => sabatons(ecs, x, y),
|
||||
"Rations" => rations(ecs, x, y),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@@ -226,6 +227,7 @@ pub fn room_table(map_depth: i32) -> RandomTable {
|
||||
.add("Breastplate", map_depth - 3)
|
||||
.add("Leggings", map_depth - 4)
|
||||
.add("Sabatons", map_depth - 4)
|
||||
.add("Rations", 10)
|
||||
}
|
||||
|
||||
fn dagger(ecs: &mut World, x: i32, y: i32) {
|
||||
@@ -397,3 +399,23 @@ fn sabatons(ecs: &mut World, x: i32, y: i32) {
|
||||
.marked::<SimpleMarker<SerializeMe>>()
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
fn rations(ecs: &mut World, x: i32, y: i32) {
|
||||
ecs.create_entity()
|
||||
.with(Position { x, y })
|
||||
.with(Renderable {
|
||||
glyph: rltk::to_cp437('%'),
|
||||
render_order: 2,
|
||||
fg: RGB::named(rltk::GREEN),
|
||||
bg: RGB::named(rltk::BLACK),
|
||||
})
|
||||
.with(Item {})
|
||||
.with(Name {
|
||||
name: "Rations".to_string(),
|
||||
})
|
||||
.with(Consumable{})
|
||||
.with(ProvidesFood{})
|
||||
.marked::<SimpleMarker<SerializeMe>>()
|
||||
.build();
|
||||
}
|
||||
|
Reference in New Issue
Block a user