Struct veloren_common::comp::presence::ViewDistance
source · pub struct ViewDistance {
direction: Direction,
last_direction_change_time: Instant,
target: Option<u32>,
current: u32,
}
Expand description
Distance from the Presence from which the world is loaded and information is synced to clients.
We limit the frequency that changes in the view distance change direction (e.g. shifting from increasing the value to decreasing it). This is useful since we want to avoid rapid cycles of shrinking and expanding of the view distance.
Fields§
§direction: Direction
§last_direction_change_time: Instant
§target: Option<u32>
§current: u32
Implementations§
source§impl ViewDistance
impl ViewDistance
sourceconst TIME_PER_DIR_CHANGE: Duration = _
const TIME_PER_DIR_CHANGE: Duration = _
Minimum time allowed between changes in direction of value adjustments.
pub fn new(start_value: u32, now: Instant) -> Self
sourcepub fn update(&mut self, now: Instant)
pub fn update(&mut self, now: Instant)
Applies deferred change based on the whether the time to apply it has been reached.
sourcepub fn set_target(&mut self, new_target: u32, now: Instant)
pub fn set_target(&mut self, new_target: u32, now: Instant)
Sets the target value.
If this hasn’t been changed recently or it is in the same direction as the previous change it will be applied immediately. Otherwise, it will be deferred to a later time (limiting the frequency of changes in the change direction).
Trait Implementations§
source§impl Clone for ViewDistance
impl Clone for ViewDistance
source§fn clone(&self) -> ViewDistance
fn clone(&self) -> ViewDistance
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for ViewDistance
impl Debug for ViewDistance
impl Copy for ViewDistance
Auto Trait Implementations§
impl Freeze for ViewDistance
impl RefUnwindSafe for ViewDistance
impl Send for ViewDistance
impl Sync for ViewDistance
impl Unpin for ViewDistance
impl UnwindSafe for ViewDistance
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,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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