generated from GarandPLG/rust-flake-template
Add tick thread and Skirmish state update
Introduce `AppEvent::Tick` and a background thread that emits timed events. `App` now handles `Tick` by calling a new `update` method, which advances the board and increments a `turn_counter` in `SkirmishState`. Add required imports, fields, and the `spawn_tick_thread` call in `main`.
This commit is contained in:
@@ -65,6 +65,7 @@ impl App {
|
||||
.board
|
||||
.change_resize(&window_area, state.skirmish.side_panel);
|
||||
}
|
||||
AppEvent::Tick => self.update()?,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,4 +91,11 @@ impl App {
|
||||
handle_keybindings(self, key_event);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn update(&mut self) -> Result<()> {
|
||||
if let Some(state) = self.states_mut() {
|
||||
state.skirmish.update(&self.args);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user