Clutter Engine 0.0.1
Loading...
Searching...
No Matches
clt::Level Class Referenceabstract

Represents a level in the game engine. More...

#include <Level.h>

Inheritance diagram for clt::Level:
DefaultMap LevelMap LevelMap MainMenuMap MainMenuMap clt::TemplateLevel

Public Member Functions

 Level (std::string pTitle="Scene")
 Constructs a new level with the given title.
 
 ~Level ()
 Destroys the level and cleans up resources.
 
virtual void Load ()=0
 Loads the level. Must be implemented by derived classes.
 
void SetManager (RendererGL *pRenderer, Physics *pPhysics, LevelManager *pManager)
 Sets the renderer, physics, and manager for the level.
 
void OpenLevel (const std::string &pLevelName)
 Opens a new level by name.
 
bool LineTrace (Vector3 start, Vector3 direction, float maxDistance, raycastHit &hit, bool debugPersistant=false, Actor *self=nullptr)
 Performs a line trace (raycast) in the level.
 
void InternalUpdate ()
 Internal update function called by the engine.
 
virtual void Close ()=0
 Closes the level. Must be implemented by derived classes.
 
void Unload ()
 Unloads the level and cleans up resources.
 
template<typename T , typename... Args>
T * AddActor (Args &&... args)
 Adds an actor of type T to the level.
 
template<typename T >
void DestroyActor (Actor *pActor)
 Removes an actor from the level.
 
template<typename T >
std::vector< T * > GetAllActorOfType ()
 Gets all actors of a specific type.
 
template<typename T >
T * GetActorOfType ()
 Gets the first actor of a specific type.
 
RendererGLGetRenderer () const
 Gets the renderer for the level.
 
PhysicsGetPhysics () const
 Gets the physics system for the level.
 

Public Attributes

friend LevelManager
 

Static Public Attributes

static LevelActiveScene
 Pointer to the currently active scene.
 

Protected Member Functions

virtual void Update ()=0
 Updates the level. Must be implemented by derived classes.
 

Protected Attributes

std::string mTitle
 The title of the scene.
 
RendererGLmRenderer
 The renderer used for drawing the scene.
 
PhysicsmPhysics
 The physics system used in the level.
 
LevelManagermManager
 The manager responsible for this level.
 
std::unordered_map< size_t, std::vector< Actor * > > mActors
 Map of actors categorized by their type.
 
std::vector< Actor * > mPendingActors
 List of actors pending to be added to the level.
 
std::vector< Actor * > mDeadActors
 List of actors pending to be removed from the level.
 

Detailed Description

Represents a level in the game engine.

Constructor & Destructor Documentation

◆ Level()

Level::Level ( std::string pTitle = "Scene")

Constructs a new level with the given title.

Parameters
pTitleThe title of the scene.

Member Function Documentation

◆ AddActor()

template<typename T , typename... Args>
T * clt::Level::AddActor ( Args &&... args)
inline

Adds an actor of type T to the level.

Template Parameters
TThe type of actor to add.
ArgsConstructor arguments for the actor.
Parameters
argsArguments to forward to the actor's constructor.
Returns
Pointer to the newly created actor.

◆ Close()

virtual void clt::Level::Close ( )
pure virtual

Closes the level. Must be implemented by derived classes.

Implemented in clt::TemplateLevel, DefaultMap, LevelMap, LevelMap, MainMenuMap, and MainMenuMap.

◆ DestroyActor()

template<typename T >
void clt::Level::DestroyActor ( Actor * pActor)
inline

Removes an actor from the level.

Template Parameters
TThe type of actor to remove.
Parameters
pActorPointer to the actor to be removed.

◆ GetActorOfType()

template<typename T >
T * clt::Level::GetActorOfType ( )
inline

Gets the first actor of a specific type.

Template Parameters
TThe type of actor to retrieve.
Returns
Pointer to the first actor of type T, or nullptr if none found.

◆ GetAllActorOfType()

template<typename T >
std::vector< T * > clt::Level::GetAllActorOfType ( )
inline

Gets all actors of a specific type.

Template Parameters
TThe type of actors to retrieve.
Returns
A vector of pointers to actors of type T.

◆ GetPhysics()

Physics & clt::Level::GetPhysics ( ) const
inline

Gets the physics system for the level.

Returns
Reference to the physics system.

◆ GetRenderer()

RendererGL & clt::Level::GetRenderer ( ) const
inline

Gets the renderer for the level.

Returns
Reference to the renderer.

◆ LineTrace()

bool Level::LineTrace ( Vector3 start,
Vector3 direction,
float maxDistance,
raycastHit & hit,
bool debugPersistant = false,
Actor * self = nullptr )

Performs a line trace (raycast) in the level.

Parameters
startThe starting point of the trace.
directionThe direction of the trace.
maxDistanceThe maximum distance for the trace.
hitThe result of the raycast.
debugPersistantWhether to persist debug visualization.
selfThe actor to ignore during the trace.
Returns
True if something was hit, false otherwise.

◆ Load()

virtual void clt::Level::Load ( )
pure virtual

Loads the level. Must be implemented by derived classes.

Implemented in clt::TemplateLevel, DefaultMap, LevelMap, LevelMap, MainMenuMap, and MainMenuMap.

◆ OpenLevel()

void Level::OpenLevel ( const std::string & pLevelName)

Opens a new level by name.

Parameters
pLevelNameThe name of the level to open.

◆ SetManager()

void clt::Level::SetManager ( RendererGL * pRenderer,
Physics * pPhysics,
LevelManager * pManager )
inline

Sets the renderer, physics, and manager for the level.

Parameters
pRendererPointer to the renderer.
pPhysicsPointer to the physics system.
pManagerPointer to the level manager.

◆ Update()

virtual void clt::Level::Update ( )
protectedpure virtual

Updates the level. Must be implemented by derived classes.

Implemented in clt::TemplateLevel, DefaultMap, LevelMap, LevelMap, MainMenuMap, and MainMenuMap.


The documentation for this class was generated from the following files: