builtin scripts
This commit is contained in:
@@ -20,6 +20,7 @@ use tinyrand::{Seeded, StdRand};
|
||||
|
||||
use crate::archetype::Archetype;
|
||||
use crate::board::Board;
|
||||
use crate::builtin_scripts::archetype_from_builtin_tag;
|
||||
use crate::floor::FLOOR_SEED;
|
||||
use crate::glyph::Glyph;
|
||||
use crate::layer::{Layer, LayerData, PaletteEntry, Placement, build_layer};
|
||||
@@ -237,6 +238,7 @@ impl TryFrom<MapFile> for Board {
|
||||
opaque: t.opaque,
|
||||
pushable: t.pushable,
|
||||
script_name: t.script_name,
|
||||
builtin_script: t.builtin_script,
|
||||
tags: t.tags.into_iter().collect(),
|
||||
name,
|
||||
},
|
||||
@@ -350,6 +352,18 @@ fn layer_to_data(board: &Board, z: usize, place_player: bool) -> LayerData {
|
||||
|
||||
// Objects on this layer overwrite their (transparent) cell with an object char.
|
||||
for o in board.objects.values().filter(|o| o.z == z) {
|
||||
// A built-in archetype object (e.g. a pusher) round-trips back to its
|
||||
// archetype keyword: emit it as a terrain cell (deduped with real terrain),
|
||||
// using the object's current glyph, rather than a `kind = "object"` entry.
|
||||
if let Some(arch) = o.tags.iter().find_map(|t| archetype_from_builtin_tag(t)) {
|
||||
let ch = *cell_to_key.entry((o.glyph, arch)).or_insert_with(|| {
|
||||
let ch = pool.next().expect("ran out of palette characters");
|
||||
palette.insert(ch.to_string(), cell_entry(o.glyph, arch));
|
||||
ch
|
||||
});
|
||||
grid[o.y][o.x] = ch;
|
||||
continue;
|
||||
}
|
||||
let ch = pool.next().expect("ran out of palette characters");
|
||||
let mut tags: Vec<String> = o.tags.iter().cloned().collect();
|
||||
tags.sort();
|
||||
|
||||
Reference in New Issue
Block a user