Some checks failed
Linux arm64 / Build (push) Has been cancelled
ajout d'un changement pour la cadence de tir Co-authored-by: Morph01 <145839520+Morph01@users.noreply.github.com> Co-authored-by: Persson-dev <sim16.prib@gmail.com> Reviewed-on: #33 Reviewed-by: Simon Pribylski <sim16.prib@gmail.com> Co-authored-by: Morph01 <thibaut6969delastreet@gmail.com> Co-committed-by: Morph01 <thibaut6969delastreet@gmail.com>
82 lines
1.7 KiB
C++
82 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include "blitz/common/Defines.h"
|
|
#include "blitz/game/Listeners.h"
|
|
#include "blitz/misc/ObjectNotifier.h"
|
|
#include "blitz/misc/Time.h"
|
|
#include "blitz/protocol/packets/ChatPacket.h"
|
|
#include "client/config/BlitzConfig.h"
|
|
#include <cstdint>
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
namespace blitz {
|
|
|
|
static const int PlayerUpdatePosRate = 50;
|
|
|
|
namespace client {
|
|
class ClientConnexion;
|
|
class ClientGame;
|
|
} // namespace client
|
|
|
|
namespace server {
|
|
class Server;
|
|
} // namespace server
|
|
|
|
|
|
|
|
// Singleton
|
|
class Client : public utils::ObjectNotifier<game::ClientListener>, public game::PlayerInputListener {
|
|
private:
|
|
std::unique_ptr<server::Server> m_Server;
|
|
std::unique_ptr<client::ClientConnexion> m_Connexion;
|
|
std::unique_ptr<client::ClientGame> m_Game;
|
|
utils::Timer m_UpdatePosTimer{PlayerUpdatePosRate};
|
|
BlitzConfig m_Config;
|
|
|
|
public:
|
|
Client();
|
|
virtual ~Client();
|
|
|
|
void Update();
|
|
|
|
bool IsConnected();
|
|
|
|
bool JoinGame(const std::string& pseudo, const std::string& address, std::uint16_t port);
|
|
bool CreateGame(std::uint16_t port, const std::string& pseudo);
|
|
|
|
void Disconnect();
|
|
|
|
void SendChatText(const std::string& text);
|
|
void ChatTextReceived(const protocol::ColoredText& text);
|
|
|
|
void SendPlayerPosAndLook(const Vec3f& position, float yaw, float pitch);
|
|
|
|
virtual void OnLocalPlayerShoot(const Vec3f& position, float yaw, float pitch) override;
|
|
|
|
game::PlayerID GetPlayerID() const;
|
|
|
|
client::ClientGame* GetGame() {
|
|
return m_Game.get();
|
|
}
|
|
|
|
BlitzConfig* GetConfig() {
|
|
return &m_Config;
|
|
}
|
|
|
|
bool IsAdmin() const;
|
|
|
|
server::Server* GetServer() {
|
|
return m_Server.get();
|
|
}
|
|
|
|
void UpdateServerConfig();
|
|
|
|
private:
|
|
void Reset();
|
|
|
|
void UpdatePosition(std::uint64_t delta);
|
|
};
|
|
|
|
} // namespace blitz
|