|
Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
|
Scene for the main gameplay. More...
#include <PlayingScene.hpp>
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. | |
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.
| using rtp::client::scenes::PlayingScene::ChangeStateFn = std::function<void(GameState)> |
Type alias for a function that changes the game state.
Definition at line 53 of file PlayingScene.hpp.
| 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.
| registry | Reference to the ECS registry |
| settings | Reference to the application settings |
| network | Reference to the client network |
| window | Reference to the SFML render window |
Definition at line 26 of file PlayingScene.cpp.
|
private |
Definition at line 434 of file PlayingScene.cpp.
References _chatHistoryText, _chatInput, _chatOpen, _chatPanel, _uiRegistry, rtp::ecs::Entity::isNull(), and rtp::ecs::Registry::kill().
Referenced by handleEvent(), onExit(), and sendChatMessage().
|
overridevirtual |
Handle an incoming event.
| event | The event to handle. |
Implements rtp::client::interfaces::IScene.
Definition at line 153 of file PlayingScene.cpp.
References _changeState, _chatInput, _chatOpen, _settings, _uiRegistry, closeChat(), rtp::ecs::Registry::get(), rtp::client::Settings::getGamepadEnabled(), rtp::client::Settings::getGamepadPauseButton(), openChat(), rtp::client::Paused, and rtp::ecs::components::ui::TextInput::value.
|
overridevirtual |
Called when the scene is entered.
Implements rtp::client::interfaces::IScene.
Definition at line 45 of file PlayingScene.cpp.
References _chargeTime, _chatCompactPanel, _chatCompactText, _hudAmmo, _hudChargeBar, _hudEntities, _hudFps, _hudHealth, _hudInit, _hudPing, _hudScore, _uiFactory, _uiRegistry, _uiScore, _worldRegistry, rtp::ecs::Registry::add(), rtp::ecs::components::ui::Text::alpha, rtp::ecs::components::audio::AudioSource::audioPath, rtp::ecs::components::ui::Text::blue, rtp::ecs::components::ui::Text::content, rtp::client::graphics::UiFactory::createButton(), rtp::client::graphics::UiFactory::createSlider(), rtp::client::graphics::UiFactory::createText(), rtp::ecs::components::audio::AudioSource::dirty, rtp::ecs::components::ui::Text::fontPath, rtp::ecs::components::ui::Text::fontSize, rtp::ecs::Registry::get(), rtp::ecs::components::ui::Text::green, rtp::log::info(), rtp::ecs::components::audio::AudioSource::isPlaying, rtp::ecs::components::audio::AudioSource::loop, rtp::ecs::components::ui::Text::position, rtp::ecs::components::ui::Text::red, rtp::ecs::Registry::spawn(), spawnParallax(), rtp::ecs::components::audio::AudioSource::volume, rtp::log::warning(), and rtp::ecs::components::ui::Text::zIndex.
|
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().
|
private |
Definition at line 375 of file PlayingScene.cpp.
References _chatHistoryText, _chatInput, _chatOpen, _chatPanel, _uiFactory, _uiRegistry, rtp::client::graphics::UiFactory::createButton(), rtp::client::graphics::UiFactory::createText(), rtp::client::graphics::UiFactory::createTextInput(), rtp::ecs::Registry::get(), sendChatMessage(), and updateChatHistoryText().
Referenced by handleEvent().
|
private |
Definition at line 355 of file PlayingScene.cpp.
References _chatInput, _network, _uiRegistry, closeChat(), rtp::ecs::Registry::get(), rtp::client::NetworkSyncSystem::trySendMessage(), and rtp::ecs::components::ui::TextInput::value.
Referenced by openChat().
|
private |
Spawn parallax background entities.
Definition at line 297 of file PlayingScene.cpp.
References _network, _worldBuilder, rtp::client::EntityTemplate::createParallaxLvl2_1(), rtp::client::EntityTemplate::createParallaxLvl3_1(), rtp::client::EntityTemplate::createParallaxLvl3_2(), rtp::client::EntityTemplate::createParallaxLvl3_3(), rtp::client::EntityTemplate::createParallaxLvl3_4(), rtp::client::EntityTemplate::createParallaxLvl3_5(), rtp::client::EntityTemplate::createParallaxLvl3_6(), rtp::client::EntityTemplate::createParallaxLvl3_7(), rtp::client::EntityTemplate::createParallaxLvl3_8(), rtp::client::EntityTemplate::createParallaxLvl3_9(), rtp::client::EntityTemplate::createParallaxLvl4_1(), rtp::client::EntityTemplate::createParallaxLvl4_2(), rtp::client::EntityTemplate::createParallaxLvl4_3(), rtp::client::EntityTemplate::createParallaxLvl4_4(), rtp::client::EntityTemplate::createParallaxLvl4_5(), rtp::client::EntityTemplate::createParallaxLvl4_6(), rtp::client::EntityTemplate::createParrallaxLvl1_1(), rtp::client::EntityTemplate::createParrallaxLvl1_2(), rtp::log::error(), rtp::client::NetworkSyncSystem::getCurrentLevelId(), and rtp::client::EntityBuilder::spawn().
Referenced by onEnter().
|
overridevirtual |
Update the scene state.
| dt | Time delta since the last update. |
Implements rtp::client::interfaces::IScene.
Definition at line 200 of file PlayingScene.cpp.
References _changeState, _chargeTime, _chatCompactText, _chatOpen, _fpsFrames, _fpsTimer, _hudAmmo, _hudChargeBar, _hudEntities, _hudFps, _hudHealth, _hudInit, _hudPing, _hudScore, _network, _settings, _uiFps, _uiPing, _uiRegistry, _uiScore, _worldRegistry, rtp::client::NetworkSyncSystem::consumeGameOver(), rtp::client::NetworkSyncSystem::consumeKicked(), rtp::client::GameOver, rtp::ecs::Registry::get(), rtp::client::NetworkSyncSystem::getAmmoCurrent(), rtp::client::NetworkSyncSystem::getAmmoMax(), rtp::client::NetworkSyncSystem::getHealthCurrent(), rtp::client::NetworkSyncSystem::getHealthMax(), rtp::client::Settings::getKey(), rtp::client::NetworkSyncSystem::getLastChatMessage(), rtp::client::NetworkSyncSystem::getPingMs(), rtp::client::NetworkSyncSystem::getReloadCooldownRemaining(), rtp::client::NetworkSyncSystem::getScore(), rtp::client::NetworkSyncSystem::isReloading(), rtp::client::Menu, rtp::client::Shoot, updateChatHistoryText(), and rtp::ecs::components::ui::TextInput::value.
|
private |
Definition at line 448 of file PlayingScene.cpp.
References _chatHistoryText, _network, _uiRegistry, rtp::ecs::Registry::get(), and rtp::client::NetworkSyncSystem::getChatHistory().
Referenced by openChat(), and update().
|
private |
Function to change the game state.
Definition at line 93 of file PlayingScene.hpp.
Referenced by handleEvent(), and update().
|
private |
Local charge timer for HUD.
Definition at line 120 of file PlayingScene.hpp.
|
private |
Compact chat background panel.
Definition at line 113 of file PlayingScene.hpp.
Referenced by onEnter().
|
private |
Text entity for last chat message.
Definition at line 114 of file PlayingScene.hpp.
|
private |
Text entity for chat history.
Definition at line 117 of file PlayingScene.hpp.
Referenced by closeChat(), openChat(), and updateChatHistoryText().
|
private |
Text input entity for chat.
Definition at line 118 of file PlayingScene.hpp.
Referenced by closeChat(), handleEvent(), openChat(), and sendChatMessage().
|
private |
Whether expanded chat is open.
Definition at line 112 of file PlayingScene.hpp.
Referenced by closeChat(), handleEvent(), openChat(), and update().
|
private |
Expanded chat panel.
Definition at line 116 of file PlayingScene.hpp.
Referenced by closeChat(), and openChat().
|
private |
|
private |
|
private |
Entity for displaying ammo.
Definition at line 107 of file PlayingScene.hpp.
|
private |
Entity for charged shot HUD bar.
Definition at line 109 of file PlayingScene.hpp.
|
private |
Parent entity for HUD elements.
Definition at line 106 of file PlayingScene.hpp.
|
private |
Entity for displaying FPS in the HUD.
Definition at line 104 of file PlayingScene.hpp.
|
private |
Entity for displaying health.
Definition at line 108 of file PlayingScene.hpp.
|
private |
Flag indicating if HUD is initialized.
Definition at line 110 of file PlayingScene.hpp.
|
private |
Entity for displaying ping in the HUD.
Definition at line 103 of file PlayingScene.hpp.
|
private |
Entity for displaying score in the HUD.
Definition at line 105 of file PlayingScene.hpp.
|
private |
Reference to the client network.
Definition at line 91 of file PlayingScene.hpp.
Referenced by sendChatMessage(), spawnParallax(), update(), and updateChatHistoryText().
|
private |
Reference to the application settings.
Definition at line 89 of file PlayingScene.hpp.
Referenced by handleEvent(), and update().
|
private |
Reference to the translation manager.
Definition at line 90 of file PlayingScene.hpp.
|
private |
UI Factory for creating UI components.
Definition at line 92 of file PlayingScene.hpp.
Referenced by onEnter(), and openChat().
|
private |
|
private |
|
private |
Reference to the ECS registry.
Definition at line 88 of file PlayingScene.hpp.
Referenced by closeChat(), handleEvent(), onEnter(), openChat(), sendChatMessage(), update(), and updateChatHistoryText().
|
private |
Player score in the UI.
Definition at line 97 of file PlayingScene.hpp.
|
private |
Reference to the world entity builder.
Definition at line 95 of file PlayingScene.hpp.
Referenced by spawnParallax().
|
private |
Reference to the world ECS registry.
Definition at line 94 of file PlayingScene.hpp.