1
0
Fork 0

Add Initiative component

This commit is contained in:
Timothy Warren 2022-01-11 09:28:45 -05:00
parent f558112836
commit 107f190a39
5 changed files with 12 additions and 0 deletions

View File

@ -291,6 +291,11 @@ pub struct LightSource {
pub range: i32,
}
#[derive(Component, Debug, Serialize, Deserialize, Clone)]
pub struct Initiative {
pub current: i32,
}
// Serialization helper code. We need to implement ConvertSaveLoad for each type that contains an
// Entity.

View File

@ -467,6 +467,7 @@ fn main() -> ::rltk::BError {
HungerClock,
InBackpack,
InflictsDamage,
Initiative,
Item,
LightSource,
LootTable,

View File

@ -293,6 +293,9 @@ pub fn spawn_named_mob(
// Spawn in the specified location
eb = spawn_position(pos, eb, key, raws);
// Initiative of 2
eb = eb.with(Initiative { current: 2 });
// Renderable
if let Some(renderable) = &mob_template.renderable {
eb = eb.with(get_renderable_component(renderable));

View File

@ -79,6 +79,7 @@ pub fn save_game(ecs: &mut World) {
HungerClock,
InBackpack,
InflictsDamage,
Initiative,
Item,
LightSource,
LootTable,
@ -184,6 +185,7 @@ pub fn load_game(ecs: &mut World) {
HungerClock,
InBackpack,
InflictsDamage,
Initiative,
Item,
LightSource,
LootTable,

View File

@ -54,6 +54,7 @@ pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity {
color: RGB::from_f32(1.0, 1.0, 0.5),
range: 8,
})
.with(Initiative { current: 0 })
.marked::<SimpleMarker<SerializeMe>>()
.build();