Class TLevelLogic

Unit

Declaration

type TLevelLogic = class(TCastleTransform)

Description

Level logic. We use T3D descendant, since this is the comfortable way to add any behavior to the 3D world (it doesn't matter that "level logic" is not a usual 3D object — it doesn't have to collide or be visible).

Hierarchy

Overview

Methods

Protected function LoadLevelScene(const URL: string; const PrepareForCollisions: boolean; const SceneClass: TCastleSceneClass): TCastleScene;
Protected function LoadLevelScene(const URL: string; const PrepareForCollisions: boolean): TCastleScene;
Protected function Placeholder(const Shape: TShape; const PlaceholderName: string): boolean; virtual;
Protected procedure PlaceholdersEnd; virtual;
Public constructor Create(AOwner: TComponent; AWorld: TSceneManagerWorld; MainScene: TCastleScene; DOMElement: TDOMElement); reintroduce; virtual;
Public function LocalBoundingBox: TBox3D; override;
Public procedure PrepareNewPlayer(NewPlayer: TPlayer); virtual;
Public procedure Update(const SecondsPassed: Single; var RemoveMe: TRemoveType); override;

Properties

Public property Time: TFloatTime read FTime;

Description

Methods

Protected function LoadLevelScene(const URL: string; const PrepareForCollisions: boolean; const SceneClass: TCastleSceneClass): TCastleScene;

Load 3D scene from file, doing common tasks.

Protected function LoadLevelScene(const URL: string; const PrepareForCollisions: boolean): TCastleScene;
 
Protected function Placeholder(const Shape: TShape; const PlaceholderName: string): boolean; virtual;

Handle a placeholder named in external modeler. Return True if this is indeed a recognized placeholder name, and it was handled and relevant shape should be removed from level geometry (to not be rendered).

Protected procedure PlaceholdersEnd; virtual;

Called after all placeholders have been processed, that is after TGameSceneManager.LoadLevel placed initial creatures, items and other stuff on the level. Override it to do anything you want.

Public constructor Create(AOwner: TComponent; AWorld: TSceneManagerWorld; MainScene: TCastleScene; DOMElement: TDOMElement); reintroduce; virtual;

Create new level instance. Called before resources (creatures and items) are initialized (override PlaceholdersEnd if you need to do something after creatures and items are added). You can modify MainScene contents here.

Parameters
AWorld

3D world items. We provide AWorld instance at construction, and the created TLevelLogic instance will be added to this AWorld, and you cannot change it later. This is necessary, as TLevelLogic descendants at construction may actually modify your world, and depend on it later.

DOMElement

An XML tree of level.xml file. You can read it however you want, to handle additional attributes in level.xml. You can use standard FPC DOM unit and classes, and add a handful of simple comfortable routines in CastleXMLUtils unit, for example you can use this to read a string attribute:

MyAttribute := DOMElement.AttributeStringDef('my_attribute', 'default value');
MyRequiredAttribute := DOMElement.AttributeString('my_required_attribute');

Public function LocalBoundingBox: TBox3D; override;
 
Public procedure PrepareNewPlayer(NewPlayer: TPlayer); virtual;

Called when new player starts new game on this level. This may be used to equip the player with some basic weapon / items.

This is never called or used by the engine itself. This does nothing in the default TLevelLogic class implementation.

Your particular game, where you can best decide when the player "starts a new game" and when the player merely "continues the previous game", may call it. And you may override this in your TLevelLogic descendants to equip the player.

Public procedure Update(const SecondsPassed: Single; var RemoveMe: TRemoveType); override;
 

Properties

Public property Time: TFloatTime read FTime;

Time of the level, in seconds. Time 0 when level is created. This is updated in our Update.


Generated by PasDoc 0.15.0.