spinners and gems

This commit is contained in:
2026-06-21 18:27:45 -05:00
parent 9b53552f4a
commit d4b9278838
17 changed files with 626 additions and 56 deletions
+17
View File
@@ -26,6 +26,10 @@ const PUSHER: &str = include_str!("scripts/pusher.rhai");
/// direction comes from the object's tag, so all spinners share one compiled AST.
const SPINNER: &str = include_str!("scripts/spinner.rhai");
/// The gem behavior, embedded into the binary: a `grab()` hook that adds a gem to
/// the player and removes the object.
const GEM: &str = include_str!("scripts/gem.rhai");
/// The tag identifying an object as the expanded form of `arch`, e.g.
/// `"BUILTIN_pusher_east"`.
pub(crate) fn builtin_tag(arch: Archetype) -> String {
@@ -46,6 +50,19 @@ pub(crate) fn archetype_script(arch: Archetype) -> Option<&'static str> {
match arch {
Archetype::Pusher(_) => Some(PUSHER),
Archetype::Spinner(_) => Some(SPINNER),
Archetype::Gem => Some(GEM),
_ => None,
}
}
/// Returns the embedded script implementing `arch` as an object, or `None` if the
/// archetype is a plain terrain cell. The one place script-backed archetypes are
/// declared.
pub(crate) fn archetype_script_key(arch: Archetype) -> Option<&'static str> {
match arch {
Archetype::Pusher(_) => Some("BUILTIN_pusher"),
Archetype::Spinner(_) => Some("BUILTIN_spinner"),
Archetype::Gem => Some("BUILTIN_gem"),
_ => None,
}
}