pub struct Item {Show 15 fields
pub id: ItemId,
pub symbol: String,
pub name: String,
pub description: String,
pub location: Location,
pub visibility: ItemVisibility,
pub visible_when: Option<EventCondition>,
pub aliases: Vec<String>,
pub movability: Movability,
pub container_state: Option<ContainerState>,
pub contents: HashSet<ItemId>,
pub abilities: HashSet<ItemAbility>,
pub interaction_requires: HashMap<ItemInteractionType, ItemAbility>,
pub text: Option<String>,
pub consumable: Option<ConsumableOpts>,
}Expand description
Anything in ‘AmbleWorld’ that can be inspected or manipulated apart from NPCs.
Some ‘Items’ can also act as containers for other items, if ‘container_state’ is ‘Some(_)’.
symbol and id refer to the same string – a holdover from a previous engine version where they differed.
movability specifies whether the Item can change location, and why not if it can’t.
‘abilities’ are special things you can do with this item (e.g. read, smash, ignite, clean)
‘interaction_requires’ maps a type of interaction (a thing that can be done to this item using another item) to an ability.
e.g. ItemInteractionType::Burn => ItemAbility::Ignite
Combined with an appropriate ActOnItem-based trigger, this would mean any Item with ItemAbility::Ignite can be
used to Burn this item – and importantly only items with that ability can be used to Burn it.
‘consumable’ makes an item consumable if present, with number of uses and what to do when
all uses are expended defined in ConsumableOpts.
Fields§
§id: ItemIdThe stable id of this item.
symbol: StringThe symbol used to refer to this item in world data.
name: StringThe display name of the item.
description: StringA general description of the item.
location: LocationThe current Location of the item.
visibility: ItemVisibilityDetermines whether the item appears in listings or is discoverable.
visible_when: Option<EventCondition>Optional condition gating visibility.
aliases: Vec<String>Alternate names that can match this item in parser searches.
movability: MovabilityDetermines whether the item can be moved from its current location.
container_state: Option<ContainerState>Some state (open, locked, etc) for the item as a container, or None if it is not a container.
contents: HashSet<ItemId>Set of ids of other items contained by this one.
abilities: HashSet<ItemAbility>Set of capabilities ItemAbility for this item.
interaction_requires: HashMap<ItemInteractionType, ItemAbility>Relates interactions to abilities. (Ex: to perform the “burn” interaction targeting this item, the other item must have the “ignite” capability.)
text: Option<String>Any legible detail text on the item. Also used as the detail text for the “examine” command.
consumable: Option<ConsumableOpts>Some consumable parameters ConsumableOpts, or None it the item isn’t consumable.
Implementations§
Source§impl Item
impl Item
Sourcepub fn is_consumed(&self) -> bool
pub fn is_consumed(&self) -> bool
Returns true if item is consumable and has been consumed.
Sourcepub fn is_accessible(&self) -> bool
pub fn is_accessible(&self) -> bool
Returns true if item’s contents can be accessed directly.
Sourcepub fn is_transparent(&self) -> bool
pub fn is_transparent(&self) -> bool
Returns true if the item is a container and its contents are visible even when closed or locked.
Sourcepub fn set_location_room(&mut self, room_id: RoomId)
pub fn set_location_room(&mut self, room_id: RoomId)
Set location to a Room by id.
Sourcepub fn set_location_item(&mut self, container_id: ItemId)
pub fn set_location_item(&mut self, container_id: ItemId)
Set location to inside another container Item by id.
Sourcepub fn set_location_inventory(&mut self)
pub fn set_location_inventory(&mut self)
Set location to player inventory
Sourcepub fn set_location_npc(&mut self, npc_id: NpcId)
pub fn set_location_npc(&mut self, npc_id: NpcId)
Set location to NPC inventory by id.
Sourcepub fn show(&self, world: &AmbleWorld, view: &mut View)
pub fn show(&self, world: &AmbleWorld, view: &mut View)
Show item description (and any contents if a container and open).
Sourcepub fn requires_capability_for(
&self,
inter: ItemInteractionType,
) -> Option<ItemAbility>
pub fn requires_capability_for( &self, inter: ItemInteractionType, ) -> Option<ItemAbility>
Determine what ability is required for certain interactions with this item.
In <verb> <target> with <tool> commands, this returns whatever ability the <tool> must have
in order to successfully <verb> the <target> (this item).
Example – if this item is candle, then:
candle.requires_capability_for(ItemInteractionType::Burn)
might return Some(ItemAbility::Ignite).
Sourcepub fn access_denied_reason(&self) -> Option<String>
pub fn access_denied_reason(&self) -> Option<String>
Returns the reason the item can’t be accessed (as a container), if any
Sourcepub fn take_denied_reason(&self) -> Option<String>
pub fn take_denied_reason(&self) -> Option<String>
Returns the reason an item can’t be taken into inventory, if any