Add HungerClock component
This commit is contained in:
parent
c4db6f5932
commit
15a0f1779c
@ -179,6 +179,20 @@ pub struct ParticleLifetime {
|
||||
pub lifetime_ms: f32,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Copy, Clone, PartialEq)]
|
||||
pub enum HungerState {
|
||||
WellFed,
|
||||
Normal,
|
||||
Hungry,
|
||||
Starving,
|
||||
}
|
||||
|
||||
#[derive(Component, Serialize, Deserialize, Clone)]
|
||||
pub struct HungerClock {
|
||||
pub state: HungerState,
|
||||
pub duration: i32,
|
||||
}
|
||||
|
||||
// Serialization helper code. We need to implement ConvertSaveLoad for each type that contains an
|
||||
// Entity.
|
||||
|
||||
|
@ -490,6 +490,7 @@ fn main() -> rltk::BError {
|
||||
DefenseBonus,
|
||||
WantsToRemoveItem,
|
||||
ParticleLifetime,
|
||||
HungerClock,
|
||||
);
|
||||
|
||||
gs.ecs.insert(SimpleMarkerAllocator::<SerializeMe>::new());
|
||||
|
@ -75,7 +75,8 @@ pub fn save_game(ecs: &mut World) {
|
||||
MeleePowerBonus,
|
||||
DefenseBonus,
|
||||
WantsToRemoveItem,
|
||||
ParticleLifetime
|
||||
ParticleLifetime,
|
||||
HungerClock
|
||||
);
|
||||
}
|
||||
|
||||
@ -157,7 +158,8 @@ pub fn load_game(ecs: &mut World) {
|
||||
MeleePowerBonus,
|
||||
DefenseBonus,
|
||||
WantsToRemoveItem,
|
||||
ParticleLifetime
|
||||
ParticleLifetime,
|
||||
HungerClock
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,10 @@ pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity {
|
||||
defense: 2,
|
||||
power: 5,
|
||||
})
|
||||
.with(HungerClock {
|
||||
state: HungerState::WellFed,
|
||||
duration: 20,
|
||||
})
|
||||
.marked::<SimpleMarker<SerializeMe>>()
|
||||
.build()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user