pub struct AdvancementRegistry {
pub(crate) advancements: Vec<AdvancementRef>,
pub(crate) adv_nodes: Vec<AdvancementNode>,
pub(crate) unloaded_advancement: FxHashSet<AdvancementRef>,
pub(crate) by_key: FxHashMap<Identifier, usize>,
pub(crate) roots: Vec<usize>,
pub(crate) tasks: Vec<usize>,
}Expand description
equivalent of the AdvancementTree of the minecraft source code
TODO add Dynamic allocated Advancement with a enum :
use steel_registry::advancement::Advancement;
use steel_registry::advancement::registry::AdvancementRef;
enum AdvancementHolder {
Static(AdvancementRef),
Dynamic(Box<Advancement>),
}TODO add the ability to reload the registry.
TODO made the registry behind a ArcSwap and the unloaded_advancement behind a Mutex to allow for dynamic reloading of advancements.
Fields§
§advancements: Vec<AdvancementRef>§adv_nodes: Vec<AdvancementNode>§unloaded_advancement: FxHashSet<AdvancementRef>§by_key: FxHashMap<Identifier, usize>§roots: Vec<usize>§tasks: Vec<usize>Implementations§
Source§impl AdvancementRegistry
impl AdvancementRegistry
pub fn new() -> Self
pub fn advancements(&self) -> &[AdvancementRef] ⓘ
pub fn nodes(&self) -> &[AdvancementNode]
fn register_with_parent( &mut self, advancement: AdvancementRef, parent_idx: Option<usize>, )
fn try_register( &mut self, advancement: AdvancementRef, ) -> Option<AdvancementRef>
fn register_all(&mut self, advancements_to_add: Vec<AdvancementRef>)
Sourcepub fn register(&mut self, advancement: AdvancementRef) -> bool
pub fn register(&mut self, advancement: AdvancementRef) -> bool
Registers an advancement in the registry. Returns true if the advancement was added to the unloaded advancements set, false if it was already present.
pub fn value_by_key(&self, key: &Identifier) -> Option<AdvancementRef>
pub fn by_key(&self, key: &Identifier) -> Option<&AdvancementNode>
pub fn get_by_idx(&self, idx: usize) -> Option<&AdvancementNode>
pub fn iter(&self) -> impl Iterator<Item = (usize, &AdvancementNode)> + '_
Sourcepub(crate) fn update_tree(&mut self)
pub(crate) fn update_tree(&mut self)
Updates the advancement tree by loading and connecting all unloaded advancements.
pub fn root( &'static self, advancement_node: AdvancementNodeRef, ) -> AdvancementNodeRef
pub fn remove_unloaded_advancement(&mut self, advancement: &Identifier)
Trait Implementations§
Source§impl Debug for AdvancementRegistry
impl Debug for AdvancementRegistry
Auto Trait Implementations§
impl !RefUnwindSafe for AdvancementRegistry
impl !UnwindSafe for AdvancementRegistry
impl Freeze for AdvancementRegistry
impl Send for AdvancementRegistry
impl Sync for AdvancementRegistry
impl Unpin for AdvancementRegistry
impl UnsafeUnpin for AdvancementRegistry
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<>>