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

source

pub fn empty() -> Self

source

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

source

pub fn from_asset( asset_specifier: &str, rng: &mut impl Rng, time: Option<&(TimeOfDay, Calendar)> ) -> Result<Self, SpecError>

Construct new LoadoutBuilder from asset_specifier

source

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

source

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

source

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

source

pub fn with_default_maintool(self, body: &Body) -> Self

Set default active mainhand weapon based on body

source

pub fn with_default_equipment(self, body: &Body) -> Self

Set default equipement based on body

source

pub fn with_preset(self, preset: Preset) -> Self

source

pub fn with_creator( self, creator: fn(_: LoadoutBuilder, _: Option<&SiteInformation>, time: Option<&(TimeOfDay, Calendar)>) -> LoadoutBuilder, economy: Option<&SiteInformation>, time: Option<&(TimeOfDay, Calendar)> ) -> LoadoutBuilder

source

fn with_loadout_spec<R: Rng>( self, spec: LoadoutSpec, rng: &mut R, time: Option<&(TimeOfDay, Calendar)> ) -> Result<Self, SpecError>

source

pub fn with_asset( self, asset_specifier: &str, rng: &mut impl Rng, time: Option<&(TimeOfDay, Calendar)> ) -> Result<Self, SpecError>

source

pub fn with_asset_expect( self, asset_specifier: &str, rng: &mut impl Rng, time: Option<&(TimeOfDay, Calendar)> ) -> Self

Usage

Creates new LoadoutBuilder with all field replaced from asset_specifier which corresponds to loadout config

Panics
  1. Will panic if there is no asset with such asset_specifier
  2. Will panic if path to item specified in loadout file doesn’t exist
source

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.

source

fn with_equipment(self, equip_slot: EquipSlot, item: Option<Item>) -> Self

source

fn with_armor(self, armor_slot: ArmorSlot, item: Option<Item>) -> Self

source

pub fn active_mainhand(self, item: Option<Item>) -> Self

source

pub fn active_offhand(self, item: Option<Item>) -> Self

source

pub fn inactive_mainhand(self, item: Option<Item>) -> Self

source

pub fn inactive_offhand(self, item: Option<Item>) -> Self

source

pub fn shoulder(self, item: Option<Item>) -> Self

source

pub fn chest(self, item: Option<Item>) -> Self

source

pub fn belt(self, item: Option<Item>) -> Self

source

pub fn hands(self, item: Option<Item>) -> Self

source

pub fn pants(self, item: Option<Item>) -> Self

source

pub fn feet(self, item: Option<Item>) -> Self

source

pub fn back(self, item: Option<Item>) -> Self

source

pub fn ring1(self, item: Option<Item>) -> Self

source

pub fn ring2(self, item: Option<Item>) -> Self

source

pub fn neck(self, item: Option<Item>) -> Self

source

pub fn lantern(self, item: Option<Item>) -> Self

source

pub fn glider(self, item: Option<Item>) -> Self

source

pub fn head(self, item: Option<Item>) -> Self

source

pub fn tabard(self, item: Option<Item>) -> Self

source

pub fn bag(self, which: ArmorSlot, item: Option<Item>) -> Self

source

pub fn build(self) -> Loadout

Trait Implementations§

source§

impl Clone for LoadoutBuilder

source§

fn clone(&self) -> LoadoutBuilder

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. 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.

§

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> Same for T

§

type Output = T

Should always be Self
source§

impl<Context> SubContext<Context> for Context

source§

fn sub_context(self) -> Context

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

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
§

impl<T> Event for T
where T: Send + Sync + 'static,

§

impl<T> Resource for T
where T: Any + Send + Sync,