spinners and gems
This commit is contained in:
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user