Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
PlayingScene.hpp
Go to the documentation of this file.
1
8#ifndef RTYPE_CLIENT_SCENES_PLAYINGSCENE_HPP_
9 #define RTYPE_CLIENT_SCENES_PLAYINGSCENE_HPP_
10
11 #include "Interfaces/IScene.hpp"
12 #include "RType/ECS/Registry.hpp"
13 #include "UI/UiFactory.hpp"
14 #include "Utils/GameState.hpp"
15 #include "Systems/NetworkSyncSystem.hpp"
17 #include "Core/Settings.hpp"
18 #include <SFML/Graphics.hpp>
19 #include <memory>
20 #include <functional>
21
22namespace rtp::client {
23 namespace scenes {
32 {
33 public:
41 PlayingScene(ecs::Registry& worldRegistry,
42 ecs::Registry& uiRegistry,
43 Settings& settings,
44 TranslationManager& translationManager,
45 NetworkSyncSystem& network,
46 graphics::UiFactory& uiFactory,
47 EntityBuilder& worldBuilder,
48 std::function<void(GameState)> changeState);
49
53 using ChangeStateFn = std::function<void(GameState)>;
54
58 void onEnter(void) override;
59
63 void onExit(void) override;
64
69 void handleEvent(const sf::Event& event) override;
70
75 void update(float dt) override;
76
77 private:
81 void spawnParallax(void);
82 void sendChatMessage(void);
83 void openChat(void);
84 void closeChat(void);
85 void updateChatHistoryText(void);
86
87 private:
97 uint32_t _uiScore = 0;
98 uint32_t _uiFps = 0;
99 uint32_t _uiPing = 0;
100 float _fpsTimer = 0.0f;
101 uint32_t _fpsFrames = 0;
110 bool _hudInit{false};
112 bool _chatOpen{false};
120 float _chargeTime{0.0f};
121 };
122 } // namespace scenes
123} // namespace rtp::client
124
125#endif // RTYPE_CLIENT_SCENES_PLAYINGSCENE_HPP_
System to handle network-related operations on the client side.
Manages game settings and preferences.
Definition Settings.hpp:67
Manages game translations for all UI elements.
Factory class for creating UI components in the ECS registry.
Definition UiFactory.hpp:72
Interface for different scenes in the client application.
Definition IScene.hpp:23
Scene for the main gameplay.
uint32_t _uiPing
Current ping in the UI.
EntityBuilder & _worldBuilder
Reference to the world entity builder.
void handleEvent(const sf::Event &event) override
Handle an incoming event.
graphics::UiFactory & _uiFactory
UI Factory for creating UI components.
ecs::Entity _hudFps
Entity for displaying FPS in the HUD.
bool _chatOpen
Whether expanded chat is open.
uint32_t _uiFps
Current FPS in the UI.
void onExit(void) override
Called when the scene is exited.
ChangeStateFn _changeState
Function to change the game state.
ecs::Entity _chatCompactPanel
Compact chat background panel.
void onEnter(void) override
Called when the scene is entered.
TranslationManager & _translationManager
Reference to the translation manager.
void spawnParallax(void)
Spawn parallax background entities.
ecs::Entity _hudHealth
Entity for displaying health.
bool _hudInit
Flag indicating if HUD is initialized.
float _fpsTimer
FPS timer accumulator.
ecs::Entity _hudEntities
Parent entity for HUD elements.
float _chargeTime
Local charge timer for HUD.
ecs::Entity _chatHistoryText
Text entity for chat history.
ecs::Entity _hudAmmo
Entity for displaying ammo.
Settings & _settings
Reference to the application settings.
ecs::Entity _chatPanel
Expanded chat panel.
void update(float dt) override
Update the scene state.
ecs::Entity _chatCompactText
Text entity for last chat message.
NetworkSyncSystem & _network
Reference to the client network.
ecs::Registry & _uiRegistry
Reference to the ECS registry.
ecs::Entity _hudScore
Entity for displaying score in the HUD.
ecs::Entity _hudPing
Entity for displaying ping in the HUD.
ecs::Registry & _worldRegistry
Reference to the world ECS registry.
uint32_t _fpsFrames
FPS frame count.
ecs::Entity _hudChargeBar
Entity for charged shot HUD bar.
uint32_t _uiScore
Player score in the UI.
std::function< void(GameState)> ChangeStateFn
Type alias for a function that changes the game state.
ecs::Entity _chatInput
Text input entity for chat.
Represents an entity in the ECS (Entity-Component-System) architecture.
Definition Entity.hpp:63
R-Type client namespace.