builtin scripts
This commit is contained in:
@@ -10,9 +10,6 @@ use std::time::Duration;
|
||||
/// How long a `say()` speech bubble stays on screen, in seconds.
|
||||
pub const SAY_DURATION: f64 = 3.0;
|
||||
|
||||
/// How often pusher archetypes fire, in seconds.
|
||||
const PUSHER_INTERVAL: f64 = 0.5;
|
||||
|
||||
// Re-export ScrollLine so kiln-tui can pattern-match scroll content without
|
||||
// accessing the private `action` module directly.
|
||||
pub use crate::action::ScrollLine;
|
||||
@@ -69,9 +66,6 @@ pub struct GameState {
|
||||
/// by [`enter_board`](GameState::enter_board). Front-ends tick this down and
|
||||
/// may block input or show a visual effect while it is `Some(t)` where `t > 0`.
|
||||
pub board_transition: Option<f64>,
|
||||
/// Countdown to the next global pusher heartbeat. When it reaches zero all
|
||||
/// [`Archetype::Pusher`] cells fire and the timer resets to [`PUSHER_INTERVAL`].
|
||||
pusher_timer: f64,
|
||||
}
|
||||
|
||||
impl GameState {
|
||||
@@ -98,7 +92,6 @@ impl GameState {
|
||||
speech_bubbles: Vec::new(),
|
||||
active_scroll: None,
|
||||
board_transition: None,
|
||||
pusher_timer: PUSHER_INTERVAL,
|
||||
};
|
||||
state.drain_errors();
|
||||
state
|
||||
@@ -183,28 +176,9 @@ impl GameState {
|
||||
b.remaining -= secs;
|
||||
b.remaining > 0.0
|
||||
});
|
||||
self.tick_pushers(secs);
|
||||
self.resolve();
|
||||
}
|
||||
|
||||
/// Fires the global pusher heartbeat: every [`PUSHER_INTERVAL`] seconds each
|
||||
/// [`Archetype::Pusher`] cell shoves the occupant directly in front of it.
|
||||
///
|
||||
/// Two-phase to avoid holding the board borrow while calling `push()` (which
|
||||
/// needs `&mut Board`): phase A collects target coordinates, phase B applies them.
|
||||
fn tick_pushers(&mut self, secs: f64) {
|
||||
self.pusher_timer -= secs;
|
||||
if self.pusher_timer > 0.0 {
|
||||
return;
|
||||
}
|
||||
self.pusher_timer += PUSHER_INTERVAL;
|
||||
let pushers: Vec<(usize, usize)> = self.board().pusher_cells();
|
||||
let mut board = self.board_mut();
|
||||
for (x, y) in pushers {
|
||||
board.advance_pusher(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
/// Drains errors collected by the script host into the game log.
|
||||
fn drain_errors(&mut self) {
|
||||
// TODO: errors are only logged for now. This is the place to halt execution /
|
||||
|
||||
Reference in New Issue
Block a user