Move passable and opaque into objectdef
This commit is contained in:
@@ -138,11 +138,19 @@ pub(crate) struct MapFileObjectEntry {
|
||||
fg: String,
|
||||
/// Background color as an `"#RRGGBB"` hex string.
|
||||
bg: String,
|
||||
/// Whether the object blocks player / object movement
|
||||
#[serde(default)]
|
||||
passable: bool,
|
||||
/// Whether the object blocks player line of sight / FOV
|
||||
#[serde(default = "default_true")]
|
||||
opaque: bool,
|
||||
/// Name of the Rhai script in the `[scripts]` table, if any.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
script_name: Option<String>,
|
||||
}
|
||||
|
||||
fn default_true() -> bool { true }
|
||||
|
||||
/// Parses an `"#RRGGBB"` hex color string into an [`Rgba8`].
|
||||
/// Returns opaque black on any parse failure.
|
||||
fn parse_color(hex: &str) -> Rgba8 {
|
||||
@@ -256,6 +264,8 @@ impl TryFrom<MapFile> for Board {
|
||||
fg: parse_color(&e.fg),
|
||||
bg: parse_color(&e.bg),
|
||||
},
|
||||
passable: e.passable,
|
||||
opaque: e.opaque,
|
||||
script_name: e.script_name,
|
||||
})
|
||||
.collect();
|
||||
@@ -365,6 +375,8 @@ impl From<&Board> for MapFile {
|
||||
tile: TileIndex::Num(o.glyph.tile),
|
||||
fg: color_to_hex(o.glyph.fg),
|
||||
bg: color_to_hex(o.glyph.bg),
|
||||
passable: o.passable,
|
||||
opaque: o.opaque,
|
||||
script_name: o.script_name.clone(),
|
||||
})
|
||||
.collect();
|
||||
|
||||
Reference in New Issue
Block a user