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).
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.
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 boolean attribute "my_attribute":
ifnot DOMGetBooleanAttribute(DOMElement, 'my_attribute', MyAttribute) then
MyAttribute := false; // default value, if not specified in level.xml
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;