pub struct GameTimer {
pub day: u32,
pub tick: u64,
}Expand description
Game timer resource for tracking in-game time progression
This resource provides pure time management without action point coupling. It tracks days and ticks independently of game mechanics.
§Example
use issun::plugin::GameTimer;
let mut timer = GameTimer::new();
assert_eq!(timer.day, 1);
assert_eq!(timer.tick, 0);
let new_day = timer.increment_day();
assert_eq!(new_day, 2);Fields§
§day: u32Current in-game day (starts at 1)
tick: u64Frame/tick counter for sub-day timing
Implementations§
Source§impl GameTimer
impl GameTimer
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new game timer starting at day 1
§Example
use issun::plugin::GameTimer;
let timer = GameTimer::new();
assert_eq!(timer.day, 1);
assert_eq!(timer.tick, 0);Sourcepub fn increment_day(&mut self) -> u32
pub fn increment_day(&mut self) -> u32
Sourcepub fn tick(&mut self)
pub fn tick(&mut self)
Increment tick counter (for realtime/sub-day timing)
§Example
use issun::plugin::GameTimer;
let mut timer = GameTimer::new();
timer.tick();
assert_eq!(timer.tick, 1);Sourcepub fn current_day(&self) -> u32
pub fn current_day(&self) -> u32
Get current day
§Example
use issun::plugin::GameTimer;
let timer = GameTimer::new();
assert_eq!(timer.current_day(), 1);Trait Implementations§
Source§impl<'de> Deserialize<'de> for GameTimer
impl<'de> Deserialize<'de> for GameTimer
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for GameTimer
impl RefUnwindSafe for GameTimer
impl Send for GameTimer
impl Sync for GameTimer
impl Unpin for GameTimer
impl UnsafeUnpin for GameTimer
impl UnwindSafe for GameTimer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> Component for T
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more