Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
rtp::client::scenes::PlayingScene Class Reference

Scene for the main gameplay. More...

#include <PlayingScene.hpp>

Inheritance diagram for rtp::client::scenes::PlayingScene:
Collaboration diagram for rtp::client::scenes::PlayingScene:

Public Types

using ChangeStateFn = std::function< void(GameState)>
 Type alias for a function that changes the game state.
 

Public Member Functions

 PlayingScene (ecs::Registry &worldRegistry, ecs::Registry &uiRegistry, Settings &settings, TranslationManager &translationManager, NetworkSyncSystem &network, graphics::UiFactory &uiFactory, EntityBuilder &worldBuilder, std::function< void(GameState)> changeState)
 Constructor for PlayingScene.
 
void onEnter (void) override
 Called when the scene is entered.
 
void onExit (void) override
 Called when the scene is exited.
 
void handleEvent (const sf::Event &event) override
 Handle an incoming event.
 
void update (float dt) override
 Update the scene state.
 
- Public Member Functions inherited from rtp::client::interfaces::IScene
virtual ~IScene (void)=default
 

Private Member Functions

void spawnParallax (void)
 Spawn parallax background entities.
 
void sendChatMessage (void)
 
void openChat (void)
 
void closeChat (void)
 
void updateChatHistoryText (void)
 

Private Attributes

ecs::Registry_uiRegistry
 Reference to the ECS registry.
 
Settings_settings
 Reference to the application settings.
 
TranslationManager_translationManager
 Reference to the translation manager.
 
NetworkSyncSystem_network
 Reference to the client network.
 
graphics::UiFactory_uiFactory
 UI Factory for creating UI components.
 
ChangeStateFn _changeState
 Function to change the game state.
 
ecs::Registry_worldRegistry
 Reference to the world ECS registry.
 
EntityBuilder_worldBuilder
 Reference to the world entity builder.
 
uint32_t _uiScore = 0
 Player score in the UI.
 
uint32_t _uiFps = 0
 Current FPS in the UI.
 
uint32_t _uiPing = 0
 Current ping in the UI.
 
float _fpsTimer = 0.0f
 FPS timer accumulator.
 
uint32_t _fpsFrames = 0
 FPS frame count.
 
ecs::Entity _hudPing {}
 Entity for displaying ping in the HUD.
 
ecs::Entity _hudFps {}
 Entity for displaying FPS in the HUD.
 
ecs::Entity _hudScore {}
 Entity for displaying score in the HUD.
 
ecs::Entity _hudEntities {}
 Parent entity for HUD elements.
 
ecs::Entity _hudAmmo {}
 Entity for displaying ammo.
 
ecs::Entity _hudHealth {}
 Entity for displaying health.
 
ecs::Entity _hudChargeBar {}
 Entity for charged shot HUD bar.
 
bool _hudInit {false}
 Flag indicating if HUD is initialized.
 
bool _chatOpen {false}
 Whether expanded chat is open.
 
ecs::Entity _chatCompactPanel {}
 Compact chat background panel.
 
ecs::Entity _chatCompactText {}
 Text entity for last chat message.
 
ecs::Entity _chatPanel {}
 Expanded chat panel.
 
ecs::Entity _chatHistoryText {}
 Text entity for chat history.
 
ecs::Entity _chatInput {}
 Text input entity for chat.
 
float _chargeTime {0.0f}
 Local charge timer for HUD.
 

Detailed Description

Scene for the main gameplay.

This scene handles the core gameplay mechanics, rendering, and user interactions during the game.

Definition at line 31 of file PlayingScene.hpp.

Member Typedef Documentation

◆ ChangeStateFn

Type alias for a function that changes the game state.

Definition at line 53 of file PlayingScene.hpp.

Constructor & Destructor Documentation

◆ PlayingScene()

rtp::client::scenes::PlayingScene::PlayingScene ( ecs::Registry worldRegistry,
ecs::Registry uiRegistry,
Settings settings,
TranslationManager translationManager,
NetworkSyncSystem network,
graphics::UiFactory uiFactory,
EntityBuilder worldBuilder,
std::function< void(GameState)>  changeState 
)

