// // Created by Zoe Roux on 6/11/21. // #include #include #include #include "System/Lobby/LobbySystem.hpp" #include "Component/Controllable/ControllableComponent.hpp" #include namespace BBM { LobbySystem::LobbySystem(WAL::Wal &wal) : System(wal) {} void LobbySystem::onUpdate(WAL::ViewEntity &entity, std::chrono::nanoseconds dtime) { auto &lobby = entity.get(); auto lastTick = std::chrono::steady_clock::now(); if (lastTick - lobby.lastInput < std::chrono::milliseconds(150)) return; if (lobby.layout == ControllableComponent::NONE) { for (auto &[_, controller] : this->_wal.getScene()->view()) { if (controller.jump) { if (std::any_of(this->getView().begin(), this->getView().end(), [&controller](WAL::ViewEntity &view) { return view.get().layout == controller.layout; })) return; lobby.lastInput = lastTick; lobby.layout = controller.layout; entity.get().drawable = std::make_shared("assets/player/icons/blue.png"); return; } } } for (auto &[_, controller] : this->_wal.getScene()->view()) { if (controller.layout == lobby.layout && controller.jump) { lobby.ready = true; lobby.lastInput = lastTick; auto *texture = dynamic_cast(lobby.readyButton.getComponent().drawable.get()); if (texture) texture->use("assets/player/icons/ready.png"); } } } }