Castle Game Engine: CastleLevels: Class TLevelLogic

# Class TLevelLogic
Description | Hierarchy | Fields | Methods | Properties
## Unit CastleLevels ## Declaration `type TLevelLogic = class(T3D)` ## 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 TComponent T3D TLevelLogic ## Overview ### Methods
| `function LoadLevelAnimation(const URL: string; const CreateFirstOctreeCollisions, CreateLastOctreeCollisions: boolean; const AnimationClass: TCastlePrecalculatedAnimationClass): TCastlePrecalculatedAnimation;`
| `function LoadLevelAnimation(const URL: string; const CreateFirstOctreeCollisions, CreateLastOctreeCollisions: boolean): TCastlePrecalculatedAnimation;`
| `function LoadLevelScene(const URL: string; const CreateOctreeCollisions: boolean; const SceneClass: TCastleSceneClass): TCastleScene;`
| `function LoadLevelScene(const URL: string; const CreateOctreeCollisions: boolean): TCastleScene;`
| `function Placeholder(const Shape: TShape; const PlaceholderName: string): boolean; virtual;`
| `procedure PlaceholdersEnd; virtual;`
| `constructor Create(AOwner: TComponent; AWorld: T3DWorld; MainScene: TCastleScene; DOMElement: TDOMElement); reintroduce; virtual;`
| `function BoundingBox: TBox3D; override;`
| `function World: T3DWorld; override;`
| `procedure PrepareNewPlayer(NewPlayer: TPlayer); virtual;`
| `procedure Update(const SecondsPassed: Single; var RemoveMe: TRemoveType); override;`
### Properties
| `property Time: TFloatTime read FTime;`
## Description ### Methods
| `function LoadLevelAnimation(const URL: string; const CreateFirstOctreeCollisions, CreateLastOctreeCollisions: boolean; const AnimationClass: TCastlePrecalculatedAnimationClass): TCastlePrecalculatedAnimation;`
Load 3D precalculated animation from (*.kanim) file, doing common tasks. optionally creates triangle octree for the FirstScene and/or LastScene call PrepareResources, with prRender, prBoundingBox, prShadowVolume (if shadow volumes possible at all in this OpenGL context) Free texture data, since they will not be needed anymore TimePlaying is by default `False`, so the animation is not playing.
| `function LoadLevelAnimation(const URL: string; const CreateFirstOctreeCollisions, CreateLastOctreeCollisions: boolean): TCastlePrecalculatedAnimation;`
| `function LoadLevelScene(const URL: string; const CreateOctreeCollisions: boolean; const SceneClass: TCastleSceneClass): TCastleScene;`
Load 3D scene from file, doing common tasks. optionally create triangle octree call PrepareResources, with prRender, prBoundingBox, prShadowVolume (if shadow volumes possible at all in this OpenGL context), Free texture data, since they will not be needed anymore
| `function LoadLevelScene(const URL: string; const CreateOctreeCollisions: boolean): TCastleScene;`
| `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).
| `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.
| `constructor Create(AOwner: TComponent; AWorld: T3DWorld; 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');
| `function BoundingBox: TBox3D; override;`
| `function World: T3DWorld; override;`
| `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.
| `procedure Update(const SecondsPassed: Single; var RemoveMe: TRemoveType); override;`
### Properties
| `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.13.0 on 2015-06-15 04:43:10