Class TItemOnWorld

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TItemOnWorld = class(T3DOrient)

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 RotationSpeed: Single; static;
Public AutoPick: boolean; static;
Public internal const DefaultRotationSpeed = Pi;

Methods

Public constructor Create(AOwner: TComponent); override;
Public destructor Destroy; override;
Public procedure Render(const Frustum: TFrustum; const Params: TRenderParams); override;
Public procedure Idle(const CompSpeed: 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 RotationSpeed: Single; static;

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; static;

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 internal const DefaultRotationSpeed = Pi;
 

Methods

Public constructor Create(AOwner: TComponent); override;
 
Public destructor Destroy; override;
 
Public procedure Render(const Frustum: TFrustum; const Params: TRenderParams); override;

Render the item, on current Position with current rotation etc. Current matrix should be modelview, this pushes/pops matrix state (so it 1. needs one place on matrix stack, 2. doesn't modify current matrix).

Pass current viewing Frustum to allow optimizing this (when item for sure is not within Frustum, we don't have to push it to OpenGL).

Public procedure Idle(const CompSpeed: 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 Idle, 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 T3DAliveWithInventory.PickItem (for example player is an instance of T3DAliveWithInventory), 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.12.1 on 2013-02-04 20:26:51