Enum LootSpec

Source
pub enum LootSpec<T: AsRef<str>> {
    Item(T),
    LootTable(T),
    Nothing,
    ModularWeapon {
        tool: ToolKind,
        material: Material,
        hands: Option<Hands>,
    },
    ModularWeaponPrimaryComponent {
        tool: ToolKind,
        material: Material,
        hands: Option<Hands>,
    },
    MultiDrop(Box<LootSpec<T>>, u32, u32),
    All(Vec<LootSpec<T>>),
    Lottery(Vec<(f32, LootSpec<T>)>),
}

Variants§

§

Item(T)

Asset specifier

§

LootTable(T)

Loot table

§

Nothing

No loot given

§

ModularWeapon

Random modular weapon that matches requested restrictions

Fields

§material: Material
§hands: Option<Hands>
§

ModularWeaponPrimaryComponent

Random primary modular weapon component that matches requested restrictions

Fields

§material: Material
§hands: Option<Hands>
§

MultiDrop(Box<LootSpec<T>>, u32, u32)

Dropping variable number of items at random from respective Category

§Examples:

MultiDrop(Item("common.items.utility.coins"), 100, 250)

Will drop 100-250 coins (250 coins is also possible).

MultiDrop(LootTable("common.loot_tables.food.prepared"), 1, 4)

Will drop random item from food.prepared loot table one to four times. Each time the dice is thrown again, so items might get duplicated or not.

§

All(Vec<LootSpec<T>>)

Each category is evaluated, often used to have guaranteed quest item and random reward.

§Examples:

All([
    Item("common.items.keys.bone_key"),
    MultiDrop(
        Item("common.items.crafting_ing.mineral.gem.sapphire"),
        0, 1,
    ),
])

Will always drop bone key, 1-2 furs, and may drop or not drop one sapphire.

All([
    Item("common.items.armor.cultist.necklace"),
    MultiDrop(Item("common.items.armor.cultist.ring"), 2, 2),
])

Will always drop cultist necklace and two cultist rings.

§

Lottery(Vec<(f32, LootSpec<T>)>)

Like a LootTable but inline, most useful with All([]).

§Examples:

All([
    Item("common.items.keys.terracotta_key_door"),

    Lottery([
        // Weapons
        (3.0, LootTable("common.loot_tables.weapons.tier-5")),
        // Armor
        (3.0, LootTable("common.loot_tables.armor.tier-5")),
        // Misc
        (0.25, Item("common.items.tool.instruments.steeltonguedrum")),
    ]),
])

Will always drop a terracotta key, and ONE of items defined in a lottery:

  • one random tier-5 weapon
  • one random tier-5 armour piece
  • Steeldrum

Implementations§

Source§

impl<T: AsRef<str>> LootSpec<T>

Source

fn to_items_inner( &self, rng: &mut ThreadRng, amount: u32, items: &mut Vec<(u32, Item)>, )

Source

pub fn to_items(&self) -> Option<Vec<(u32, Item)>>

Trait Implementations§

Source§

impl<T: Clone + AsRef<str>> Clone for LootSpec<T>

Source§

fn clone(&self) -> LootSpec<T>

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
Source§

impl<T: Debug + AsRef<str>> Debug for LootSpec<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for LootSpec<String>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de, T> Deserialize<'de> for LootSpec<T>
where T: Deserialize<'de> + AsRef<str>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T: PartialEq + AsRef<str>> PartialEq for LootSpec<T>

Source§

fn eq(&self, other: &LootSpec<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> Serialize for LootSpec<T>
where T: Serialize + AsRef<str>,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T: AsRef<str>> StructuralPartialEq for LootSpec<T>

Auto Trait Implementations§

§

impl<T> Freeze for LootSpec<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for LootSpec<T>
where T: RefUnwindSafe,

§

impl<T> Send for LootSpec<T>
where T: Send,

§

impl<T> Sync for LootSpec<T>
where T: Sync,

§

impl<T> Unpin for LootSpec<T>
where T: Unpin,

§

impl<T> UnwindSafe for LootSpec<T>
where T: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<C, M> ConvertSaveload<M> for C

§

type Data = C

(De)Serializable data representation for data type
§

type Error = Infallible

Error may occur during serialization or deserialization of component
§

fn convert_into<F>( &self, _: F, ) -> Result<<C as ConvertSaveload<M>>::Data, <C as ConvertSaveload<M>>::Error>
where F: FnMut(Entity) -> Option<M>,

Convert this data type into serializable form (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>
where F: FnMut(M) -> Option<Entity>,

Convert this data from a deserializable form (Data) using entity to marker mapping function
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.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
§

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

Source§

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,

Source§

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
§

impl<T> TryDefault for T
where T: Default,

§

fn try_default() -> Result<T, String>

Tries to create the default.
§

fn unwrap_default() -> Self

Calls try_default and panics on an error case.
Source§

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

Source§

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

Source§

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
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

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

§

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

§

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