mirror of
https://github.com/Xevion/smart-rgb.git
synced 2025-12-05 23:16:23 -06:00
35 lines
953 B
Rust
35 lines
953 B
Rust
use bevy_ecs::prelude::*;
|
|
|
|
use crate::networking::Turn;
|
|
|
|
/// Resource containing the current turn data
|
|
/// Updated once per turn (10 TPS), provides turn context to all gameplay systems
|
|
#[derive(Resource)]
|
|
pub struct CurrentTurn {
|
|
pub turn: Turn,
|
|
/// Flag indicating if this turn has been processed by gameplay systems
|
|
/// Set to false when turn arrives, set to true after all systems run
|
|
pub processed: bool,
|
|
}
|
|
|
|
impl CurrentTurn {
|
|
pub fn new(turn: Turn) -> Self {
|
|
Self { turn, processed: false }
|
|
}
|
|
|
|
/// Mark turn as processed
|
|
pub fn mark_processed(&mut self) {
|
|
self.processed = true;
|
|
}
|
|
|
|
/// Check if turn is ready to process (not yet processed)
|
|
pub fn is_ready(&self) -> bool {
|
|
!self.processed
|
|
}
|
|
}
|
|
|
|
/// Run condition: only run when a turn is ready to process
|
|
pub fn turn_is_ready(current_turn: Option<Res<CurrentTurn>>) -> bool {
|
|
current_turn.is_some_and(|ct| ct.is_ready())
|
|
}
|