|
SleakEngine 1.0.0
C++23 multi-backend game engine
|
#include <SceneBase.hpp>
Public Member Functions | |
| 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. | |
| virtual void | Begin ()=0 |
| Activates every owned object; runs once after Initialize(). | |
| 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. | |
| virtual void | FixedUpdate (float fixedDeltaTime) |
| Advances all active, root-level objects on the fixed timestep. | |
| 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 |
| virtual bool | Initialize () |
| Runs once before the scene's first Begin()/Update(). | |
| bool | IsActive () const |
| bool | IsLoaded () const |
| virtual void | LateUpdate (float deltaTime) |
| Advances all active, root-level objects after the main Update pass. | |
| void | Load () |
| Moves Unloaded -> Loading -> Active, calling OnLoad() and Initialize(). | |
| virtual void | OnActivate () |
| Override for logic that should run when the scene becomes active. | |
| virtual void | OnDeactivate () |
| Override for logic that should run when the scene stops being active. | |
| virtual void | OnLoad () |
| Override to load scene-specific assets; called once from Load(). | |
| virtual void | OnUnload () |
| Override to release scene-specific assets; called from Unload(). | |
| 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. | |
| virtual void | Update (float deltaTime)=0 |
| Advances all active, root-level objects by deltaTime, then steps lighting and physics. | |
Protected Member Functions | |
| void | DestroyAllObjects () |
| Destroys every object still owned by the scene, e.g. during Unload(). | |
| void | ProcessPendingDestroy () |
| Actually deletes objects queued by DestroyObject(). | |
Protected Attributes | |
| 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 |
Non-templated scene interface: object ownership, state machine, and per-frame update hooks. Game scenes derive from Scene, not this directly.
SceneBase defines what every scene can do regardless of subclass: hold objects, move through the SceneState machine, and answer queries. GameBase stores scenes by SceneBase*, so this is the type you see in the scene registry API.
Ownership is strict. AddObject() transfers ownership to the scene. RemoveObject() unregisters and deletes immediately, which is unsafe from inside that object's own update. DestroyObject() queues the object (and its children) for deletion at the end of the frame, which is the safe choice while iterating.
Objects added to the scene are registered with the LightManager if they report IsLight(), and their colliders are registered with the PhysicsWorld, hierarchy included.
Definition at line 70 of file SceneBase.hpp.
|
inlineexplicit |
Definition at line 72 of file SceneBase.hpp.
|
virtual |
Definition at line 40 of file SceneBase.cpp.
| void Sleak::SceneBase::Activate | ( | ) |
Marks the scene active and calls OnActivate().
Definition at line 74 of file SceneBase.cpp.
|
virtual |
Takes ownership of object, registering it with lighting and physics as needed.
Definition at line 234 of file SceneBase.cpp.
|
pure virtual |
Activates every owned object; runs once after Initialize().
Implemented in Sleak::Scene.
Definition at line 137 of file SceneBase.cpp.
| void Sleak::SceneBase::Deactivate | ( | ) |
Marks the scene inactive and calls OnDeactivate().
Definition at line 87 of file SceneBase.cpp.
|
protected |
Destroys every object still owned by the scene, e.g. during Unload().
Definition at line 340 of file SceneBase.cpp.
| void Sleak::SceneBase::DestroyObject | ( | GameObject * | object | ) |
Queues an object for destruction; actually freed on the next ProcessPendingDestroy().
Definition at line 271 of file SceneBase.cpp.
| GameObject * Sleak::SceneBase::FindObjectByID | ( | uint64_t | id | ) |
Linear search for the object with a matching unique ID.
Definition at line 295 of file SceneBase.cpp.
| GameObject * Sleak::SceneBase::FindObjectByName | ( | const std::string & | name | ) |
Linear search for the first object with a matching name.
Definition at line 286 of file SceneBase.cpp.
| List< GameObject * > Sleak::SceneBase::FindObjectsByTag | ( | const std::string & | tag | ) |
Collects every object whose tag matches.
Definition at line 304 of file SceneBase.cpp.
|
virtual |
Advances all active, root-level objects on the fixed timestep.
Reimplemented in Sleak::Scene.
Definition at line 214 of file SceneBase.cpp.
|
inline |
Definition at line 142 of file SceneBase.hpp.
|
inline |
Definition at line 145 of file SceneBase.hpp.
|
inline |
Definition at line 105 of file SceneBase.hpp.
|
inline |
Definition at line 140 of file SceneBase.hpp.
|
inline |
Definition at line 131 of file SceneBase.hpp.
|
inline |
Definition at line 149 of file SceneBase.hpp.
|
inline |
Definition at line 155 of file SceneBase.hpp.
|
inline |
Definition at line 106 of file SceneBase.hpp.
|
virtual |
Runs once before the scene's first Begin()/Update().
Reimplemented in Sleak::Scene.
Definition at line 106 of file SceneBase.cpp.
|
inline |
Definition at line 107 of file SceneBase.hpp.
|
inline |
Definition at line 108 of file SceneBase.hpp.
|
virtual |
Advances all active, root-level objects after the main Update pass.
Reimplemented in Sleak::Scene.
Definition at line 224 of file SceneBase.cpp.
| void Sleak::SceneBase::Load | ( | ) |
Moves Unloaded -> Loading -> Active, calling OnLoad() and Initialize().
Definition at line 50 of file SceneBase.cpp.
|
inlinevirtual |
Override for logic that should run when the scene becomes active.
Reimplemented in Sleak::Scene.
Definition at line 86 of file SceneBase.hpp.
|
inlinevirtual |
Override for logic that should run when the scene stops being active.
Reimplemented in Sleak::Scene.
Definition at line 88 of file SceneBase.hpp.
|
inlinevirtual |
Override to load scene-specific assets; called once from Load().
Reimplemented in Sleak::Scene.
Definition at line 80 of file SceneBase.hpp.
|
inlinevirtual |
Override to release scene-specific assets; called from Unload().
Reimplemented in Sleak::Scene.
Definition at line 82 of file SceneBase.hpp.
| void Sleak::SceneBase::Pause | ( | ) |
Freezes the scene without tearing it down; leaves it in the Paused state.
Definition at line 94 of file SceneBase.cpp.
|
protected |
Actually deletes objects queued by DestroyObject().
Definition at line 314 of file SceneBase.cpp.
|
virtual |
Unregisters and deletes object immediately.
Definition at line 255 of file SceneBase.cpp.
| void Sleak::SceneBase::Resume | ( | ) |
Reactivates a paused scene without re-running OnActivate().
Definition at line 100 of file SceneBase.cpp.
|
inline |
Definition at line 143 of file SceneBase.hpp.
| void Sleak::SceneBase::SetSkybox | ( | Skybox * | skybox | ) |
Replaces the scene's skybox, deleting the previous one.
Definition at line 350 of file SceneBase.cpp.
| void Sleak::SceneBase::Unload | ( | ) |
Deactivates if active, calls OnUnload(), and destroys all owned objects.
Definition at line 57 of file SceneBase.cpp.
|
pure virtual |
Advances all active, root-level objects by deltaTime, then steps lighting and physics.
Implemented in Sleak::Scene.
Definition at line 143 of file SceneBase.cpp.
|
protected |
Definition at line 161 of file SceneBase.hpp.
|
protected |
Definition at line 160 of file SceneBase.hpp.
|
protected |
Definition at line 166 of file SceneBase.hpp.
|
protected |
Definition at line 168 of file SceneBase.hpp.
|
protected |
Definition at line 164 of file SceneBase.hpp.
|
protected |
Definition at line 169 of file SceneBase.hpp.
|
protected |
Definition at line 170 of file SceneBase.hpp.
|
protected |
Definition at line 158 of file SceneBase.hpp.
|
protected |
Definition at line 163 of file SceneBase.hpp.
|
protected |
Definition at line 159 of file SceneBase.hpp.