cleans up mobs.json, adds MoveModes

This commit is contained in:
Llywelwyn 2023-08-15 20:28:21 +01:00
parent 198486df1d
commit 084e5e6f7b
5 changed files with 68 additions and 41 deletions

View file

@ -291,10 +291,16 @@ pub fn spawn_named_mob(
}
let mut has_mind = true;
let mut has_faction = false;
let mut blocks_tile = true;
let mut has_move_mode = false;
if let Some(flags) = &mob_template.flags {
for flag in flags.iter() {
match flag.as_str() {
"BLOCKS_TILE" => eb = eb.with(BlocksTile {}),
"PASSABLE" => blocks_tile = false,
"STATIC" => {
eb = eb.with(MoveMode { mode: Movement::Static });
has_move_mode = true;
}
"MINDLESS" => {
eb = eb.with(Faction { name: "mindless".to_string() });
has_faction = true;
@ -322,6 +328,13 @@ pub fn spawn_named_mob(
}
}
}
if blocks_tile {
eb = eb.with(BlocksTile {});
}
// If we didn't already add one, just move randomly.
if !has_move_mode {
eb = eb.with(MoveMode { mode: Movement::Random });
}
// If we're anything other than MINDLESS, add a mind.
if has_mind {
eb = eb.with(Mind {});