pub struct Loadout {
slots: Vec<LoadoutSlot>,
pub(super) recently_unequipped_items: HashMap<ItemDefinitionIdOwned, (Time, u8)>,
}
Fields§
§slots: Vec<LoadoutSlot>
§recently_unequipped_items: HashMap<ItemDefinitionIdOwned, (Time, u8)>
Implementations§
Source§impl Loadout
impl Loadout
pub(super) fn new_empty() -> Self
Sourcepub(super) fn swap(
&mut self,
equip_slot: EquipSlot,
item: Option<Item>,
time: Time,
) -> Option<Item>
pub(super) fn swap( &mut self, equip_slot: EquipSlot, item: Option<Item>, time: Time, ) -> Option<Item>
Replaces the item in the Loadout slot that corresponds to the given EquipSlot and returns the previous item if any
Sourcepub(super) fn equipped(&self, equip_slot: EquipSlot) -> Option<&Item>
pub(super) fn equipped(&self, equip_slot: EquipSlot) -> Option<&Item>
Returns a reference to the item (if any) equipped in the given EquipSlot
fn slot(&self, equip_slot: EquipSlot) -> Option<&LoadoutSlot>
pub(super) fn loadout_idx_for_equip_slot( &self, equip_slot: EquipSlot, ) -> Option<usize>
Sourcepub(super) fn items_with_persistence_key(
&self,
) -> impl Iterator<Item = (&str, Option<&Item>)>
pub(super) fn items_with_persistence_key( &self, ) -> impl Iterator<Item = (&str, Option<&Item>)>
Returns all loadout items paired with their persistence key
Sourcepub fn set_item_at_slot_using_persistence_key(
&mut self,
persistence_key: &str,
item: Item,
) -> Result<(), LoadoutError>
pub fn set_item_at_slot_using_persistence_key( &mut self, persistence_key: &str, item: Item, ) -> Result<(), LoadoutError>
Sets a loadout item in the correct slot using its persistence key. Any item that already exists in the slot is lost.
pub fn get_mut_item_at_slot_using_persistence_key( &mut self, persistence_key: &str, ) -> Result<&mut Item, LoadoutError>
Sourcepub(super) fn swap_slots(
&mut self,
equip_slot_a: EquipSlot,
equip_slot_b: EquipSlot,
time: Time,
)
pub(super) fn swap_slots( &mut self, equip_slot_a: EquipSlot, equip_slot_b: EquipSlot, time: Time, )
Swaps the contents of two loadout slots
Sourcepub(super) fn get_slot_to_equip_into(&self, item: &Item) -> Option<EquipSlot>
pub(super) fn get_slot_to_equip_into(&self, item: &Item) -> Option<EquipSlot>
Gets a slot that an item of a particular ItemKind
can be equipped
into. A slot compatible with the item will be returned, prioritizing
empty slots, then slots with differing items, and returning the first
slot if no other is availible.
Sourcepub(super) fn equipped_items_replaceable_by<'a>(
&'a self,
item_kind: &'a ItemKind,
) -> impl Iterator<Item = &'a Item>
pub(super) fn equipped_items_replaceable_by<'a>( &'a self, item_kind: &'a ItemKind, ) -> impl Iterator<Item = &'a Item>
Returns all items currently equipped that an item of the given ItemKind could replace
Sourcepub(super) fn inv_slot(
&self,
loadout_slot_id: LoadoutSlotId,
) -> Option<&InvSlot>
pub(super) fn inv_slot( &self, loadout_slot_id: LoadoutSlotId, ) -> Option<&InvSlot>
Returns the InvSlot
for a given LoadoutSlotId
Sourcepub(super) fn inv_slot_mut(
&mut self,
loadout_slot_id: LoadoutSlotId,
) -> Option<&mut InvSlot>
pub(super) fn inv_slot_mut( &mut self, loadout_slot_id: LoadoutSlotId, ) -> Option<&mut InvSlot>
Returns the InvSlot
for a given LoadoutSlotId
Sourcepub(super) fn inv_slots_with_id(
&self,
) -> impl Iterator<Item = (LoadoutSlotId, &InvSlot)>
pub(super) fn inv_slots_with_id( &self, ) -> impl Iterator<Item = (LoadoutSlotId, &InvSlot)>
Returns all inventory slots provided by equipped loadout items, along
with their LoadoutSlotId
Sourcepub(super) fn inv_slots_mut(&mut self) -> impl Iterator<Item = &mut InvSlot>
pub(super) fn inv_slots_mut(&mut self) -> impl Iterator<Item = &mut InvSlot>
Returns all inventory slots provided by equipped loadout items
pub(super) fn inv_slots_mut_with_mutable_recently_unequipped_items( &mut self, ) -> (impl Iterator<Item = &mut InvSlot>, &mut HashMap<ItemDefinitionIdOwned, (Time, u8)>)
Sourcepub(super) fn slot_range_for_equip_slot(
&self,
equip_slot: EquipSlot,
) -> Option<Range<usize>>
pub(super) fn slot_range_for_equip_slot( &self, equip_slot: EquipSlot, ) -> Option<Range<usize>>
Gets the range of loadout-provided inventory slot indexes that are
provided by the item in the given EquipSlot
Sourcepub(super) fn try_equip(&mut self, item: Item) -> Result<(), Item>
pub(super) fn try_equip(&mut self, item: Item) -> Result<(), Item>
Attempts to equip the item into a compatible, unpopulated loadout slot. If no slot is available the item is returned.
pub(super) fn items(&self) -> impl Iterator<Item = &Item>
pub(super) fn items_with_slot(&self) -> impl Iterator<Item = (EquipSlot, &Item)>
Sourcepub(super) fn slot_can_hold(
&self,
equip_slot: EquipSlot,
item_kind: Option<&ItemKind>,
) -> bool
pub(super) fn slot_can_hold( &self, equip_slot: EquipSlot, item_kind: Option<&ItemKind>, ) -> bool
Checks that a slot can hold a given item
fn is_valid_weapon_pair( main_hand: Option<&ItemKind>, off_hand: Option<&ItemKind>, ) -> bool
pub(super) fn swap_equipped_weapons(&mut self, time: Time)
Sourcepub fn persistence_update_all_item_states(
&mut self,
ability_map: &AbilityMap,
msm: &MaterialStatManifest,
)
pub fn persistence_update_all_item_states( &mut self, ability_map: &AbilityMap, msm: &MaterialStatManifest, )
Update internal computed state of all top level items in this loadout. Used only when loading in persistence code.
Sourcepub(super) fn damage_items(
&mut self,
ability_map: &AbilityMap,
msm: &MaterialStatManifest,
)
pub(super) fn damage_items( &mut self, ability_map: &AbilityMap, msm: &MaterialStatManifest, )
Increments durability by 1 of all valid items
Sourcepub(super) fn repair_item_at_slot(
&mut self,
equip_slot: EquipSlot,
ability_map: &AbilityMap,
msm: &MaterialStatManifest,
)
pub(super) fn repair_item_at_slot( &mut self, equip_slot: EquipSlot, ability_map: &AbilityMap, msm: &MaterialStatManifest, )
Resets durability of item in specified slot
pub(super) fn cull_recently_unequipped_items(&mut self, time: Time)
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Loadout
impl<'de> Deserialize<'de> for Loadout
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Loadout
impl !RefUnwindSafe for Loadout
impl Send for Loadout
impl Sync for Loadout
impl Unpin for Loadout
impl !UnwindSafe for Loadout
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,
§impl<C, M> ConvertSaveload<M> for C
impl<C, M> ConvertSaveload<M> for C
§type Error = Infallible
type Error = Infallible
§fn convert_into<F>(
&self,
_: F,
) -> Result<<C as ConvertSaveload<M>>::Data, <C as ConvertSaveload<M>>::Error>
fn convert_into<F>( &self, _: F, ) -> Result<<C as ConvertSaveload<M>>::Data, <C as ConvertSaveload<M>>::Error>
Data
) using
entity to marker mapping function§fn convert_from<F>(
data: <C as ConvertSaveload<M>>::Data,
_: F,
) -> Result<C, <C as ConvertSaveload<M>>::Error>
fn convert_from<F>( data: <C as ConvertSaveload<M>>::Data, _: F, ) -> Result<C, <C as ConvertSaveload<M>>::Error>
Data
) using
entity to marker mapping function§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