Class TCreature

Unit

Declaration

type TCreature = class(TAlive)

Description

Base creature, using any TCreatureResource.

Hierarchy

Overview

Fields

Protected var LevelProperties: TLevelProperties;
Public class var RenderDebug: boolean;

Methods

Protected procedure SetLife(const Value: Single); override;
Protected procedure Fall(const FallHeight: Single); override;
Protected function LerpLegsMiddle(const A: Single): TVector3;
Protected procedure AttackHurt(const HurtEnemy: TAlive);
Protected procedure UpdateDebugCaption(const Lines: TCastleStringList); virtual;
Protected function Sector(const OtherTransform: TCastleTransform): TSector;
Protected function Sector: TSector;
Public constructor Create(AOwner: TComponent; const AMaxLife: Single); virtual; reintroduce;
Public destructor Destroy; override;
Public function GetExists: boolean; override;
Public function GetCollides: boolean; override;
Public procedure Update(const SecondsPassed: Single; var RemoveMe: TRemoveType); override;
Public procedure Sound3d(const SoundType: TSoundType; const SoundHeight: Single; TiedToCreature: boolean = true);
Public function Sphere(out ARadius: Single): boolean; override;
Public function Radius: Single;

Properties

Public property Resource: TCreatureResource read FResource;
Public property SoundDieEnabled: boolean read FSoundDieEnabled write FSoundDieEnabled default true;
Public property CollidesWithMoving default true;

Description

Fields

Protected var LevelProperties: TLevelProperties;

Set by CreateCreature.

Public class var RenderDebug: boolean;

Render debug bounding boxes and captions at every creature.

Methods

Protected procedure SetLife(const Value: Single); override;
 
Protected procedure Fall(const FallHeight: Single); override;
 
Protected function LerpLegsMiddle(const A: Single): TVector3;

LerpLegsMiddle interpolates between Position and Middle (intuitively, legs and eye positions).

Protected procedure AttackHurt(const HurtEnemy: TAlive);

Hurt given enemy. HurtEnemy may be Nil, in this case we do nothing.

Protected procedure UpdateDebugCaption(const Lines: TCastleStringList); virtual;
 
Protected function Sector(const OtherTransform: TCastleTransform): TSector;

Sector where the middle of this 3D object is. Used for AI. Nil if none (maybe because we're not part of any world, maybe because sectors of the world were not initialized, or maybe simply because we're outside of all sectors).

Protected function Sector: TSector;
 
Public constructor Create(AOwner: TComponent; const AMaxLife: Single); virtual; reintroduce;
 
Public destructor Destroy; override;
 
Public function GetExists: boolean; override;
 
Public function GetCollides: boolean; override;
 
Public procedure Update(const SecondsPassed: Single; var RemoveMe: TRemoveType); override;
 
Public procedure Sound3d(const SoundType: TSoundType; const SoundHeight: Single; TiedToCreature: boolean = true);

Play SoundType where the creature's position is.

Exactly, the position is between Position and Middle — SoundHeight = 0 means Position, SoundHeight = 1 means Middle, SoundHeight between means ... well, between Position and Middle. This can also be higher than 1 or lower than 0, should be treated like lerp between Position and Middle.

If TiedToCreature then the sounds position will be updated as the creature will move, and when the creature object will be destroyed, sound will stop. If not TiedToCreature, then the sound will simply be done at creature's position, but then it will continue to be played independent of this creature.

Public function Sphere(out ARadius: Single): boolean; override;

Can the approximate sphere be used for some collision-detection tasks.

Set to False in descendants if Resource.Radius is not appropriate for this creature state.

In this class, this is implemented to return not Dead. This is usually sensible, since only alive creatures need bounding sphere advantages (stairs climbing), and using sphere with dead creatures would unnecessarily force the sphere radius to be small and Middle to be high.

Public function Radius: Single;

Sphere radius for collision detection for alive creatures. Must be something <> 0 for collision detection to work.

See also
TCreatureResource.Radius
Sphere radius for collision detection for alive creatures.

Properties

Public property Resource: TCreatureResource read FResource;
 
Public property SoundDieEnabled: boolean read FSoundDieEnabled write FSoundDieEnabled default true;

You can set this to False to force the creature to die without making any sound. This is really seldom needed, usefull only to avoid a loud shriek noise when you kill many creatures at once. Primarily for use by debug menu "kill all creatures" and similar things.

Public property CollidesWithMoving default true;
 

Generated by PasDoc 0.15.0.