pub struct ClockSpeed { /* private fields */ }Expand description
The mod’s say in how fast the server’s clock runs; get it from
Load::clock_speed.
The clock runs at the game’s own speed times every mod’s factor, so mods compose: one that doubles the day and one that halves it leave it as it was. Players sleeping at night still speed it up on top.
§Examples
use enshwick::events::WorldLoaded;
fn init(load: &mut enshwick::Load<'_>) -> Result<(), enshwick::Off> {
let speed = load.clock_speed()?;
load.on::<WorldLoaded>(move |()| {
if let Err(why) = speed.set(0.5) {
enshwick::warn!("the clock keeps its speed: {why}");
}
})
}Implementations§
Source§impl ClockSpeed
impl ClockSpeed
Sourcepub fn set(&self, factor: f32) -> Result<(), WorldError>
pub fn set(&self, factor: f32) -> Result<(), WorldError>
Sets the mod’s factor on the clock’s speed: 1 leaves it, 2 makes the days pass twice as fast, 0 stops the clock. Clients follow after the next step.
§Errors
WorldError::Refused for a factor outside 0 to ClockSpeed::MAX,
WorldError::WrongThread off the game thread and
WorldError::Missing on a build without the clock.
§Examples
See ClockSpeed.
Trait Implementations§
Source§impl Clone for ClockSpeed
impl Clone for ClockSpeed
impl Copy for ClockSpeed
Auto Trait Implementations§
impl Freeze for ClockSpeed
impl RefUnwindSafe for ClockSpeed
impl Send for ClockSpeed
impl Sync for ClockSpeed
impl Unpin for ClockSpeed
impl UnsafeUnpin for ClockSpeed
impl UnwindSafe for ClockSpeed
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