2021-09-13 15:53:43 +03:00
|
|
|
//
|
|
|
|
// Created by Иван Ильин on 25.05.2021.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef SHOOTER_CLIENT_H
|
|
|
|
#define SHOOTER_CLIENT_H
|
|
|
|
|
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
#include "network/ClientUDP.h"
|
|
|
|
#include "Player.h"
|
|
|
|
|
|
|
|
class Client : public ClientUDP {
|
|
|
|
private:
|
|
|
|
std::shared_ptr<Player> _player;
|
|
|
|
std::shared_ptr<World> _world;
|
|
|
|
|
|
|
|
std::map<sf::Uint16, std::shared_ptr<Player>> _players{};
|
|
|
|
|
|
|
|
int fireTraces = 0;
|
2021-09-14 13:47:53 +03:00
|
|
|
|
|
|
|
void spawnPlayer(sf::Uint16 id);
|
2021-09-13 15:53:43 +03:00
|
|
|
public:
|
2021-09-19 11:25:10 +03:00
|
|
|
Client(std::shared_ptr<Player> player, std::shared_ptr<World> world) : _player(player), _world(world) {};
|
2021-09-13 15:53:43 +03:00
|
|
|
|
|
|
|
void updatePacket() override;
|
|
|
|
|
|
|
|
void processInit(sf::Packet& packet) override;
|
|
|
|
void processUpdate(sf::Packet& packet) override;
|
|
|
|
void processNewClient(sf::Packet& packet) override;
|
|
|
|
void processDisconnect(sf::Uint16 targetId) override;
|
|
|
|
|
|
|
|
void processCustomPacket(MsgType type, sf::Packet& packet) override;
|
|
|
|
|
|
|
|
void processDisconnected() override;
|
|
|
|
|
|
|
|
void damagePlayer(sf::Uint16 targetId, double damage);
|
|
|
|
|
|
|
|
void takeBonus(const std::string& bonusName);
|
|
|
|
|
|
|
|
void addTrace(const Point4D& from, const Point4D& to);
|
|
|
|
|
2021-09-14 13:47:53 +03:00
|
|
|
void deleteTrace(std::shared_ptr<World> world, const std::string& traceName);
|
2021-09-13 15:53:43 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif //MINECRAFT_3DZAVR_CLIENT_H
|