Class TInventory

Unit

Declaration

type TInventory = class(specialize TObjectList<TInventoryItem>)

Description

List of items, with a 3D object (like a player or creature) owning these items. Do not directly change this list, always use the owner (TAliveWithInventory) methods like TAliveWithInventory.PickItem or TAliveWithInventory.DropItem. They make sure that items are correctly stacked, and that TInventoryItem.Owner3D and memory management is good.

Hierarchy

  • TObject
  • TList
  • TObjectList
  • TInventory

Overview

Methods

Protected function Pick(var Item: TInventoryItem): Integer;
Protected function Drop(const ItemIndex: Integer): TInventoryItem;
Protected procedure CheckDepleted(const Item: TInventoryItem);
Protected procedure Use(const Index: Integer);
Public constructor Create(const AOwner3D: TAliveWithInventory);
Public function FindResource(Resource: TItemResource): Integer;

Properties

Public property Owner3D: TAliveWithInventory read FOwner3D;

Description

Methods

Protected function Pick(var Item: TInventoryItem): Integer;

Add Item to inventory. See TAliveWithInventory.PickItemUpdate description, this method actually implements it.

Protected function Drop(const ItemIndex: Integer): TInventoryItem;

Drop item with given index. ItemIndex must be valid (between 0 and Items.Count - 1). You must take care yourself of returned TInventoryItem memory management. This is the low-level basis for TAliveWithInventory.DropItem.

Protected procedure CheckDepleted(const Item: TInventoryItem);

Pass here items owned by this list, immediately after decreasing their Quantity. This frees the item (removing it from the list) if it's quantity reached zero.

Protected procedure Use(const Index: Integer);

Use the item of given index. This is the low-level basis for TAliveWithInventory.UseItem.

Public constructor Create(const AOwner3D: TAliveWithInventory);
 
Public function FindResource(Resource: TItemResource): Integer;

Searches for item of given Resource. Returns index of first found, or -1 if not found.

Properties

Public property Owner3D: TAliveWithInventory read FOwner3D;

Owner of the inventory (like a player or creature). Never Nil, always valid for given inventory. All items on this list always have the same TInventoryItem.Owner3D value as the inventory they are in.


Generated by PasDoc 0.16.0.