Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
LevelSystem.hpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2025
3** Air-Trap
4** File description:
5** LevelSystem
6*/
7
8#pragma once
9
10#include <string>
11#include <unordered_map>
12#include <optional>
13
14#include "Game/LevelData.hpp"
17#include "Systems/NetworkSyncSystem.hpp"
18
19namespace rtp::server {
20
22 public:
30 LevelSystem(ecs::Registry& registry,
31 EntitySystem& entitySystem,
32 RoomSystem& roomSystem,
33 NetworkSyncSystem& networkSync);
34
40 void registerLevelPath(uint32_t levelId, const std::string& path);
41
47 void startLevelForRoom(uint32_t roomId, uint32_t levelId);
48
53 void stopLevelForRoom(uint32_t roomId);
54
59 void update(float dt);
60
66 const LevelData* getLevelData(uint32_t roomId) const;
67
68 private:
72 struct ActiveLevel {
74 float elapsed{0.0f};
75 size_t nextSpawn{0};
76 size_t nextPowerup{0};
77 size_t nextObstacle{0};
78 };
79
85 void spawnEntityForRoom(uint32_t roomId, const ecs::Entity& entity);
86
92 std::optional<LevelData> loadLevel(uint32_t levelId) const;
93
94 private:
99 std::unordered_map<uint32_t,
101 std::unordered_map<uint32_t,
102 std::string> _levelPaths;
103};
104
105} // namespace rtp::server
Represents an entity in the ECS (Entity-Component-System) architecture.
Definition Entity.hpp:63
Base class for systems that operate on entities in the ECS.
void stopLevelForRoom(uint32_t roomId)
Stop the level for a specific room.
const LevelData * getLevelData(uint32_t roomId) const
Get the level data for a specific room.
void spawnEntityForRoom(uint32_t roomId, const ecs::Entity &entity)
Spawn an entity for a specific room.
RoomSystem & _roomSystem
Reference to the RoomSystem.
std::unordered_map< uint32_t, std::string > _levelPaths
Level file paths mapped by level ID.
void startLevelForRoom(uint32_t roomId, uint32_t levelId)
Start a level for a specific room.
std::optional< LevelData > loadLevel(uint32_t levelId) const
Load level data from a file.
NetworkSyncSystem & _networkSync
Reference to the NetworkSyncSystem.
ecs::Registry & _registry
Reference to the entity registry.
void registerLevelPath(uint32_t levelId, const std::string &path)
Register a level file path with a level ID.
EntitySystem & _entitySystem
Reference to the EntitySystem.
void update(float dt)
Update system logic for one frame.
std::unordered_map< uint32_t, ActiveLevel > _activeLevels
Active levels mapped by room ID.
System to handle network-related operations on the server side.
System to handle room-related operations on the server side.
File : GameManager.hpp License: MIT Author : Elias Josué HAJJAR LLAUQUEN elias-josue....
Struct to hold active level data for a room.