Class TItemOnWorld

Unit

Declaration

type TItemOnWorld = class(TCastleTransform)

Description

Item that is placed on a 3D world, ready to be picked up. It's not in anyone's inventory.

Hierarchy

Overview

Fields

Public class var RenderDebug: boolean;
Public RotationSpeed: Single;
Public AutoPick: boolean;
Public nested const DefaultRotationSpeed = Pi;

Methods

Public constructor Create(AOwner: TComponent); override;
Public destructor Destroy; override;
Public function GetExists: boolean; override;
Public procedure Update(const SecondsPassed: Single; var RemoveMe: TRemoveType); override;
Public function ExtractItem: TInventoryItem;

Properties

Public property Item: TInventoryItem read FItem;
Public property Collides default false;
Public property CollidesWithMoving default true;

Description

Fields

Public class var RenderDebug: boolean;

Render debug bounding boxes and captions at every creature.

Public RotationSpeed: Single;

Speed of the rotation of 3D item on world. In radians per second, default is DefaultRotationSpeed. Set to zero to disable rotation.

Public AutoPick: boolean;

Does the player automatically picks up items by walking over them. Default is True. If you set this to False, you most probably want to implement some other way of picking up items, use the ExtractItem method.

More precisely, this variable controls when TInventoryItem.Picked is called. When True, it is called for player when player steps over an item (otherwise it's never called). You can always override TInventoryItem.Picked for particular items to customize what happens at "pick" — the default implementation picks an item by adding it to inventory, but you could override it e.g. to consume some potions immediately on pickup.

Public nested const DefaultRotationSpeed = Pi;
 

Methods

Public constructor Create(AOwner: TComponent); override;
 
Public destructor Destroy; override;
 
Public function GetExists: boolean; override;
 
Public procedure Update(const SecondsPassed: Single; var RemoveMe: TRemoveType); override;
 
Public function ExtractItem: TInventoryItem;

Extract the Item, used when picking up the TInventoryItem instance referenced by this TItemOnWorld instance. This returns our Item property, and clears it (clearing also TInventoryItem.Owner3D). At the next Update, this TItemOnWorld instance will be freed and removed from 3D world.

It's up to you what to do with resulting TInventoryItem instance. You can pick it up, by TAliveWithInventory.PickItem (for example player is an instance of TAliveWithInventory), or add it back to 3D world by TInventoryItem.PutOnWorld, or at least free it (or you'll get a memory leak).

Properties

Public property Item: TInventoryItem read FItem;

The Item owned by this TItemOnWorld instance. Never Nil.

Public property Collides default false;
 
Public property CollidesWithMoving default true;
 

Generated by PasDoc 0.15.0.