clippy
This commit is contained in:
@@ -50,9 +50,9 @@ impl From<Dynamic> for SendArg {
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<Dynamic> for SendArg {
|
||||
fn into(self) -> Dynamic {
|
||||
match self {
|
||||
impl From<SendArg> for Dynamic {
|
||||
fn from(val: SendArg) -> Self {
|
||||
match val {
|
||||
SendArg::None => Dynamic::UNIT,
|
||||
SendArg::Int(value) => Dynamic::from(value),
|
||||
SendArg::Float(value) => Dynamic::from(value),
|
||||
@@ -240,13 +240,13 @@ pub(crate) fn action_to_map(action: &Action) -> rhai::Map {
|
||||
}
|
||||
Action::Teleport { x, y } => {
|
||||
m.insert("type".into(), ds("Teleport"));
|
||||
m.insert("x".into(), Dynamic::from(*x as i64));
|
||||
m.insert("y".into(), Dynamic::from(*y as i64));
|
||||
m.insert("x".into(), Dynamic::from(*x));
|
||||
m.insert("y".into(), Dynamic::from(*y));
|
||||
}
|
||||
Action::Push { x, y, dir } => {
|
||||
m.insert("type".into(), ds("Push"));
|
||||
m.insert("x".into(), Dynamic::from(*x as i64));
|
||||
m.insert("y".into(), Dynamic::from(*y as i64));
|
||||
m.insert("x".into(), Dynamic::from(*x));
|
||||
m.insert("y".into(), Dynamic::from(*y));
|
||||
m.insert("dir".into(), ds(dir_to_str(*dir)));
|
||||
}
|
||||
// Shift cells are not inspectable via the queue map API; emit type only.
|
||||
|
||||
@@ -80,9 +80,7 @@ impl Registerable for BoardRef {
|
||||
engine.register_fn("tagged", move |board_ref: &mut BoardRef, tag: ImmutableString| -> rhai::Array {
|
||||
let board = board_ref.borrow();
|
||||
board
|
||||
.objects
|
||||
.iter()
|
||||
.filter_map(|(_id, def)| {
|
||||
.objects.values().filter_map(|def| {
|
||||
if def.tags.contains(tag.as_str()) {
|
||||
Some(Dynamic::from(ObjectInfo::from_def(def, board_ref.clone())))
|
||||
} else {
|
||||
|
||||
@@ -103,11 +103,10 @@ impl Board {
|
||||
|
||||
/// Replace the solid (if any) at `(x, y)` with `Empty`
|
||||
pub fn clear_solid(&mut self, x: usize, y: usize) {
|
||||
if self.in_bounds((x as i64, y as i64)) {
|
||||
if let Some(z) = self.solid_cell_layer(x, y) {
|
||||
if self.in_bounds((x as i64, y as i64))
|
||||
&& let Some(z) = self.solid_cell_layer(x, y) {
|
||||
*self.get_mut(z, x, y) = (Archetype::Empty.default_glyph(), Archetype::Empty)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the glyph to display at `(x, y)`, honoring layer draw order.
|
||||
|
||||
@@ -163,7 +163,7 @@ impl GameState {
|
||||
/// the game is about to start — never during map deserialization, since a script
|
||||
/// may inspect the board.
|
||||
pub fn run_init(&mut self) {
|
||||
self.scripts.run_init(ScriptState::from_game_state(&self));
|
||||
self.scripts.run_init(ScriptState::from_game_state(self));
|
||||
self.resolve();
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ impl GameState {
|
||||
// this runs exactly once per player interaction with a scroll.
|
||||
self.handle_scroll();
|
||||
let secs = dt.as_secs_f64();
|
||||
self.scripts.run_tick(ScriptState::from_game_state(&self), secs);
|
||||
self.scripts.run_tick(ScriptState::from_game_state(self), secs);
|
||||
// Expire speech bubbles before resolving new actions so a fresh say()
|
||||
// this frame isn't immediately culled.
|
||||
self.speech_bubbles.retain_mut(|b| {
|
||||
@@ -370,7 +370,7 @@ impl GameState {
|
||||
if let Some(scroll) = self.active_scroll.take()
|
||||
&& let Some(choice) = scroll.choice
|
||||
{
|
||||
self.scripts.run_send(ScriptState::from_game_state(&self), scroll.source, &choice, SendArg::None);
|
||||
self.scripts.run_send(ScriptState::from_game_state(self), scroll.source, &choice, SendArg::None);
|
||||
self.drain_errors();
|
||||
}
|
||||
}
|
||||
@@ -437,7 +437,7 @@ impl GameState {
|
||||
{
|
||||
let (dx, dy): (i64, i64) = dir.into();
|
||||
let mut board = self.board_mut();
|
||||
let target = (board.player.x as i64 + dx, board.player.y as i64 + dy);
|
||||
let target = (board.player.x + dx, board.player.y + dy);
|
||||
if !board.in_bounds(target) {
|
||||
return;
|
||||
}
|
||||
@@ -476,7 +476,7 @@ impl GameState {
|
||||
}
|
||||
// Fire the grab hook and resolve it immediately so the grabbed thing's
|
||||
// die()/add_gems() apply now — no player+object overlap survives this call.
|
||||
let state = ScriptState::from_game_state(&self);
|
||||
let state = ScriptState::from_game_state(self);
|
||||
if let Some(id) = grabbed {
|
||||
self.scripts.run_grab(state.clone(), id);
|
||||
self.resolve();
|
||||
|
||||
@@ -247,7 +247,7 @@ impl ScriptHost {
|
||||
Dynamic::from(info.clone()),
|
||||
Dynamic::from(state.clone())
|
||||
];
|
||||
arg.map(|d| args.push(d));
|
||||
if let Some(d) = arg { args.push(d) }
|
||||
|
||||
// Call this with opts tagging this call as our id. The write API will read
|
||||
// that to find what queue to emit events to
|
||||
|
||||
@@ -434,7 +434,7 @@ pub enum Hook {
|
||||
}
|
||||
|
||||
impl Hook {
|
||||
pub fn to_str(&self) -> &'static str {
|
||||
pub fn to_str(self) -> &'static str {
|
||||
match self {
|
||||
Hook::Init => "init",
|
||||
Hook::Bump => "bump",
|
||||
|
||||
Reference in New Issue
Block a user