CAST II Game Engine

   DESCRIPTION       FEATURES       SCREENSHOTS       FORUMS       DOCUMENTATION       DOWNLOADS       CONTACTS   
Units
Class Hierarchy
Classes, Interfaces and Objects
Types
Enumerations
Variables
Constants
Functions and Procedures
Identifiers

Class TItem

Unit

BaseClasses

Declaration

type TItem = class(TBaseItem)

Description

Base item class

Provides hierarchical structure, saving/loading, properties interface and some service functions.

Hierarchy

TBaseItem

Fields

 NameDescription
ProtectedFChildsChilds collection
ProtectedFManagerManager reference. See TItemsManager
ProtectedFParentParent reference
ProtectedFStateSet of state flags
ProtectedFTotalChildsNumber of childs
ProtectedIndexInParentIndex in parent collection for internal use
PublicNameItem name. Used to reference items by name in a filesystem-like way: RootItemName\Parent\Name

Methods

Overview

Publicconstructor Construct(AManager: TItemsManager); virtual;
Publicconstructor Create(AManager: TItemsManager); virtual;
Publicdestructor Destroy; override;
Publicfunction AddChild(AItem: TItem): TItem;
Protectedprocedure AddItemLink(Properties: TProperties; const PropName: string; PropOptions: TPOptions; const BaseClass: string);
Publicprocedure AddProperties(const Result: TProperties); virtual;
Protectedprocedure BroadcastMessage(const Msg: TMessage);
Protectedprocedure BuildItemLinks;
Protectedprocedure ClearParent;
Publicfunction Clone: TItem; virtual;
Publicfunction FindNextChildInclDummy(var Current: TItem): Boolean;
Publicprocedure FreeChilds; virtual;
Publicfunction GetChildByName(const AName: string; SearchChilds: Boolean): TItem;
Publicfunction GetChildByPath(const AName: string): TItem;
Publicfunction GetChilds: TItems;
Publicclass function GetClass: CItem;
Publicfunction GetFullName: string;
Publicfunction GetItemSize(CountChilds: Boolean): Integer; virtual;
Publicfunction GetNextChild(CurrentChild: TItem): TItem;
Publicfunction GetNonDummyParent: TItem;
Publicprocedure GetProperties(const Result: TProperties);
Publicfunction GetRelativeItemName(const AFullName: string): string;
Publicprocedure HandleMessage(const Msg: TMessage); override;
Protectedprocedure InsertChild(AItem: TItem; Index: Integer);
Publicclass function IsAbstract: Boolean; virtual;
Publicfunction IsChildOf(AParent: TItem): Boolean;
Publicfunction Load(Stream: TStream): Boolean; virtual;
Publicprocedure MarkAsRemoved(DoNotRelease: Boolean);
Publicprocedure MoveChild(Child, Target: TItem; Mode: TItemMoveMode);
Protectedprocedure NotifyChilds(const Msg: TMessage);
Publicprocedure ObtainLinkedItemName(const PropName: string; out Result: string);
Publicprocedure OnInit; virtual;
Publicprocedure OnSceneAdd; virtual;
Publicprocedure OnSceneLoaded; virtual;
Publicprocedure OnSceneRemove; virtual;
Publicprocedure RemoveChild(AItem: TItem); virtual;
Protectedprocedure RemoveChildByIndex(Index: Integer); virtual;
Protectedfunction ResolveLink(const PropName: string; out Linked: TItem): Boolean;
Protectedprocedure ResolveLinks; virtual;
Publicfunction Save(Stream: TStream): Boolean; virtual;
Publicprocedure SendMessage(const Msg: TMessage; Recipient: TItem; Destination: TMessageFlags);
Protectedfunction SetChild(Index: Integer; AItem: TItem): TItem; virtual;
Protectedfunction SetLinkedObject(const PropName: string; Linked: TItem): Boolean;
Protectedfunction SetLinkProperty(const AName, Value: string): Boolean;
Protectedprocedure SetParent(NewParent: TItem); virtual;
Publicprocedure SetProperties(Properties: TProperties); virtual;
Publicprocedure SetProperty(const AName, AValue: string);
Protectedprocedure SetState(const Value: TItemFlags); virtual;

Description

Publicconstructor Construct(AManager: TItemsManager); virtual;

Constructor used to construct complex objects such as windows with a header area and a client area

Publicconstructor Create(AManager: TItemsManager); virtual;

Regular constructor

Publicdestructor Destroy; override;

Regular destructor

Publicfunction AddChild(AItem: TItem): TItem;

Adds and returns a child. Sends a TAddToSceneMsg message to all items in scene and to manager (see TItemsManager )

Protectedprocedure AddItemLink(Properties: TProperties; const PropName: string; PropOptions: TPOptions; const BaseClass: string);

Adds an item link property with the given name and base class to Properties. Use this method in order to add a property which points to another item

Publicprocedure AddProperties(const Result: TProperties); virtual;

This procedure is called (by editor for example) to retrieve a list of item's properties and their values. Any TItem descendant class should override this method in order to add its own properties.

Protectedprocedure BroadcastMessage(const Msg: TMessage);

Calls HandleMessage with the message for all items in the hierarchy starting from Self

Protectedprocedure BuildItemLinks;

Performs initialization of internal data structures. Do not call manually

Protectedprocedure ClearParent;

Sets Parent to nil without removing from hierarchy, etc

Publicfunction Clone: TItem; virtual;

Creates and returns a clone of the item with all properties having the same value as they be in original. Descendants should override this method in order to handle specific fields if any.

Publicfunction FindNextChildInclDummy(var Current: TItem): Boolean;

