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 !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