pub struct StatTypeRegistry {
stat_types_by_id: Vec<StatTypeEntryRef>,
stat_types_by_key: FxHashMap<Identifier, usize>,
allows_registering: bool,
}Expand description
Registry of all stat types. A stat type is always associated with a registry whose values will be used to identify stats from this stat type.
For example, ITEM_DROPPED uses the item registry to have each item in this registry become a stat
under this stat type (like diamond) to track how many of those items have been dropped by the player.
Fields§
§stat_types_by_id: Vec<StatTypeEntryRef>Stat types indexed by network ID.
stat_types_by_key: FxHashMap<Identifier, usize>Map which maps from the stat type identifier to its network ID.
allows_registering: boolWhether registration is still allowed.
Implementations§
Source§impl StatTypeRegistry
impl StatTypeRegistry
Sourcepub fn register<R, F>(
&mut self,
stat_type: StatTypeRef<R>,
registry_supplier: F,
)
pub fn register<R, F>( &mut self, stat_type: StatTypeRef<R>, registry_supplier: F, )
Registers a stat type in this registry.
The registry supplied in this function must be in a supplier so that it only runs once when the registries are initialized.
Sourcepub fn iter(&self) -> impl Iterator<Item = (usize, StatTypeEntryRef)> + '_
pub fn iter(&self) -> impl Iterator<Item = (usize, StatTypeEntryRef)> + '_
Iterates all stat type entries in this registry.
Trait Implementations§
Source§impl Default for StatTypeRegistry
impl Default for StatTypeRegistry
Source§impl RegistryExt for StatTypeRegistry
impl RegistryExt for StatTypeRegistry
type Entry = StatTypeEntry
fn freeze(&mut self)
fn by_id(&self, id: usize) -> Option<&'static StatTypeEntry>
fn by_key(&self, key: &Identifier) -> Option<&'static StatTypeEntry>
fn id_from_key(&self, key: &Identifier) -> Option<usize>
fn len(&self) -> usize
fn is_empty(&self) -> bool
Auto Trait Implementations§
impl !RefUnwindSafe for StatTypeRegistry
impl !UnwindSafe for StatTypeRegistry
impl Freeze for StatTypeRegistry
impl Send for StatTypeRegistry
impl Sync for StatTypeRegistry
impl Unpin for StatTypeRegistry
impl UnsafeUnpin for StatTypeRegistry
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
§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> ⓘ
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 moreWraps this value in an
Arc<SyncMutex<>>