Loading...
Searching...
No Matches
AdventureCore.ItemBase Class Reference

Detailed Description

base class for items, items are anything character can own some amount of
implementations can define whether they can be used, equipped or both and then implement some logic that happens in those cases
for example a health potion could be used and equipped, when it is equipped it shows up on the characters belt
and when it is used it starts a healing action or just directly adds health

https://adventure.softleitner.com/manual/item

Inheritance diagram for AdventureCore.ItemBase:
AdventureCore.CapacityRaisingItem AdventureCore.GenericItem AdventureCore.PlaceholderItem AdventureCore.PrefabItem AdventureHero.HeroEquipmentItem AdventureSouls.SoulsArmorItem AdventureSouls.SoulsArrowItem AdventureSouls.SoulsUsableItem AdventureSouls.SoulsWeaponItem

Public Member Functions

virtual ? bool CanAdd (InventoryBase inventory, int quantity=1, bool fully=true)
 checks if a quantity can be added in cases where the adding is handled by OnAdd(InventoryBase, int, out int)
 
virtual bool OnAdd (InventoryBase inventory, int quantity, out int remaining)
 signals to the item that a quantity of it is about to be added to an inventory
gives the item a chance to interfere in that process and do something else instead
for example items that added different items or are used instead of being added
 
virtual bool CanUse (CharacterBase character, int quantity=1)
 checks if the specified quantity of the item can be used on a character
 
virtual bool OnUse (CharacterBase character, int quantity=1)
 uses a quantity of the item on a character
 
virtual bool CanEquip (CharacterBase character)
 checks if the item can be equipped on a character
 
virtual void OnEquip (CharacterBase character)
 called when the item gets equipped on a character
can be used to apply effects like attribute modifications
 
virtual void OnUnequip (CharacterBase character)
 called when the item gets unequipped from a character
can be used to remove effects like attribute modifications
 
void Add (CharacterBase character)
 adds one of this item to a character, this method can be called from events in the inspector by dragging the item into the target
 
void Remove (CharacterBase character)
 removes one of this item from a character, this method can be called from events in the inspector by dragging the item into the target
 
void Add (CharacterActionBase action)
 adds one of this item to the character currently associated with an action, this method can be called from events in the inspector by dragging the item into the target
 
void Remove (CharacterActionBase action)
 removes one of this item from the character currently associated with an action, this method can be called from events in the inspector by dragging the item into the target
 
override string ToString ()
 

Public Attributes

string Key
 
string Name
 
string Description
 
Sprite Image
 
GameObject Visual
 
ItemCategory Category
 
ItemSlotCategory Slot
 

Properties

virtual bool IsStackable [get]
 whether whether multiple items can be stacked in one inventory item
 
virtual bool IsEquippable [get]
 whether the item can be equipped to a slot
 
virtual bool IsUsable [get]
 whether the item can be used
 

Member Function Documentation

◆ Add() [1/2]

void AdventureCore.ItemBase.Add ( CharacterActionBase action)

adds one of this item to the character currently associated with an action, this method can be called from events in the inspector by dragging the item into the target

Parameters
characterthe charracter the item is added to

◆ Add() [2/2]

void AdventureCore.ItemBase.Add ( CharacterBase character)

adds one of this item to a character, this method can be called from events in the inspector by dragging the item into the target

Parameters
characterthe charracter the item is added to

◆ CanAdd()

virtual ? bool AdventureCore.ItemBase.CanAdd ( InventoryBase inventory,
int quantity = 1,
bool fully = true )
virtual

checks if a quantity can be added in cases where the adding is handled by OnAdd(InventoryBase, int, out int)

Parameters
inventorythe inventory the item is about to be added to
quantitythe quantit of the items that is about to be added to the inventory
fullywhether the full quantity has to be added
Returns
true/false if the item has custom adding logic, otherwise null

Reimplemented in AdventureCore.CapacityRaisingItem, AdventureCore.PlaceholderItem, and AdventureCore.UsableItem.

◆ CanEquip()

virtual bool AdventureCore.ItemBase.CanEquip ( CharacterBase character)
virtual

checks if the item can be equipped on a character

Parameters
characterthe character the item may be equipped on
Returns
true if the item may be equipped

Reimplemented in AdventureCore.EquipmentItem, AdventureSouls.SoulsArmorItem, and AdventureSouls.SoulsWeaponItem.

◆ CanUse()

virtual bool AdventureCore.ItemBase.CanUse ( CharacterBase character,
int quantity = 1 )
virtual

checks if the specified quantity of the item can be used on a character

Parameters
characterthe character the item may be used on
quantityhow many items may be used
Returns
whether the usage is possible

◆ OnAdd()

virtual bool AdventureCore.ItemBase.OnAdd ( InventoryBase inventory,
int quantity,
out int remaining )
inlinevirtual

signals to the item that a quantity of it is about to be added to an inventory
gives the item a chance to interfere in that process and do something else instead
for example items that added different items or are used instead of being added

Parameters
inventorythe inventory the item is about to be added to
quantitythe quantit of the items that is about to be added to the inventory
remainingthe remaining quantity if adding was handled by the item
Returns
whether the item has already handled the adding, this means the inventoy does not have to continue its own adding logic

Reimplemented in AdventureCore.CapacityRaisingItem, AdventureCore.PlaceholderItem, and AdventureCore.UsableItem.

◆ OnEquip()

virtual void AdventureCore.ItemBase.OnEquip ( CharacterBase character)
inlinevirtual

called when the item gets equipped on a character
can be used to apply effects like attribute modifications

Parameters
characterthe character the item is equipped on

Reimplemented in AdventureCore.EquipmentItem.

◆ OnUnequip()

virtual void AdventureCore.ItemBase.OnUnequip ( CharacterBase character)
inlinevirtual

called when the item gets unequipped from a character
can be used to remove effects like attribute modifications

Parameters
characterthe character the item was equipped on

Reimplemented in AdventureCore.EquipmentItem.

◆ OnUse()

virtual bool AdventureCore.ItemBase.OnUse ( CharacterBase character,
int quantity = 1 )
virtual

uses a quantity of the item on a character

Parameters
characterthe character to use the items on
quantityhow many items to use
Returns
whether the items have been used

Reimplemented in AdventureCore.UsableItem, and AdventureSouls.SoulsUsableItem.

◆ Remove() [1/2]

void AdventureCore.ItemBase.Remove ( CharacterActionBase action)

removes one of this item from the character currently associated with an action, this method can be called from events in the inspector by dragging the item into the target

Parameters
characterthe charracter the item is removed from

◆ Remove() [2/2]

void AdventureCore.ItemBase.Remove ( CharacterBase character)

removes one of this item from a character, this method can be called from events in the inspector by dragging the item into the target

Parameters
characterthe charracter the item is removed from