the huge refactor
This commit is contained in:
@@ -2,19 +2,19 @@
|
||||
//! carrying the embedded `pusher.rhai` plus a `BUILTIN_pusher_<dir>` tag).
|
||||
|
||||
use super::{grid, load_board, map};
|
||||
use crate::archetype::Archetype;
|
||||
use crate::builtin::Archetype;
|
||||
use crate::game::GameState;
|
||||
use crate::map_file::MapFile;
|
||||
use crate::object_def::ObjectDef;
|
||||
use std::time::Duration;
|
||||
use crate::{Board, Builtin};
|
||||
use crate::Board;
|
||||
|
||||
/// Finds the pusher object on a board (by its built-in tag).
|
||||
fn pusher<'a>(board: &'a crate::board::Board, id: &mut u32) -> &'a ObjectDef {
|
||||
let (&oid, obj) = board
|
||||
.objects
|
||||
.iter()
|
||||
.find(|(_, o)| o.tags.contains("BUILTIN_pusher_east"))
|
||||
.find(|(_, o)| o.scripting.tags.contains("BUILTIN_pusher_east"))
|
||||
.expect("pusher object");
|
||||
*id = oid;
|
||||
obj
|
||||
@@ -34,17 +34,17 @@ fn pusher_loads_as_a_tagged_scripted_solid_object() {
|
||||
let p = pusher(&board, &mut id);
|
||||
assert_eq!((p.x, p.y), (0, 0));
|
||||
assert!(
|
||||
p.builtin_script.is_some(),
|
||||
p.scripting.builtin_script.is_some(),
|
||||
"carries the embedded pusher script"
|
||||
);
|
||||
// Each alias gets its own compile-cache key (e.g. "BUILTIN_pusher_east") so the
|
||||
// script can read direction from Me.has_tag("BUILTIN_pusher_east").
|
||||
assert_eq!(p.script_name.as_deref(), Some("BUILTIN_pusher_east"));
|
||||
assert_eq!(p.scripting.script_name.as_deref(), Some("BUILTIN_pusher_east"));
|
||||
assert!(!board.is_passable(0, 0), "pusher is solid");
|
||||
}
|
||||
|
||||
fn is_tag(board: &Board, x: usize, y: usize, tag: &str) -> bool {
|
||||
board.object_ids_at(x, y).iter().any(|id| board.objects[id].tags.contains(tag))
|
||||
board.object_ids_at(x, y).iter().any(|id| board.objects[id].scripting.tags.contains(tag))
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -135,5 +135,5 @@ fn pusher_round_trips_to_its_keyword() {
|
||||
let mut id = 0;
|
||||
let p = pusher(&board2, &mut id);
|
||||
assert_eq!((p.x, p.y), (0, 0));
|
||||
assert!(p.builtin_script.is_some());
|
||||
assert!(p.scripting.builtin_script.is_some());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user