vectozavr-shooter/Client.h

56 lines
1.8 KiB
C
Raw Normal View History

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::map<sf::Uint16, std::shared_ptr<Player>> _players{};
2021-10-02 20:36:07 +03:00
std::shared_ptr<Player> _player;
void spawnPlayer(sf::Uint16 id);
2021-10-02 20:36:07 +03:00
std::function<void(sf::Uint16)> _spawnPlayerCallBack;
std::function<void(sf::Uint16)> _removePlayerCallBack;
std::function<void(const Point4D&, const Point4D&)> _addFireTraceCallBack;
std::function<void(const std::string&, const Point4D&)> _addBonusCallBack;
std::function<void(const std::string&)> _removeBonusCallBack;
2021-09-13 15:53:43 +03:00
public:
2021-10-02 20:36:07 +03:00
Client(std::shared_ptr<Player> player) : _player(player){};
2021-09-13 15:53:43 +03:00
void updatePacket() override;
2021-10-02 20:36:07 +03:00
void setSpawnPlayerCallBack(std::function<void(sf::Uint16)> spawn);
void setRemovePlayerCallBack(std::function<void(sf::Uint16)> remove);
void setAddFireTraceCallBack(std::function<void(const Point4D&, const Point4D&)> addTrace);
void setAddBonusCallBack(std::function<void(const std::string&, const Point4D&)> addBonus);
void setRemoveBonusCallBack(std::function<void(const std::string&)> removeBonus);
2021-09-13 15:53:43 +03:00
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-10-02 20:36:07 +03:00
void addPlayer(sf::Uint16 id, std::shared_ptr<Player> player);
2021-09-13 15:53:43 +03:00
};
#endif //MINECRAFT_3DZAVR_CLIENT_H