Struct veloren_common::comp::inventory::loadout_builder::LoadoutBuilder
source · pub struct LoadoutBuilder(Loadout);
Expand description
Builder for character Loadouts, containing weapon and armour items belonging
to a character, along with some helper methods for loading Item
-s and
ItemConfig
use veloren_common::{comp::Item, LoadoutBuilder};
// Build a loadout with character starter defaults
// and a specific sword with default sword abilities
let sword = Item::new_from_asset_expect("common.items.weapons.sword.starter");
let loadout = LoadoutBuilder::empty()
.defaults()
.active_mainhand(Some(sword))
.build();
Tuple Fields§
§0: Loadout
Implementations§
source§impl LoadoutBuilder
impl LoadoutBuilder
pub fn empty() -> Self
sourcepub fn from_asset_expect(
asset_specifier: &str,
rng: &mut impl Rng,
time: Option<&(TimeOfDay, Calendar)>,
) -> Self
pub fn from_asset_expect( asset_specifier: &str, rng: &mut impl Rng, time: Option<&(TimeOfDay, Calendar)>, ) -> Self
Construct new LoadoutBuilder
from asset_specifier
Will panic if asset is broken
sourcepub fn from_asset(
asset_specifier: &str,
rng: &mut impl Rng,
time: Option<&(TimeOfDay, Calendar)>,
) -> Result<Self, SpecError>
pub fn from_asset( asset_specifier: &str, rng: &mut impl Rng, time: Option<&(TimeOfDay, Calendar)>, ) -> Result<Self, SpecError>
Construct new LoadoutBuilder
from asset_specifier
sourcepub fn from_default(body: &Body) -> Self
pub fn from_default(body: &Body) -> Self
Construct new default LoadoutBuilder
for corresponding body
NOTE: make sure that you check what is default for this body Use it if you don’t care much about it, for example in “/spawn” command
sourcepub fn from_loadout_spec(
loadout_spec: LoadoutSpec,
rng: &mut impl Rng,
time: Option<&(TimeOfDay, Calendar)>,
) -> Result<Self, SpecError>
pub fn from_loadout_spec( loadout_spec: LoadoutSpec, rng: &mut impl Rng, time: Option<&(TimeOfDay, Calendar)>, ) -> Result<Self, SpecError>
Construct new LoadoutBuilder
from asset_specifier
sourcepub fn from_loadout_spec_expect(
loadout_spec: LoadoutSpec,
rng: &mut impl Rng,
time: Option<&(TimeOfDay, Calendar)>,
) -> Self
pub fn from_loadout_spec_expect( loadout_spec: LoadoutSpec, rng: &mut impl Rng, time: Option<&(TimeOfDay, Calendar)>, ) -> Self
Construct new LoadoutBuilder
from asset_specifier
Will panic if asset is broken
sourcepub fn with_default_maintool(self, body: &Body) -> Self
pub fn with_default_maintool(self, body: &Body) -> Self
Set default active mainhand weapon based on body
sourcepub fn with_default_equipment(self, body: &Body) -> Self
pub fn with_default_equipment(self, body: &Body) -> Self
Set default equipement based on body
pub fn with_preset(self, preset: Preset) -> Self
pub fn with_creator( self, creator: fn(_: LoadoutBuilder, _: Option<&SiteInformation>, time: Option<&(TimeOfDay, Calendar)>) -> LoadoutBuilder, economy: Option<&SiteInformation>, time: Option<&(TimeOfDay, Calendar)>, ) -> LoadoutBuilder
fn with_loadout_spec<R: Rng>( self, spec: LoadoutSpec, rng: &mut R, time: Option<&(TimeOfDay, Calendar)>, ) -> Result<Self, SpecError>
pub fn with_asset( self, asset_specifier: &str, rng: &mut impl Rng, time: Option<&(TimeOfDay, Calendar)>, ) -> Result<Self, SpecError>
sourcepub fn with_asset_expect(
self,
asset_specifier: &str,
rng: &mut impl Rng,
time: Option<&(TimeOfDay, Calendar)>,
) -> Self
pub fn with_asset_expect( self, asset_specifier: &str, rng: &mut impl Rng, time: Option<&(TimeOfDay, Calendar)>, ) -> Self
sourcepub fn defaults(self) -> Self
pub fn defaults(self) -> Self
Set default armor items for the loadout. This may vary with game updates, but should be safe defaults for a new character.
fn with_equipment(self, equip_slot: EquipSlot, item: Option<Item>) -> Self
fn with_armor(self, armor_slot: ArmorSlot, item: Option<Item>) -> Self
pub fn active_mainhand(self, item: Option<Item>) -> Self
pub fn active_offhand(self, item: Option<Item>) -> Self
pub fn inactive_mainhand(self, item: Option<Item>) -> Self
pub fn inactive_offhand(self, item: Option<Item>) -> Self
pub fn shoulder(self, item: Option<Item>) -> Self
pub fn chest(self, item: Option<Item>) -> Self
pub fn belt(self, item: Option<Item>) -> Self
pub fn hands(self, item: Option<Item>) -> Self
pub fn pants(self, item: Option<Item>) -> Self
pub fn feet(self, item: Option<Item>) -> Self
pub fn back(self, item: Option<Item>) -> Self
pub fn ring1(self, item: Option<Item>) -> Self
pub fn ring2(self, item: Option<Item>) -> Self
pub fn neck(self, item: Option<Item>) -> Self
pub fn lantern(self, item: Option<Item>) -> Self
pub fn glider(self, item: Option<Item>) -> Self
pub fn head(self, item: Option<Item>) -> Self
pub fn tabard(self, item: Option<Item>) -> Self
pub fn bag(self, which: ArmorSlot, item: Option<Item>) -> Self
pub fn build(self) -> Loadout
Trait Implementations§
source§impl Clone for LoadoutBuilder
impl Clone for LoadoutBuilder
source§fn clone(&self) -> LoadoutBuilder
fn clone(&self) -> LoadoutBuilder
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for LoadoutBuilder
impl RefUnwindSafe for LoadoutBuilder
impl Send for LoadoutBuilder
impl Sync for LoadoutBuilder
impl Unpin for LoadoutBuilder
impl UnwindSafe for LoadoutBuilder
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§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>
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>
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