|
SleakEngine 1.0.0
C++23 multi-backend game engine
|
#include <Scene.hpp>
Public Member Functions | |
| Scene (const std::string &name) | |
| ~Scene () override=default | |
| void | Begin () override |
| Activates every owned object; runs once after Initialize(). | |
| void | FixedUpdate (float fixedDeltaTime) override |
| Advances all active, root-level objects on the fixed timestep. | |
| bool | Initialize () override |
| Runs once before the scene's first Begin()/Update(). | |
| bool | IsFixedUpdateEnabled () const |
| void | LateUpdate (float deltaTime) override |
| Advances all active, root-level objects after the main Update pass. | |
| void | OnActivate () override |
| Override for logic that should run when the scene becomes active. | |
| void | OnDeactivate () override |
| Override for logic that should run when the scene stops being active. | |
| void | OnLoad () override |
| Override to load scene-specific assets; called once from Load(). | |
| void | OnUnload () override |
| Override to release scene-specific assets; called from Unload(). | |
| void | SetFixedUpdateEnabled (bool enabled) |
| void | Update (float deltaTime) override |
| Advances all active, root-level objects by deltaTime, then steps lighting and physics. | |
| Public Member Functions inherited from Sleak::SceneBase | |
| SceneBase (const std::string &name) | |
| virtual | ~SceneBase () |
| void | Activate () |
| Marks the scene active and calls OnActivate(). | |
| virtual void | AddObject (GameObject *object) |
| Takes ownership of object, registering it with lighting and physics as needed. | |
| void | Deactivate () |
| Marks the scene inactive and calls OnDeactivate(). | |
| void | DestroyObject (GameObject *object) |
| Queues an object for destruction; actually freed on the next ProcessPendingDestroy(). | |
| GameObject * | FindObjectByID (uint64_t id) |
| Linear search for the object with a matching unique ID. | |
| GameObject * | FindObjectByName (const std::string &name) |
| Linear search for the first object with a matching name. | |
| List< GameObject * > | FindObjectsByTag (const std::string &tag) |
| Collects every object whose tag matches. | |
| Camera * | GetActiveCamera () const |
| LightManager * | GetLightManager () const |
| const std::string & | GetName () const |
| size_t | GetObjectCount () const |
| const List< GameObject * > & | GetObjects () const |
| Physics::PhysicsWorld * | GetPhysicsWorld () const |
| Skybox * | GetSkybox () const |
| SceneState | GetState () const |
| bool | IsActive () const |
| bool | IsLoaded () const |
| void | Load () |
| Moves Unloaded -> Loading -> Active, calling OnLoad() and Initialize(). | |
| void | Pause () |
| Freezes the scene without tearing it down; leaves it in the Paused state. | |
| virtual void | RemoveObject (GameObject *object) |
| Unregisters and deletes object immediately. | |
| void | Resume () |
| Reactivates a paused scene without re-running OnActivate(). | |
| void | SetActiveCamera (Camera *cam) |
| void | SetSkybox (Skybox *skybox) |
| Replaces the scene's skybox, deleting the previous one. | |
| void | Unload () |
| Deactivates if active, calls OnUnload(), and destroys all owned objects. | |
Additional Inherited Members | |
| Protected Member Functions inherited from Sleak::SceneBase | |
| void | DestroyAllObjects () |
| Destroys every object still owned by the scene, e.g. during Unload(). | |
| void | ProcessPendingDestroy () |
| Actually deletes objects queued by DestroyObject(). | |
| Protected Attributes inherited from Sleak::SceneBase | |
| bool | bActive |
| bool | bInitialized |
| Camera * | m_activeCamera = nullptr |
| LightManager * | m_lightManager = nullptr |
| List< GameObject * > | m_pendingDestroy |
| Physics::PhysicsWorld * | m_physicsWorld = nullptr |
| Skybox * | m_skybox = nullptr |
| std::string | name |
| List< GameObject * > | Objects |
| SceneState | state |
Concrete scene type games subclass. Adds an opt-out switch for the fixed-timestep update on top of SceneBase's lifecycle.
This is the class your levels, menus, and screens derive from. Override the hooks you need and call the base implementation from each one: OnLoad() and OnUnload() for assets, OnActivate() and OnDeactivate() for entering and leaving, Begin() to build the object graph, and Update() / FixedUpdate() / LateUpdate() for per-frame work.
The scene owns every object handed to AddObject(), including lights and cameras, and destroys all of them on unload. It also owns a LightManager and a Physics::PhysicsWorld, reachable through GetLightManager() and GetPhysicsWorld(), and registers added objects with both automatically.
Call SetFixedUpdateEnabled(false) on scenes that do not simulate anything, such as menus, to skip the fixed-timestep pass entirely.
|
inlineexplicit |
|
overridedefault |
|
overridevirtual |
Activates every owned object; runs once after Initialize().
Implements Sleak::SceneBase.
|
overridevirtual |
Advances all active, root-level objects on the fixed timestep.
Reimplemented from Sleak::SceneBase.
|
overridevirtual |
Runs once before the scene's first Begin()/Update().
Reimplemented from Sleak::SceneBase.
|
overridevirtual |
Advances all active, root-level objects after the main Update pass.
Reimplemented from Sleak::SceneBase.
|
overridevirtual |
Override for logic that should run when the scene becomes active.
Reimplemented from Sleak::SceneBase.
|
overridevirtual |
Override for logic that should run when the scene stops being active.
Reimplemented from Sleak::SceneBase.
|
overridevirtual |
Override to load scene-specific assets; called once from Load().
Reimplemented from Sleak::SceneBase.
|
overridevirtual |
Override to release scene-specific assets; called from Unload().
Reimplemented from Sleak::SceneBase.
|
inline |
|
overridevirtual |
Advances all active, root-level objects by deltaTime, then steps lighting and physics.
Implements Sleak::SceneBase.