Castle Game Engine: CastleItems: Class T3DAliveWithInventory

# Class T3DAliveWithInventory
Description | Hierarchy | Fields | Methods | Properties
## Unit CastleItems ## Declaration `type T3DAliveWithInventory = class(T3DAlive)` ## Description Alive 3D thing that has inventory (can keep items). ## Hierarchy TComponent T3D T3DList T3DCustomTransform T3DOrient T3DAlive T3DAliveWithInventory ## Overview ### Methods
| `constructor Create(AOwner: TComponent); override;`
| `destructor Destroy; override;`
| `function PickItemUpdate(var Item: TInventoryItem): Integer; virtual;`
| `function PickItem(Item: TInventoryItem): Integer;`
| `function DropItem(const Index: Integer): TItemOnWorld; virtual;`
| `procedure UseItem(const Index: Integer); virtual;`
### Properties
| `property Inventory: TInventory read FInventory;`
## Description ### Methods
| `constructor Create(AOwner: TComponent); override;`
| `destructor Destroy; override;`
| `function PickItemUpdate(var Item: TInventoryItem): Integer; virtual;`
Add given Item to Inventory. Because an item may be stacked with others, the actual Item instance may be freed and replaced with other by this method, that is why Item parameter is "var". Use PickItem method if you don't care about your Item instance. Returns index to the added item. Using this method means that the memory management of the item becomes the responsibility of this list.
| `function PickItem(Item: TInventoryItem): Integer;`
Add given Item to Inventory. See PickItemUpdate for details. This is a shortcut to call PickItemUpdate and then ignore changes to Item instance. Calling this method may be comfortable, but remember that the Item instance possibly doesn't exist after we finish.
| `function DropItem(const Index: Integer): TItemOnWorld; virtual;`
Drop item from Inventory. It is Ok to pass here Index out of range, it will be ignored. ###### Returns Droppped item, or `Nil` if the operation was not completed due to any reason (e.g. no space on 3D world to fit this item).
| `procedure UseItem(const Index: Integer); virtual;`
Use an item from Inventory. Calls TInventoryItem.Use, and then checks whether the item was depleted (and eventually removes it from repository). It is Ok to pass here Index out of range, it will be ignored.
### Properties
| `property Inventory: TInventory read FInventory;`
Owned items. Never change the contents of this list directly, always use T3DAliveWithInventory methods like PickItem or DropItem for this.
Generated by PasDoc 0.13.0 on 2015-06-15 04:43:10