Class TInventoryItem

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TInventoryItem = class(TComponent)

Description

An item that can be used, kept in the inventory, or (using PutOnWorld that wraps it in TItemOnWorld) dropped on 3D world. Thanks to the Quantity property, this may actually represent many "stacked" items, all having the same properties.

Hierarchy

  • TComponent
  • TInventoryItem

Overview

Methods

Public function Split(QuantitySplit: Cardinal): TInventoryItem;
Public function PutOnWorld(const AWorld: T3DWorld; const APosition: TVector3Single): TItemOnWorld;
Public function World: T3DWorld;

Properties

Public property Resource: TItemResource read FResource;
Public property Quantity: Cardinal read FQuantity write FQuantity;
Public property Owner3D: T3D read FOwner3D;

Description

Methods

Public function Split(QuantitySplit: Cardinal): TInventoryItem;

Splits item (with Quantity >= 2) into two items. It returns newly created object with the same properties as this object, and with Quantity set to QuantitySplit. And it lowers our Quantity by QuantitySplit.

Always QuantitySplit must be >= 1 and < Quantity.

Public function PutOnWorld(const AWorld: T3DWorld; const APosition: TVector3Single): TItemOnWorld;

Create TItemOnWorld instance referencing this item, and add this to the given 3D AWorld. Although normal item knows (through Owner3D) the world it lives in, but this method may be used for items that don't have an owner yet, so we take AWorld parameter explicitly. This is how you should create new TItemOnWorld instances. It is analogous to TCreatureResource.CreateCreature, but now for items.

Public function World: T3DWorld;

3D world of this item, if any.

Although the TInventoryItem, by itself, is not a 3D thing (only pickable TItemOnWorld is a 3D thing). But it exists inside a 3D world: either as pickable (TItemOnWorld), or as being owned by a 3D object (like player or creature) that are part of 3D world. In other words, our Owner3D.World is the 3D world this item lives in.

Properties

Public property Resource: TItemResource read FResource;
 
Public property Quantity: Cardinal read FQuantity write FQuantity;

Quantity of this item. This must always be >= 1.

Public property Owner3D: T3D read FOwner3D;

3D owner of the item, like a player or creature (if the item is in the backpack) or the TItemOnWorld instance (if the item is lying on the world, pickable). May be Nil only in special situations (when item is moved from one 3D to another, and technically it's safer to Nil this property).

The owner is always responsible for freeing this TInventoryItem instance (in case of TItemOnWorld, it does it directly; in case of player or creature, it does it by TInventory).


Generated by PasDoc 0.13.0 on 2013-08-17 21:27:13