pub struct RecipeDiscovery { /* private fields */ }Expand description
Tracks which ingredient combinations a player has already attempted.
Implementations§
Source§impl RecipeDiscovery
impl RecipeDiscovery
pub fn new() -> Self
Sourcepub fn attempt_discovery(
&mut self,
ingredient_ids: &[String],
recipe_book: &RecipeBook,
rng: f32,
) -> Option<String>
pub fn attempt_discovery( &mut self, ingredient_ids: &[String], recipe_book: &RecipeBook, rng: f32, ) -> Option<String>
Attempt to discover a recipe from a list of ingredient ids.
Returns Some(recipe_id) if the combination matches a discoverable recipe
AND the random roll succeeds. rng should be in [0.0, 1.0).
Sourcepub fn is_discovered(&self, recipe_id: &str) -> bool
pub fn is_discovered(&self, recipe_id: &str) -> bool
Check whether a recipe has been discovered.
Sourcepub fn learn_recipe(&mut self, recipe_id: String)
pub fn learn_recipe(&mut self, recipe_id: String)
Force-add a recipe to discovered (e.g. from a recipe book item).
Sourcepub fn all_discovered(&self) -> &[String]
pub fn all_discovered(&self) -> &[String]
All discovered recipe IDs.
Trait Implementations§
Source§impl Clone for RecipeDiscovery
impl Clone for RecipeDiscovery
Source§fn clone(&self) -> RecipeDiscovery
fn clone(&self) -> RecipeDiscovery
Returns a duplicate 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 RecipeDiscovery
impl Debug for RecipeDiscovery
Auto Trait Implementations§
impl Freeze for RecipeDiscovery
impl RefUnwindSafe for RecipeDiscovery
impl Send for RecipeDiscovery
impl Sync for RecipeDiscovery
impl Unpin for RecipeDiscovery
impl UnsafeUnpin for RecipeDiscovery
impl UnwindSafe for RecipeDiscovery
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§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.