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