Bomberman
LobbySystem.hpp
Go to the documentation of this file.
1 //
2 // Created by Zoe Roux on 6/11/21.
3 //
4 
5 #pragma once
6 
7 #include "System/System.hpp"
10 #include "Entity/Entity.hpp"
11 #include <array>
12 #include <string>
13 
14 namespace BBM
15 {
17  class LobbySystem : public WAL::System<LobbyComponent, Drawable2DComponent>
18  {
19  private:
20 
21  bool _canJoin();
22 
24 
25 
26  static std::array<RAY::Color, 4> _rayColors;
27 
28  std::array<bool, 4> _colorTaken = {};
29  public:
30  static std::array<std::string, 4> colors;
31 
33  static void addController(WAL::Entity &player, ControllableComponent::Layout layout);
34 
36  static void createTile(const std::shared_ptr<WAL::Scene>& drawable, WAL::Entity &player, int color, int playerCount);
37 
39  void onUpdate(WAL::ViewEntity<LobbyComponent, Drawable2DComponent> &entity, std::chrono::nanoseconds dtime) override;
40 
42  void onSelfUpdate(std::chrono::nanoseconds dtime) override;
43 
46  static bool playersAreReady(WAL::Scene &scene);
47 
50  static void switchToGame(WAL::Wal &wal);
51 
53  void unloadLobby();
54 
56  void addAI();
57 
59  void removeAI();
60 
62  explicit LobbySystem(WAL::Wal &wal);
64  LobbySystem(const LobbySystem &) = default;
66  ~LobbySystem() override = default;
68  LobbySystem &operator=(const LobbySystem &) = delete;
69  };
70 }
BBM::LobbySystem::createTile
static void createTile(const std::shared_ptr< WAL::Scene > &drawable, WAL::Entity &player, int color, int playerCount)
Create ingame tile.
Definition: LobbySystem.cpp:220
BBM::LobbySystem::playersAreReady
static bool playersAreReady(WAL::Scene &scene)
Check if every player is ready.
Definition: LobbySystem.cpp:177
BBM::LobbySystem::_canJoin
bool _canJoin()
Definition: LobbySystem.cpp:113
BBM::LobbySystem::addAI
void addAI()
Add an AI to the game.
Definition: LobbySystem.cpp:122
WAL::ViewEntity
Definition: View.hpp:19
System.hpp
BBM::LobbySystem::colors
static std::array< std::string, 4 > colors
Definition: LobbySystem.hpp:30
BBM::ControllableComponent::Layout
Layout
Definition: ControllableComponent.hpp:20
BBM::LobbySystem
A system to handle Health entities.
Definition: LobbySystem.hpp:17
BBM
Definition: AnimationsComponent.cpp:9
WAL::Wal
The main WAL class, it is used to setup and run the ECS.
Definition: Wal.hpp:27
Entity.hpp
WAL::Entity
An entity of the WAL's ECS.
Definition: Entity.hpp:20
BBM::LobbySystem::_nextColor
void _nextColor(WAL::ViewEntity< LobbyComponent, Drawable2DComponent > &entity)
Definition: LobbySystem.cpp:53
BBM::LobbySystem::addController
static void addController(WAL::Entity &player, ControllableComponent::Layout layout)
Add a controller for the player.
Definition: LobbySystem.cpp:192
BBM::LobbySystem::unloadLobby
void unloadLobby()
Reset the lobby scene to it's default state.
Definition: LobbySystem.cpp:312
ControllableComponent.hpp
BBM::LobbySystem::switchToGame
static void switchToGame(WAL::Wal &wal)
Inform the engine that the next scene should be the game scene and load it.
Definition: LobbySystem.cpp:285
BBM::LobbySystem::LobbySystem
LobbySystem(WAL::Wal &wal)
A default constructor.
Definition: LobbySystem.cpp:49
BBM::LobbySystem::removeAI
void removeAI()
Remove an AI from the game.
Definition: LobbySystem.cpp:139
BBM::LobbySystem::onSelfUpdate
void onSelfUpdate(std::chrono::nanoseconds dtime) override
A method called after all entities that this system manage has been updated.
Definition: LobbySystem.cpp:163
BBM::LobbySystem::operator=
LobbySystem & operator=(const LobbySystem &)=delete
A system is not assignable.
BBM::LobbySystem::_rayColors
static std::array< RAY::Color, 4 > _rayColors
Definition: LobbySystem.hpp:26
WAL::System
A base system of WAL.
Definition: System.hpp:22
WAL::Scene
Represent a single scene that contains entities.
Definition: Scene.hpp:17
BBM::LobbySystem::~LobbySystem
~LobbySystem() override=default
A default destructor.
BBM::LobbySystem::_colorTaken
std::array< bool, 4 > _colorTaken
Definition: LobbySystem.hpp:28
LobbyComponent.hpp
BBM::LobbySystem::onUpdate
void onUpdate(WAL::ViewEntity< LobbyComponent, Drawable2DComponent > &entity, std::chrono::nanoseconds dtime) override
Definition: LobbySystem.cpp:68