Add species to /spawn auto-complete

This commit is contained in:
juliancoffee 2021-05-09 18:25:52 +03:00
parent 587b48871d
commit d3be89f5eb
2 changed files with 36 additions and 4 deletions

View File

@ -209,10 +209,40 @@ lazy_static! {
/// TODO: Make this use hot-reloading
static ref ENTITIES: Vec<String> = {
let npc_names = &*npc::NPC_NAMES.read();
npc::ALL_NPCS
.iter()
.map(|&npc| npc_names[npc].keyword.clone())
.collect()
let mut souls = Vec::new();
macro_rules! push_souls {
($species:tt) => {
for s in comp::$species::ALL_SPECIES.iter() {
souls.push(npc_names.$species.species[s].keyword.clone())
}
};
($base:tt, $($species:tt),+ $(,)?) => {
push_souls!($base);
push_souls!($($species),+);
}
}
for npc in npc::ALL_NPCS.iter() {
souls.push(npc_names[*npc].keyword.clone())
}
// See `[AllBodies](crate::comp::body::AllBodies)`
push_souls!(
humanoid,
quadruped_small,
quadruped_medium,
quadruped_low,
bird_medium,
bird_large,
fish_small,
fish_medium,
biped_small,
biped_large,
theropod,
dragon,
golem,
);
souls
};
static ref OBJECTS: Vec<String> = comp::object::ALL_OBJECTS
.iter()

View File

@ -65,6 +65,8 @@ pub struct BodyData<BodyMeta, SpeciesData> {
/// stored for each species for each body.
///
/// NOTE: Deliberately don't (yet?) implement serialize.
/// NOTE: If you are adding new body kind and it should be spawned via /spawn
/// please add it to `[ENTITIES](crate::cmd::ENTITIES)`
#[derive(Clone, Debug, Deserialize)]
pub struct AllBodies<BodyMeta, SpeciesMeta> {
pub humanoid: BodyData<BodyMeta, humanoid::AllSpecies<SpeciesMeta>>,