|
SleakEngine 0.1.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, calls OnActivate(), then Begin() once. | |
| 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 per Load(). | |
| 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) |
| Object with a matching unique ID, children included. | |
| GameObject * | FindObjectByName (const std::string &name) |
| First object with a matching name, children included. | |
| List< GameObject * > | FindObjectsByTag (const std::string &tag) |
| Collects every object whose tag matches, children included. | |
| 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) |
| 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 | bHasBegun = false |
| 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.
Children of an added object that were never added themselves are owned by their parent and belong to the scene through it. Lights and colliders anywhere in that hierarchy are registered with the LightManager and PhysicsWorld, and the queries below search it too.
Definition at line 72 of file SceneBase.hpp.
|
inlineexplicit |
Definition at line 74 of file SceneBase.hpp.
|
virtual |
Definition at line 70 of file SceneBase.cpp.
| void Sleak::SceneBase::Activate | ( | ) |
Marks the scene active, calls OnActivate(), then Begin() once.
Definition at line 113 of file SceneBase.cpp.
|
virtual |
Takes ownership of object, registering it with lighting and physics as needed.
Definition at line 280 of file SceneBase.cpp.
|
pure virtual |
Activates every owned object; runs once per Load().
Implemented in Sleak::Scene.
Definition at line 181 of file SceneBase.cpp.
| void Sleak::SceneBase::Deactivate | ( | ) |
Marks the scene inactive and calls OnDeactivate().
Definition at line 129 of file SceneBase.cpp.
|
protected |
Destroys every object still owned by the scene, e.g. during Unload().
Definition at line 379 of file SceneBase.cpp.
| void Sleak::SceneBase::DestroyObject | ( | GameObject * | object | ) |
Queues an object for destruction; actually freed on the next ProcessPendingDestroy().
Definition at line 316 of file SceneBase.cpp.
| GameObject * Sleak::SceneBase::FindObjectByID | ( | uint64_t | id | ) |
Object with a matching unique ID, children included.
Definition at line 339 of file SceneBase.cpp.
| GameObject * Sleak::SceneBase::FindObjectByName | ( | const std::string & | name | ) |
First object with a matching name, children included.
Definition at line 331 of file SceneBase.cpp.
| List< GameObject * > Sleak::SceneBase::FindObjectsByTag | ( | const std::string & | tag | ) |
Collects every object whose tag matches, children included.
Definition at line 347 of file SceneBase.cpp.
|
virtual |
Advances all active, root-level objects on the fixed timestep.
Reimplemented in Sleak::Scene.
Definition at line 260 of file SceneBase.cpp.
|
inline |
Definition at line 145 of file SceneBase.hpp.
|
inline |
Definition at line 148 of file SceneBase.hpp.
|
inline |
Definition at line 107 of file SceneBase.hpp.
|
inline |
Definition at line 143 of file SceneBase.hpp.
|
inline |
Definition at line 134 of file SceneBase.hpp.
|
inline |
Definition at line 152 of file SceneBase.hpp.
|
inline |
Definition at line 158 of file SceneBase.hpp.
|
inline |
Definition at line 108 of file SceneBase.hpp.
|
virtual |
Runs once before the scene's first Begin()/Update().
Reimplemented in Sleak::Scene.
Definition at line 148 of file SceneBase.cpp.
|
inline |
Definition at line 109 of file SceneBase.hpp.
|
inline |
Definition at line 110 of file SceneBase.hpp.
|
virtual |
Advances all active, root-level objects after the main Update pass.
Reimplemented in Sleak::Scene.
Definition at line 270 of file SceneBase.cpp.
| void Sleak::SceneBase::Load | ( | ) |
Moves Unloaded -> Loading -> Active, calling OnLoad() and Initialize().
Definition at line 87 of file SceneBase.cpp.
|
inlinevirtual |
Override for logic that should run when the scene becomes active.
Reimplemented in Sleak::Scene.
Definition at line 88 of file SceneBase.hpp.
|
inlinevirtual |
Override for logic that should run when the scene stops being active.
Reimplemented in Sleak::Scene.
Definition at line 90 of file SceneBase.hpp.
|
inlinevirtual |
Override to load scene-specific assets; called once from Load().
Reimplemented in Sleak::Scene.
Definition at line 82 of file SceneBase.hpp.
|
inlinevirtual |
Override to release scene-specific assets; called from Unload().
Reimplemented in Sleak::Scene.
Definition at line 84 of file SceneBase.hpp.
| void Sleak::SceneBase::Pause | ( | ) |
Freezes the scene without tearing it down; leaves it in the Paused state.
Definition at line 136 of file SceneBase.cpp.
|
protected |
Actually deletes objects queued by DestroyObject().
Definition at line 358 of file SceneBase.cpp.
|
virtual |
Unregisters and deletes object and its whole hierarchy immediately. Cancels a queued DestroyObject() on anything it deletes.
Definition at line 294 of file SceneBase.cpp.
| void Sleak::SceneBase::Resume | ( | ) |
Reactivates a paused scene without re-running OnActivate().
Definition at line 142 of file SceneBase.cpp.
|
inline |
Definition at line 146 of file SceneBase.hpp.
| void Sleak::SceneBase::SetSkybox | ( | Skybox * | skybox | ) |
Replaces the scene's skybox, deleting the previous one.
Definition at line 395 of file SceneBase.cpp.
| void Sleak::SceneBase::Unload | ( | ) |
Deactivates if active, calls OnUnload(), and destroys all owned objects.
Definition at line 94 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 187 of file SceneBase.cpp.
|
protected |
Definition at line 164 of file SceneBase.hpp.
|
protected |
Definition at line 165 of file SceneBase.hpp.
|
protected |
Definition at line 163 of file SceneBase.hpp.
|
protected |
Definition at line 170 of file SceneBase.hpp.
|
protected |
Definition at line 172 of file SceneBase.hpp.
|
protected |
Definition at line 168 of file SceneBase.hpp.
|
protected |
Definition at line 173 of file SceneBase.hpp.
|
protected |
Definition at line 174 of file SceneBase.hpp.
|
protected |
Definition at line 161 of file SceneBase.hpp.
|
protected |
Definition at line 167 of file SceneBase.hpp.
|
protected |
Definition at line 162 of file SceneBase.hpp.