Constructor for PlayingScene.

Parameters
registryReference to the ECS registry
settingsReference to the application settings
networkReference to the client network
windowReference to the SFML render window

Definition at line 26 of file PlayingScene.cpp.

Member Function Documentation

◆ closeChat()

void rtp::client::scenes::PlayingScene::closeChat ( void  )
private

◆ handleEvent()

void rtp::client::scenes::PlayingScene::handleEvent ( const sf::Event &  event)
overridevirtual

◆ onEnter()

◆ onExit()

void rtp::client::scenes::PlayingScene::onExit ( void  )
overridevirtual

Called when the scene is exited.

Implements rtp::client::interfaces::IScene.

Definition at line 145 of file PlayingScene.cpp.

References _chargeTime, _hudInit, and closeChat().

◆ openChat()

◆ sendChatMessage()

void rtp::client::scenes::PlayingScene::sendChatMessage ( void  )
private

◆ spawnParallax()

◆ update()

◆ updateChatHistoryText()

void rtp::client::scenes::PlayingScene::updateChatHistoryText ( void  )
private

Member Data Documentation

◆ _changeState

ChangeStateFn rtp::client::scenes::PlayingScene::_changeState
private

Function to change the game state.

Definition at line 93 of file PlayingScene.hpp.

Referenced by handleEvent(), and update().

◆ _chargeTime

float rtp::client::scenes::PlayingScene::_chargeTime {0.0f}
private

Local charge timer for HUD.

Definition at line 120 of file PlayingScene.hpp.

Referenced by onEnter(), onExit(), and update().

◆ _chatCompactPanel

ecs::Entity rtp::client::scenes::PlayingScene::_chatCompactPanel {}
private

Compact chat background panel.

Definition at line 113 of file PlayingScene.hpp.

Referenced by onEnter().

◆ _chatCompactText

ecs::Entity rtp::client::scenes::PlayingScene::_chatCompactText {}
private

Text entity for last chat message.

Definition at line 114 of file PlayingScene.hpp.

Referenced by onEnter(), and update().

◆ _chatHistoryText

ecs::Entity rtp::client::scenes::PlayingScene::_chatHistoryText {}
private

Text entity for chat history.

Definition at line 117 of file PlayingScene.hpp.

Referenced by closeChat(), openChat(), and updateChatHistoryText().

◆ _chatInput

ecs::Entity rtp::client::scenes::PlayingScene::_chatInput {}
private

Text input entity for chat.

Definition at line 118 of file PlayingScene.hpp.

Referenced by closeChat(), handleEvent(), openChat(), and sendChatMessage().

◆ _chatOpen

bool rtp::client::scenes::PlayingScene::_chatOpen {false}
private

Whether expanded chat is open.

Definition at line 112 of file PlayingScene.hpp.

Referenced by closeChat(), handleEvent(), openChat(), and update().

◆ _chatPanel

ecs::Entity rtp::client::scenes::PlayingScene::_chatPanel {}
private

Expanded chat panel.

Definition at line 116 of file PlayingScene.hpp.

Referenced by closeChat(), and openChat().

◆ _fpsFrames

uint32_t rtp::client::scenes::PlayingScene::_fpsFrames = 0
private

FPS frame count.

Definition at line 101 of file PlayingScene.hpp.

Referenced by update().

◆ _fpsTimer

float rtp::client::scenes::PlayingScene::_fpsTimer = 0.0f
private

FPS timer accumulator.

Definition at line 100 of file PlayingScene.hpp.

Referenced by update().

◆ _hudAmmo

ecs::Entity rtp::client::scenes::PlayingScene::_hudAmmo {}
private

Entity for displaying ammo.

Definition at line 107 of file PlayingScene.hpp.

Referenced by onEnter(), and update().

◆ _hudChargeBar

ecs::Entity rtp::client::scenes::PlayingScene::_hudChargeBar {}
private

Entity for charged shot HUD bar.

Definition at line 109 of file PlayingScene.hpp.

Referenced by onEnter(), and update().

◆ _hudEntities

ecs::Entity rtp::client::scenes::PlayingScene::_hudEntities {}
private

Parent entity for HUD elements.

Definition at line 106 of file PlayingScene.hpp.

Referenced by onEnter(), and update().

◆ _hudFps

ecs::Entity rtp::client::scenes::PlayingScene::_hudFps {}
private

Entity for displaying FPS in the HUD.

Definition at line 104 of file PlayingScene.hpp.

Referenced by onEnter(), and update().

◆ _hudHealth

ecs::Entity rtp::client::scenes::PlayingScene::_hudHealth {}
private

Entity for displaying health.

Definition at line 108 of file PlayingScene.hpp.

Referenced by onEnter(), and update().

◆ _hudInit

bool rtp::client::scenes::PlayingScene::_hudInit {false}
private

Flag indicating if HUD is initialized.

Definition at line 110 of file PlayingScene.hpp.

Referenced by onEnter(), onExit(), and update().

◆ _hudPing

ecs::Entity rtp::client::scenes::PlayingScene::_hudPing {}
private

Entity for displaying ping in the HUD.

Definition at line 103 of file PlayingScene.hpp.

Referenced by onEnter(), and update().

◆ _hudScore

ecs::Entity rtp::client::scenes::PlayingScene::_hudScore {}
private

Entity for displaying score in the HUD.

Definition at line 105 of file PlayingScene.hpp.

Referenced by onEnter(), and update().

◆ _network

NetworkSyncSystem& rtp::client::scenes::PlayingScene::_network
private

Reference to the client network.

Definition at line 91 of file PlayingScene.hpp.

Referenced by sendChatMessage(), spawnParallax(), update(), and updateChatHistoryText().

◆ _settings

Settings& rtp::client::scenes::PlayingScene::_settings
private

Reference to the application settings.

Definition at line 89 of file PlayingScene.hpp.

Referenced by handleEvent(), and update().

◆ _translationManager

TranslationManager& rtp::client::scenes::PlayingScene::_translationManager
private

Reference to the translation manager.

Definition at line 90 of file PlayingScene.hpp.

◆ _uiFactory

graphics::UiFactory& rtp::client::scenes::PlayingScene::_uiFactory
private

UI Factory for creating UI components.

Definition at line 92 of file PlayingScene.hpp.

Referenced by onEnter(), and openChat().

◆ _uiFps

uint32_t rtp::client::scenes::PlayingScene::_uiFps = 0
private

Current FPS in the UI.

Definition at line 98 of file PlayingScene.hpp.

Referenced by update().

◆ _uiPing

uint32_t rtp::client::scenes::PlayingScene::_uiPing = 0
private

Current ping in the UI.

Definition at line 99 of file PlayingScene.hpp.

Referenced by update().

◆ _uiRegistry

ecs::Registry& rtp::client::scenes::PlayingScene::_uiRegistry
private

Reference to the ECS registry.

Definition at line 88 of file PlayingScene.hpp.

Referenced by closeChat(), handleEvent(), onEnter(), openChat(), sendChatMessage(), update(), and updateChatHistoryText().

◆ _uiScore

uint32_t rtp::client::scenes::PlayingScene::_uiScore = 0
private

Player score in the UI.

Definition at line 97 of file PlayingScene.hpp.

Referenced by onEnter(), and update().

◆ _worldBuilder

EntityBuilder& rtp::client::scenes::PlayingScene::_worldBuilder
private

Reference to the world entity builder.

Definition at line 95 of file PlayingScene.hpp.

Referenced by spawnParallax().

◆ _worldRegistry

ecs::Registry& rtp::client::scenes::PlayingScene::_worldRegistry
private

Reference to the world ECS registry.

Definition at line 94 of file PlayingScene.hpp.

Referenced by onEnter(), and update().


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