Files
kiln/kiln-core/src/portal.rs
T

32 lines
1.3 KiB
Rust
Raw Normal View History

2026-07-24 21:52:05 -05:00
use serde::{Deserialize, Serialize};
use crate::glyph::Glyph;
2026-08-11 01:02:38 -05:00
use crate::utils::Point;
2026-07-24 21:52:05 -05:00
/// A portal that teleports the player to a named entry point on another board.
///
/// Portals are loaded from `[[portals]]` entries in `.toml` map files and
/// stored on [`Board`]. When the player steps onto a portal's cell, the engine
/// calls [`crate::game::GameState::enter_board`] with the `target_map` and
/// `target_entry`, placing the player at the matching named portal on the
/// destination board.
///
/// In map files, portals are conventionally placed using digit characters
/// (`'1'``'9'`) as palette keys — parallel to the uppercase-letter convention
/// for objects. A portal's `name` is board-unique: it is also used as the
/// `target_entry` value on the other end of the connection.
#[derive(Serialize, Deserialize, Clone, Debug)]
#[serde(rename_all = "lowercase")]
pub struct Portal {
2026-08-11 01:02:38 -05:00
#[serde(flatten)]
pub location: Point,
2026-07-24 21:52:05 -05:00
/// Board-unique name for this portal, also used as `target_entry` by portals
/// on other boards that want to arrive here.
pub name: String,
/// Key of the target board in `World::boards`.
pub target_board: String,
/// Name of the arrival portal on the target board.
pub target_name: String,
#[serde(skip_serializing_if = "Option::is_none")]
2026-07-25 12:48:11 -05:00
pub glyph: Option<Glyph>
2026-07-24 21:52:05 -05:00
}