Add Initiative component
This commit is contained in:
parent
f558112836
commit
107f190a39
@ -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.
|
||||
|
||||
|
@ -467,6 +467,7 @@ fn main() -> ::rltk::BError {
|
||||
HungerClock,
|
||||
InBackpack,
|
||||
InflictsDamage,
|
||||
Initiative,
|
||||
Item,
|
||||
LightSource,
|
||||
LootTable,
|
||||
|
@ -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));
|
||||
|
@ -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,
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user