pub struct StatsCounter {
pub(super) stats: FxHashMap<Stat, (i32, StatState)>,
}Expand description
Manages the counters for every statistic for a particular player.
Analogous to Vanilla’s ServerStatsCounter.java.
Fields§
§stats: FxHashMap<Stat, (i32, StatState)>The map of each stat currently being tracked to its value and state.
Implementations§
Source§impl StatsCounter
impl StatsCounter
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new, empty StatsCounter.
Sourcepub fn get(&self, stat: &Stat) -> i32
pub fn get(&self, stat: &Stat) -> i32
Gets the value of the counter corresponding to the given stat.
If this counter is not currently being tracked, 0 is returned instead.
Sourcepub fn set(&mut self, stat: Stat, count: i32)
pub fn set(&mut self, stat: Stat, count: i32)
Sets the value of the counter corresponding to the given stat to a given value.
Sourcepub fn increment(&mut self, stat: Stat, count: i32)
pub fn increment(&mut self, stat: Stat, count: i32)
Increments the value of the counter corresponding to the given stat by a given value.
Sourcepub fn mark_all_dirty(&mut self)
pub fn mark_all_dirty(&mut self)
Marks all the stat counters of this player to be dirty. This means that the next time statistics are requested, all tracked stat counters will be sent to the client.
Sourcepub(crate) fn get_dirty_and_clear(&mut self) -> Vec<(Stat, i32)>
pub(crate) fn get_dirty_and_clear(&mut self) -> Vec<(Stat, i32)>
Gets all the counters of stats that are marked dirty and clears their dirty flag as well.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Sets the counters of all stats in this counter to zero, and marks them as reset. The stats will not be persisted, but will be sent to the client the next time they are queried.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for StatsCounter
impl !UnwindSafe for StatsCounter
impl Freeze for StatsCounter
impl Send for StatsCounter
impl Sync for StatsCounter
impl Unpin for StatsCounter
impl UnsafeUnpin for StatsCounter
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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> ⓘ
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 moreArc<SyncMutex<>>