Skip to main content

EquipProvider

Trait EquipProvider 

Source
pub trait EquipProvider: ItemProvider {
    type CustomSlot: Copy + Eq + Hash + Debug;
    type Stat: Copy;

    // Required method
    fn equip_slots(&self, item: &Self::Item) -> Vec<EquipSlot<Self::CustomSlot>>;

    // Provided method
    fn stat_bonuses(&self, item: &Self::Item) -> &[(Self::Stat, i16)] { ... }
}
Expand description

Optional provider trait for games with an equipment system.

Split from ItemProvider so games without equipment (e.g. early JRPGs) never declare slot or stat placeholder types. Games with equipment implement this in addition to ItemProvider; the engine’s equipment flows bound on EquipProvider only where they actually need slot/bonus data.

The Stat associated type fixes the stat key at impl time, so stat_bonuses can return real per-item data (a generic <Stat> method parameter would let the caller pick the type, which no impl could satisfy with anything but an empty slice).

Required Associated Types§

Source

type CustomSlot: Copy + Eq + Hash + Debug

Game-specific equipment slot identifier. Use an uninhabited enum if the standard EquipSlot variants suffice.

Source

type Stat: Copy

The game’s stat identifier for equipment bonuses (typically the same type as the game’s MonsterProvider::Stat).

Required Methods§

Source

fn equip_slots(&self, item: &Self::Item) -> Vec<EquipSlot<Self::CustomSlot>>

Which slots this item can be equipped into. Empty means the item is not equipment.

Provided Methods§

Source

fn stat_bonuses(&self, item: &Self::Item) -> &[(Self::Stat, i16)]

Additive stat bonuses granted while this item is equipped. The game applies these to its own monster stats; the engine never computes totals itself. Defaults to no bonuses.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§