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
ModularWeaponPrimaryComponent
Random primary modular weapon component that matches requested restrictions
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§
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for LootSpec<T>
impl<'de, T> Deserialize<'de> for LootSpec<T>
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>,
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> 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§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<Context> SubContext<Context> for Context
impl<Context> SubContext<Context> for Context
fn sub_context(self) -> Context
§impl<T> TryDefault for Twhere
T: Default,
impl<T> TryDefault for Twhere
T: Default,
§fn try_default() -> Result<T, String>
fn try_default() -> Result<T, String>
§fn unwrap_default() -> Self
fn unwrap_default() -> Self
try_default
and panics on an error case.