Make describing undescribed areas configurable.

This commit is contained in:
Nolan Darilek 2021-05-16 15:27:52 -05:00
parent 3332d0a88d
commit 64e763a840

View File

@ -84,6 +84,7 @@ impl ITileType for TileType {
#[derive(Clone, Debug)]
pub struct MapConfig {
pub autospawn_exits: bool,
pub describe_undescribed_areas: bool,
pub speak_area_descriptions: bool,
pub start_revealed: bool,
}
@ -92,6 +93,7 @@ impl Default for MapConfig {
fn default() -> Self {
Self {
autospawn_exits: true,
describe_undescribed_areas: false,
speak_area_descriptions: true,
start_revealed: false,
}
@ -263,6 +265,7 @@ fn exit_spawner(
}
fn area_description(
config: Res<MapConfig>,
mut prev_area: Local<Option<Area>>,
query: Query<(&Player, &Coordinates), Changed<Coordinates>>,
map: Query<(&Map, &Areas)>,
@ -288,15 +291,23 @@ fn area_description(
if should_describe_area {
if let Some(ref area) = current_area {
let description = if area.description.is_some() {
area.description.as_ref().unwrap().clone()
area.description.clone()
} else if config.describe_undescribed_areas {
Some(format!(
"{} by {} area.",
area.rect.width(),
area.rect.height()
))
} else {
format!("{} by {} area.", area.rect.width(), area.rect.height())
None
};
if let Some(description) = description {
for mut log in log.iter_mut() {
log.push(description.clone());
}
}
}
}
*prev_area = current_area;
}
}