lotus_script/time.rs
1//! Simulationszeit und Tick-Zähler.
2//!
3//! Simulation time and tick counters.
4
5/// Gibt die vergangene Zeit seit dem letzten Tick in Sekunden zurück (`f32`).
6///
7/// Returns the elapsed time since the last tick in seconds (`f32`).
8pub fn delta() -> f32 {
9 unsafe { lotus_script_sys::time::delta_f64() as f32 }
10}
11
12/// Gibt die vergangene Zeit seit dem letzten Tick in Sekunden zurück (`f64`).
13///
14/// Returns the elapsed time since the last tick in seconds (`f64`).
15pub fn delta_f64() -> f64 {
16 unsafe { lotus_script_sys::time::delta_f64() }
17}
18
19/// Gibt die Anzahl der Ticks zurück, seit das Script aktiv ist.
20///
21/// Returns the number of ticks since the script became active.
22pub fn ticks_alive() -> u64 {
23 unsafe { lotus_script_sys::time::ticks_alive() }
24}
25
26/// Gibt die aktuelle Spielzeit zurück.
27///
28/// Returns the current in-game time.
29pub fn game_time() -> lotus_shared::time::GameTime {
30 let unix_micros = unsafe { lotus_script_sys::time::game_time() };
31 lotus_shared::time::GameTime::from_unix_micros(unix_micros)
32}