2021-09-13 15:53:43 +03:00
|
|
|
//
|
|
|
|
// Created by Иван Ильин on 25.05.2021.
|
|
|
|
//
|
|
|
|
|
2021-10-28 17:06:10 +03:00
|
|
|
#ifndef SHOOTER_SHOOTERCLIENT_H
|
|
|
|
#define SHOOTER_SHOOTERCLIENT_H
|
2021-09-13 15:53:43 +03:00
|
|
|
|
2023-05-21 16:34:55 +03:00
|
|
|
#include "../3dzavr/engine/network/ClientUDP.h"
|
2022-07-19 12:37:37 +03:00
|
|
|
#include "../player/Player.h"
|
2023-05-21 16:34:55 +03:00
|
|
|
#include <SFML/Config.hpp>
|
2022-07-22 22:52:54 +03:00
|
|
|
#include "Chat.h"
|
2021-09-13 15:53:43 +03:00
|
|
|
|
2021-10-28 17:06:10 +03:00
|
|
|
class ShooterClient final : public ClientUDP {
|
2021-09-13 15:53:43 +03:00
|
|
|
private:
|
2021-10-26 09:50:59 +03:00
|
|
|
std::string _lastEvent;
|
|
|
|
|
2021-09-13 15:53:43 +03:00
|
|
|
std::map<sf::Uint16, std::shared_ptr<Player>> _players{};
|
2021-10-02 20:36:07 +03:00
|
|
|
std::shared_ptr<Player> _player;
|
2021-09-14 13:47:53 +03:00
|
|
|
|
2022-07-22 22:52:54 +03:00
|
|
|
std::shared_ptr<ChatManager> chatManager;
|
2021-09-13 15:53:43 +03:00
|
|
|
|
2023-05-27 18:14:17 +03:00
|
|
|
void damagePlayer(sf::Uint16 targetId, double damage);
|
2022-07-22 22:52:54 +03:00
|
|
|
|
2023-05-27 18:14:17 +03:00
|
|
|
void takeBonus(const std::string &bonusName);
|
2021-09-13 15:53:43 +03:00
|
|
|
|
2023-05-27 18:14:17 +03:00
|
|
|
void sendTrace(const Vec3D &from, const Vec3D &to);
|
2021-10-31 11:39:08 +03:00
|
|
|
|
2023-05-27 18:14:17 +03:00
|
|
|
void changeWeapon(const std::string &weaponName);
|
2021-10-02 20:36:07 +03:00
|
|
|
|
2023-05-27 18:14:17 +03:00
|
|
|
public:
|
|
|
|
explicit ShooterClient(std::shared_ptr<Player> player);
|
2021-10-31 11:39:08 +03:00
|
|
|
|
2023-05-27 18:14:17 +03:00
|
|
|
void sendMessage(std::string message);
|
2021-10-31 11:39:08 +03:00
|
|
|
|
2023-05-27 18:14:17 +03:00
|
|
|
void sendChatMessage(std::string message, std::string name);
|
2021-10-31 11:39:08 +03:00
|
|
|
|
2023-05-27 18:14:17 +03:00
|
|
|
void updatePacket() override;
|
2021-10-31 11:39:08 +03:00
|
|
|
|
|
|
|
void processInit(sf::Packet &packet) override;
|
|
|
|
|
|
|
|
void processUpdate(sf::Packet &packet) override;
|
|
|
|
|
|
|
|
void processNewClient(sf::Packet &packet) override;
|
2021-10-18 18:30:02 +03:00
|
|
|
|
2021-09-13 15:53:43 +03:00
|
|
|
void processDisconnect(sf::Uint16 targetId) override;
|
|
|
|
|
2021-10-31 11:39:08 +03:00
|
|
|
void processCustomPacket(sf::Packet &packet) override;
|
2021-09-13 15:53:43 +03:00
|
|
|
|
|
|
|
void processDisconnected() override;
|
|
|
|
|
2022-07-22 22:52:54 +03:00
|
|
|
void setChatManager(std::shared_ptr<ChatManager> chat) { chatManager = chat; };
|
|
|
|
|
2021-10-02 20:36:07 +03:00
|
|
|
void addPlayer(sf::Uint16 id, std::shared_ptr<Player> player);
|
2021-10-31 11:39:08 +03:00
|
|
|
|
2023-05-21 16:34:55 +03:00
|
|
|
static void requestMap(const std::string& clientIp, std::string *current_map);
|
|
|
|
|
2021-10-31 11:39:08 +03:00
|
|
|
[[nodiscard]] std::map<sf::Uint16, std::shared_ptr<Player>> const &players() const { return _players; }
|
2021-10-26 09:50:59 +03:00
|
|
|
|
|
|
|
[[nodiscard]] std::string lastEvent() const { return _lastEvent; }
|
2021-09-13 15:53:43 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif //MINECRAFT_3DZAVR_CLIENT_H
|