Class TAliveWithInventory
Unit
Declaration
type TAliveWithInventory = class(TCastleAlive)
Description
Alive 3D thing that has inventory (can keep items).
Hierarchy
- TObject
- TPersistent
- TComponent
- TCastleComponent
- TCastleTransform
- TCastleAlive
- TAliveWithInventory
Overview
Fields
![]() |
var InternalLevel: TAbstractLevel; |
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
Fields
![]() |
var InternalLevel: TAbstractLevel; |
|
Set when assigning TPlayer to TLevel.Player. | |
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. ReturnsDroppped item, or | |
![]() |
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 TAliveWithInventory methods like PickItem or DropItem for this. | |
Generated by PasDoc 0.16.0.
