Interface IInventoryItem
Represents an inventory item that a character can hold in his/her inventory.
Namespace: AGS.API
Assembly: AGS.API.dll
Syntax
public interface IInventoryItem
Properties
| Improve this Doc View SourceCursorGraphics
Gets or sets the graphics that represents the inventory item when the mouse cursor is to be shaped like the inventory item (i.e when the character holds the inventory and wants to use it on something). The graphics can be a single image or an animation. This is only relevant when using a mouse cursor (in touch platforms it won't be used, unless we're simulating a mouse).
Declaration
IObject CursorGraphics { get; set; }
Property Value
Type | Description |
---|---|
IObject | The cursor graphics. |
Graphics
Gets or sets the graphics that represents the inventory item when it sits in the inventory window. The graphics can be a single image or an animation.
Declaration
IObject Graphics { get; set; }
Property Value
Type | Description |
---|---|
IObject | The graphics. |
Qty
Gets or sets the quantity of the item of the inventory. Most inventory items don't have quantity, they're either there or not. But, if the inventory item is money, for example, you can use the "Qty" variable to indicate how much money you currently have in your inventory.
Declaration
float Qty { get; set; }
Property Value
Type | Description |
---|---|
System.Single | The item quantity. |
ShouldInteract
Gets or sets a value indicating whether this inventory item is an inventory item that you can only interact with but not combine with other items or objects in the room. Most items will have this as false, but it might be useful in rare cases. For example, if you have a trumpet, and you want the character to be able to play the trumpet at any given time, but don't actually want to use the trumpet on other items, you can assign ShouldInteract = true, and subscribe to the interact event, in order to play the music.
Declaration
bool ShouldInteract { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Methods
| Improve this Doc View SourceOnCombination(IInventoryItem)
Called when one inventory item is combined with another. OnInventoryCombination
Declaration
IEvent<InventoryCombinationEventArgs> OnCombination(IInventoryItem otherItem)
Parameters
Type | Name | Description |
---|---|---|
IInventoryItem | otherItem | The second inventory item, which is combined with this inventory item. |
Returns
Type | Description |
---|---|
IEvent<InventoryCombinationEventArgs> | The event to subscribe. |
Examples
First, we subscribe to the event:
iScissors.OnCombination(iRope).Subscribe(cutRope); //The "cutRope" will be called whether the scissors were used on the rope, or vice versa.
Then, we define the event (we describe what happens when using the scissors and the rope together:
private void cutRope(object sender, InventoryCombinationEventArgs args)
{
displayCutRopeAnimation();
cEgo.Inventory.Items.Remove(iRope); //No more rope for us!
}