object tags
This commit is contained in:
@@ -191,6 +191,9 @@ pub(crate) struct MapFileObjectEntry {
|
||||
/// Name of the Rhai script in the `[scripts]` table, if any.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
script_name: Option<String>,
|
||||
/// Open-ended string labels. Serialized as a TOML array; omitted when empty.
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
tags: Vec<String>,
|
||||
}
|
||||
|
||||
fn default_true() -> bool {
|
||||
@@ -497,6 +500,7 @@ impl TryFrom<MapFile> for Board {
|
||||
}
|
||||
};
|
||||
let obj = ObjectDef {
|
||||
id: 0, // stamped by Board::add_object
|
||||
x,
|
||||
y,
|
||||
glyph: Glyph {
|
||||
@@ -508,6 +512,7 @@ impl TryFrom<MapFile> for Board {
|
||||
opaque: e.opaque,
|
||||
pushable: e.pushable,
|
||||
script_name: e.script_name,
|
||||
tags: e.tags.into_iter().collect(),
|
||||
};
|
||||
// A solid object may not share a cell with another solid.
|
||||
if obj.solid {
|
||||
@@ -645,6 +650,8 @@ impl From<&Board> for MapFile {
|
||||
opaque: o.opaque,
|
||||
pushable: o.pushable,
|
||||
script_name: o.script_name.clone(),
|
||||
// Sort for stable TOML output; HashSet iteration order is non-deterministic.
|
||||
tags: { let mut v: Vec<String> = o.tags.iter().cloned().collect(); v.sort(); v },
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user