Object passable/opaque: editor checkboxes + doc/simplify cleanup

- ObjectDef gains passable/opaque fields (defaults: false/true); Board::is_passable
  consults the object before the grid cell, so objects block movement independently
  of the floor tile beneath them
- Editor Objects tab exposes Passable and Opaque checkboxes; changes survive save/load
- Add ObjectDef::new(x, y) to centralise placement defaults; remove triple
  default_glyph() call and unused Glyph import from main.rs
- Fix stale Behavior doc comment; update CLAUDE.md and ARCHITECTURE.md

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-30 21:48:40 -05:00
parent 0241cd2a8d
commit 067bb9bee0
4 changed files with 43 additions and 27 deletions
+18 -3
View File
@@ -70,9 +70,8 @@ pub struct FontSpec {
/// passability and opacity. Future properties (pushable, shootable, etc.) can
/// be added here without changing call sites.
///
/// For scripted objects (`Archetype::Object`), the behavior will eventually be
/// determined by the Rhai script rather than this struct. See the Object variant
/// for details. (TODO fix this comment)
/// For scripted objects, passability and opacity are stored directly on
/// [`ObjectDef`] and will eventually be overridable by Rhai scripts at runtime.
#[derive(Copy, Clone, Debug)]
pub struct Behavior {
/// Whether an entity can walk through this cell.
@@ -226,6 +225,7 @@ pub struct ObjectDef {
}
impl ObjectDef {
/// Returns the default glyph for a newly placed object: tile 63 (`?`) in yellow on black.
pub fn default_glyph() -> Glyph {
Glyph {
tile: 63,
@@ -233,6 +233,21 @@ impl ObjectDef {
bg: Rgba8 { r: 0, g: 0, b: 0, a: 255 },
}
}
/// Creates a new object at `(x, y)` with default glyph and blocking behavior.
///
/// Defaults: `passable = false`, `opaque = true`, no script. These match
/// the serde defaults in the map file format so new objects round-trip correctly.
pub fn new(x: usize, y: usize) -> Self {
Self {
x,
y,
glyph: Self::default_glyph(),
passable: false,
opaque: true,
script_name: None,
}
}
}
/// A portal that teleports the player to a named entry point on another board.