Struct veloren_common::npc::NpcBody
source · pub struct NpcBody(pub NpcKind, pub Box<dyn FnMut() -> Body>);
Expand description
A combination of an NpcKind (representing an outer species to generate), and a function that generates a fresh Body of a species that is part of that NpcKind each time it’s called. The reason things are done this way is that when parsing spawn strings, we’d like to be able to randomize features that haven’t already been specified; for instance, if no species is specified we should randomize species, while if a species is specified we can still randomize other attributes like gender or clothing.
TODO: Now that we return a closure, consider having the closure accept a source of randomness explicitly, rather than always using ThreadRng.
Tuple Fields§
§0: NpcKind
§1: Box<dyn FnMut() -> Body>
Implementations§
Trait Implementations§
source§impl FromStr for NpcBody
impl FromStr for NpcBody
Auto Trait Implementations§
impl Freeze for NpcBody
impl !RefUnwindSafe for NpcBody
impl !Send for NpcBody
impl !Sync for NpcBody
impl Unpin for NpcBody
impl !UnwindSafe for NpcBody
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>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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 more