|
Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
|
#include <LevelSystem.hpp>
Classes | |
| struct | ActiveLevel |
| Struct to hold active level data for a room. More... | |
Public Member Functions | |
| LevelSystem (ecs::Registry ®istry, EntitySystem &entitySystem, RoomSystem &roomSystem, NetworkSyncSystem &networkSync) | |
| Constructor for LevelSystem. | |
| void | registerLevelPath (uint32_t levelId, const std::string &path) |
| Register a level file path with a level ID. | |
| void | startLevelForRoom (uint32_t roomId, uint32_t levelId) |
| Start a level for a specific room. | |
| void | stopLevelForRoom (uint32_t roomId) |
| Stop the level for a specific room. | |
| void | update (float dt) |
| Update system logic for one frame. | |
| const LevelData * | getLevelData (uint32_t roomId) const |
| Get the level data for a specific room. | |
Private Member Functions | |
| void | spawnEntityForRoom (uint32_t roomId, const ecs::Entity &entity) |
| Spawn an entity for a specific room. | |
| std::optional< LevelData > | loadLevel (uint32_t levelId) const |
| Load level data from a file. | |
Private Attributes | |
| ecs::Registry & | _registry |
| Reference to the entity registry. | |
| EntitySystem & | _entitySystem |
| Reference to the EntitySystem. | |
| RoomSystem & | _roomSystem |
| Reference to the RoomSystem. | |
| NetworkSyncSystem & | _networkSync |
| Reference to the NetworkSyncSystem. | |
| std::unordered_map< uint32_t, ActiveLevel > | _activeLevels |
| Active levels mapped by room ID. | |
| std::unordered_map< uint32_t, std::string > | _levelPaths |
| Level file paths mapped by level ID. | |
Definition at line 21 of file LevelSystem.hpp.
| rtp::server::LevelSystem::LevelSystem | ( | ecs::Registry & | registry, |
| EntitySystem & | entitySystem, | ||
| RoomSystem & | roomSystem, | ||
| NetworkSyncSystem & | networkSync | ||
| ) |
Constructor for LevelSystem.
| registry | Reference to the ECS registry |
| entitySystem | Reference to the EntitySystem |
| roomSystem | Reference to the RoomSystem |
| networkSync | Reference to the NetworkSyncSystem |
Definition at line 23 of file LevelSystem.cpp.
| const LevelData * rtp::server::LevelSystem::getLevelData | ( | uint32_t | roomId | ) | const |
Get the level data for a specific room.
| roomId | ID of the room |
Definition at line 238 of file LevelSystem.cpp.
References _activeLevels.
|
private |
Load level data from a file.
| levelId | ID of the level to load |
Definition at line 39 of file LevelSystem.cpp.
References _levelPaths, rtp::log::error(), rtp::server::loadLevelFromFile(), and rtp::log::warning().
Referenced by startLevelForRoom().
| void rtp::server::LevelSystem::registerLevelPath | ( | uint32_t | levelId, |
| const std::string & | path | ||
| ) |
Register a level file path with a level ID.
| levelId | ID of the level |
| path | File path to the level data |
Definition at line 34 of file LevelSystem.cpp.
References _levelPaths.
|
private |
Spawn an entity for a specific room.
| roomId | ID of the room |
| entity | Entity to spawn |
Definition at line 178 of file LevelSystem.cpp.
References _networkSync, _registry, _roomSystem, rtp::net::EntitySpawn, rtp::log::error(), rtp::ecs::Registry::get(), rtp::server::RoomSystem::getRoom(), rtp::ecs::Entity::index(), rtp::server::NetworkSyncSystem::sendPacketToSessions(), and rtp::net::TCP.
Referenced by update().
| void rtp::server::LevelSystem::startLevelForRoom | ( | uint32_t | roomId, |
| uint32_t | levelId | ||
| ) |
Start a level for a specific room.
| roomId | ID of the room |
| levelId | ID of the level to start |
Definition at line 57 of file LevelSystem.cpp.
References _activeLevels, rtp::server::LevelSystem::ActiveLevel::data, rtp::log::info(), and loadLevel().
| void rtp::server::LevelSystem::stopLevelForRoom | ( | uint32_t | roomId | ) |
Stop the level for a specific room.
| roomId | ID of the room |
Definition at line 70 of file LevelSystem.cpp.
References _activeLevels.
| void rtp::server::LevelSystem::update | ( | float | dt | ) |
Update system logic for one frame.
| dt | Time elapsed since last update in seconds |
Definition at line 75 of file LevelSystem.cpp.
References _activeLevels, _entitySystem, _registry, _roomSystem, rtp::ecs::Registry::add(), rtp::net::Boss, rtp::net::Boss2, rtp::net::BossShield, rtp::server::EntitySystem::createEnemyEntity(), rtp::server::EntitySystem::createObstacleEntity(), rtp::server::EntitySystem::createPowerupEntity(), rtp::server::RoomSystem::getRoom(), rtp::server::Room::InGame, rtp::net::Player, spawnEntityForRoom(), rtp::Vec2< T >::x, rtp::Vec2< T >::y, and rtp::ecs::Registry::zipView().
|
private |
Active levels mapped by room ID.
Definition at line 100 of file LevelSystem.hpp.
Referenced by getLevelData(), startLevelForRoom(), stopLevelForRoom(), and update().
|
private |
Reference to the EntitySystem.
Definition at line 96 of file LevelSystem.hpp.
Referenced by update().
|
private |
Level file paths mapped by level ID.
Definition at line 102 of file LevelSystem.hpp.
Referenced by loadLevel(), and registerLevelPath().
|
private |
Reference to the NetworkSyncSystem.
Definition at line 98 of file LevelSystem.hpp.
Referenced by spawnEntityForRoom().
|
private |
Reference to the entity registry.
Definition at line 95 of file LevelSystem.hpp.
Referenced by spawnEntityForRoom(), and update().
|
private |
Reference to the RoomSystem.
Definition at line 97 of file LevelSystem.hpp.
Referenced by spawnEntityForRoom(), and update().