Class TAliveWithInventory

Unit

Declaration

type TAliveWithInventory = class(TCastleAlive)

Description

Alive 3D thing that has inventory (can keep items).

Hierarchy

Overview

Fields

Public var InternalLevel: TAbstractLevel;

Methods

Public constructor Create(AOwner: TComponent); override;
Public destructor Destroy; override;
Public function PickItemUpdate(var Item: TInventoryItem): Integer; virtual;
Public function PickItem(Item: TInventoryItem): Integer;
Public function DropItem(const Index: Integer): TItemOnWorld; virtual;
Public procedure UseItem(const Index: Integer); virtual;

Properties

Public property Inventory: TInventory read FInventory;

Description

Fields

Public var InternalLevel: TAbstractLevel;

Set when assigning TPlayer to TLevel.Player.

Methods

Public constructor Create(AOwner: TComponent); override;
 
Public destructor Destroy; override;
 
Public 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.

Public 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.

Public 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).

Public 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

Public 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.