pub struct NetworkSimulationTime { /* private fields */ }
Expand description
Resource to track the state of the network simulation separately from the ECS frame timings
Implementations§
Source§impl NetworkSimulationTime
impl NetworkSimulationTime
Sourcepub fn sim_frames_to_run(&self) -> RangeInclusive<u32>
pub fn sim_frames_to_run(&self) -> RangeInclusive<u32>
Returns the simulation frame numbers needed to be run this game frame.
Sourcepub fn should_send_message_now(&self) -> bool
pub fn should_send_message_now(&self) -> bool
Determines whether or not to send a message in the current frame based on the
message_send_rate
Sourcepub fn should_send_message(&self, frame: u32) -> bool
pub fn should_send_message(&self, frame: u32) -> bool
Determines whether or not to send a message based on the message_send_rate
Sourcepub fn increment_frame_number(&mut self)
pub fn increment_frame_number(&mut self)
Bumps the frame number
Sourcepub fn reset_frame_lag(&mut self)
pub fn reset_frame_lag(&mut self)
Resets the frame lag
Sourcepub fn update_elapsed(&mut self, duration: Duration)
pub fn update_elapsed(&mut self, duration: Duration)
Increases the elapsed_duration
by the given duration
Sourcepub fn frame_number(&self) -> u32
pub fn frame_number(&self) -> u32
Returns the current simulation frame number
Sourcepub fn set_frame_number(&mut self, new_frame: u32)
pub fn set_frame_number(&mut self, new_frame: u32)
Sets the frame number to the given frame number. This is useful when synchronizing frames with a server for example.
Sourcepub fn elapsed_duration(&self) -> Duration
pub fn elapsed_duration(&self) -> Duration
Returns the total duration since the last simulation frame
Sourcepub fn per_frame_duration(&self) -> Duration
pub fn per_frame_duration(&self) -> Duration
Returns the duration between each simulation frame. This number is calculated when a frame rate is set
Sourcepub fn message_send_rate(&self) -> u8
pub fn message_send_rate(&self) -> u8
Returns the rate at which messages should be sent over the network.
i.e. ‘every N frames’ where N is message_send_rate
.
Sourcepub fn frame_lag(&self) -> u32
pub fn frame_lag(&self) -> u32
Returns the number of frames which the simulation is behind. This will usually be 0 or 1 if the ECS system is keeping up.
Sourcepub fn set_sim_frame_rate(&mut self, new_rate: u32)
pub fn set_sim_frame_rate(&mut self, new_rate: u32)
Sets the rate at which the network simulation progresses. Specified in hertz (frames/second).
Sourcepub fn set_message_send_rate(&mut self, new_rate: u8)
pub fn set_message_send_rate(&mut self, new_rate: u8)
Set the rate which messages are sent. Specified as ‘every N frames’ where N is new_rate.
Trait Implementations§
Source§impl Clone for NetworkSimulationTime
impl Clone for NetworkSimulationTime
Source§fn clone(&self) -> NetworkSimulationTime
fn clone(&self) -> NetworkSimulationTime
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for NetworkSimulationTime
impl Debug for NetworkSimulationTime
Source§impl Default for NetworkSimulationTime
impl Default for NetworkSimulationTime
Source§impl PartialEq for NetworkSimulationTime
impl PartialEq for NetworkSimulationTime
impl Copy for NetworkSimulationTime
impl StructuralPartialEq for NetworkSimulationTime
Auto Trait Implementations§
impl Freeze for NetworkSimulationTime
impl RefUnwindSafe for NetworkSimulationTime
impl Send for NetworkSimulationTime
impl Sync for NetworkSimulationTime
impl Unpin for NetworkSimulationTime
impl UnwindSafe for NetworkSimulationTime
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).Source§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.Source§impl<T> TryDefault for Twhere
T: Default,
impl<T> TryDefault for Twhere
T: Default,
Source§fn try_default() -> Result<T, String>
fn try_default() -> Result<T, String>
Source§fn unwrap_default() -> Self
fn unwrap_default() -> Self
try_default
and panics on an error case.