Skip to main content

AdvancementRegistry

Struct AdvancementRegistry 

Source
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

Source

pub fn new() -> Self

Source

pub fn advancements(&self) -> &[AdvancementRef] ⓘ

Source

pub fn nodes(&self) -> &[AdvancementNode]

Source

fn register_with_parent( &mut self, advancement: AdvancementRef, parent_idx: Option<usize>, )

Source

fn try_register( &mut self, advancement: AdvancementRef, ) -> Option<AdvancementRef>

Source

fn register_all(&mut self, advancements_to_add: Vec<AdvancementRef>)

Source

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.

Source

pub fn value_by_key(&self, key: &Identifier) -> Option<AdvancementRef>

Source

pub fn by_key(&self, key: &Identifier) -> Option<&AdvancementNode>

Source

pub fn get_by_idx(&self, idx: usize) -> Option<&AdvancementNode>

Source

pub fn iter(&self) -> impl Iterator<Item = (usize, &AdvancementNode)> + '_

Source

pub(crate) fn update_tree(&mut self)

Updates the advancement tree by loading and connecting all unloaded advancements.

Source

pub fn root( &'static self, advancement_node: AdvancementNodeRef, ) -> AdvancementNodeRef

Source

pub fn remove_unloaded_advancement(&mut self, advancement: &Identifier)

Trait Implementations§

Source§

impl Debug for AdvancementRegistry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AdvancementRegistry

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> IntoShared for T

Source§

fn into_shared(self) -> Arc<Mutex<RawMutex, Self>> ⓘ

Wraps this value in an Arc<SyncMutex<>>
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more