Finds child next to current assuming childs of dummy childs as own. Pass nil as current to find the first child. If next child found, the function returns True and with Current set to that child. Otherwise returns False with Current set to nil.

Publicprocedure FreeChilds; virtual;

Frees all childs

Publicfunction GetChildByName(const AName: string; SearchChilds: Boolean): TItem;

Finds a child item by its name. Name is case-sensitive. If SearchChilds is False only first-level childs can be found.

Publicfunction GetChildByPath(const AName: string): TItem;

Finds a child item by its full name relative to the item. Name is case-sensitive.

Publicfunction GetChilds: TItems;

Returns all childs of the item

Publicclass function GetClass: CItem;

Returns class reference

Publicfunction GetFullName: string;

Returns item's full name in a filesystem-like format: \\

Publicfunction GetItemSize(CountChilds: Boolean): Integer; virtual;

Returns full size in memory of an item in bytes. Descendants should override this method if they have dynamic fields which sizes are not included in TObject.InstanceSize.

Publicfunction GetNextChild(CurrentChild: TItem): TItem;

Finds a child next to CurrentChild

Publicfunction GetNonDummyParent: TItem;

Returns item's parent, skipping the dummy ones

Publicprocedure GetProperties(const Result: TProperties);

Do not use this procedure directly. Call AddProperties instead

Publicfunction GetRelativeItemName(const AFullName: string): string;

Returns full path of an item specified by its full name relative to the item

Publicprocedure HandleMessage(const Msg: TMessage); override;

Main message handler

Protectedprocedure InsertChild(AItem: TItem; Index: Integer);

Inserts a child to the given position in childs collection

Publicclass function IsAbstract: Boolean; virtual;

Items of abstract classes can not be created in editor

Publicfunction IsChildOf(AParent: TItem): Boolean;

Returns True if item is a child of any level of AParent

Publicfunction Load(Stream: TStream): Boolean; virtual;

Loads an item from a stream and returns True if success

Publicprocedure MarkAsRemoved(DoNotRelease: Boolean);

Marks item as removed from hierarchy and (if DoNotRelease is False) as released. These marks will be handled by CollectGarbage.

Publicprocedure MoveChild(Child, Target: TItem; Mode: TItemMoveMode);

Moves a child in hierarchy as specified by Mode (see TItemMoveMode)

Protectedprocedure NotifyChilds(const Msg: TMessage);

Sets mfNotification flag of the message and calls HandleMessage with the message for all first-level childs

Publicprocedure ObtainLinkedItemName(const PropName: string; out Result: string);

Returns name of an item which linked by a property with the given name

Publicprocedure OnInit; virtual;

Occurs after object creation and initialization of Root variable

Publicprocedure OnSceneAdd; virtual;

Occurs when the item added to a scene (usally after loading)

Publicprocedure OnSceneLoaded; virtual;

Occurs when a scene is completely loaded

Publicprocedure OnSceneRemove; virtual;

Occurs when the item being remove from scene

Publicprocedure RemoveChild(AItem: TItem); virtual;

Removes the given child item. Sends a TRemoveFromSceneMsg message to all items in scene and to manager (see TItemsManager )

Protectedprocedure RemoveChildByIndex(Index: Integer); virtual;

Removes a child with the specified index

Protectedfunction ResolveLink(const PropName: string; out Linked: TItem): Boolean;

Resolves (with class checking) an object link and returns True if a NEW linked item was resolved.

Protectedprocedure ResolveLinks; virtual;

Called from default OnSceneLoaded event handler. Override to resolve all link which needed to be resolved right after scene load

Publicfunction Save(Stream: TStream): Boolean; virtual;

Saves an item to a stream and returns True if success

Publicprocedure SendMessage(const Msg: TMessage; Recipient: TItem; Destination: TMessageFlags);

Sends the specified message according to the specified destination.

Protectedfunction SetChild(Index: Integer; AItem: TItem): TItem; virtual;

Sets child and returns AItem if success or nil if index is invalid or impossible to set a child

Protectedfunction SetLinkedObject(const PropName: string; Linked: TItem): Boolean;

Sets Linked as resolved linked object for a link property with the given name. Returns True if Linked passes type checking

Protectedfunction SetLinkProperty(const AName, Value: string): Boolean;

Should be called from SetProperties to handle item link property setting

Protectedprocedure SetParent(NewParent: TItem); virtual;

Sets a new parent value

Publicprocedure SetProperties(Properties: TProperties); virtual;

This procedure is called (by editor for example) to set values of item's properties. Any TItem descendant class should override this method to allow its own properties to be set.

Publicprocedure SetProperty(const AName, AValue: string);

Calls SetProperty to set a single property identified by AName

Protectedprocedure SetState(const Value: TItemFlags); virtual;

Sets a new state flags

Properties

Overview

Publicproperty Childs[Index: Integer]: TItem;
Publicproperty Parent: TItem;
Publicproperty State: TItemFlags;
Publicproperty TotalChilds: Integer;

Description

Publicproperty Childs[Index: Integer]: TItem;

Item's childs collection

Publicproperty Parent: TItem;

Item's parent. You can set this property to move the item within items hierarchy. Setting Parent to nil will remove the item from the hierarchy.

Publicproperty State: TItemFlags;

A set of state flags. See isRemoved, isReleased, isNeedInit, isPicked, isVisible, isProcessing, isDrawVolumes.

Publicproperty TotalChilds: Integer;

Specifies number of childs of an item

Last modified: 4 Jul, 2008
Copyright (C) 2006-2008, casteng.com