2021-09-13 15:53:43 +03:00
|
|
|
//
|
|
|
|
// Created by Иван Ильин on 25.05.2021.
|
|
|
|
//
|
|
|
|
|
2021-10-28 17:06:10 +03:00
|
|
|
#ifndef SHOOTER_SHOOTERSERVER_H
|
|
|
|
#define SHOOTER_SHOOTERSERVER_H
|
2021-09-13 15:53:43 +03:00
|
|
|
|
2021-10-09 13:41:12 +03:00
|
|
|
#include "engine/network/ServerUDP.h"
|
2021-09-13 15:53:43 +03:00
|
|
|
#include "Player.h"
|
|
|
|
|
2021-10-17 10:21:10 +03:00
|
|
|
struct BonusInfo final {
|
2021-10-25 04:09:45 +03:00
|
|
|
const Vec3D position{};
|
2021-10-17 10:21:10 +03:00
|
|
|
const double lastTake = std::numeric_limits<double>::min();
|
|
|
|
const bool onTheMap = false;
|
2021-09-13 15:53:43 +03:00
|
|
|
};
|
|
|
|
|
2021-10-28 17:06:10 +03:00
|
|
|
class ShooterServer final : public ServerUDP {
|
2021-09-13 15:53:43 +03:00
|
|
|
private:
|
|
|
|
std::map<sf::Uint16, std::shared_ptr<Player>> _players{};
|
2021-10-17 10:21:10 +03:00
|
|
|
std::map<std::string, std::shared_ptr<BonusInfo>> _bonuses{};
|
2021-09-13 15:53:43 +03:00
|
|
|
public:
|
2021-10-28 17:06:10 +03:00
|
|
|
ShooterServer() = default;
|
2021-09-13 15:53:43 +03:00
|
|
|
|
|
|
|
void broadcast() override;
|
|
|
|
|
|
|
|
void processConnect(sf::Uint16 senderId) override;
|
2021-10-31 11:39:08 +03:00
|
|
|
|
|
|
|
void processClientUpdate(sf::Uint16 senderId, sf::Packet &packet) override;
|
|
|
|
|
2021-09-13 15:53:43 +03:00
|
|
|
void processDisconnect(sf::Uint16 senderId) override;
|
|
|
|
|
2021-10-31 11:39:08 +03:00
|
|
|
void processCustomPacket(sf::Packet &packet, sf::Uint16 senderId) override;
|
2021-09-13 15:53:43 +03:00
|
|
|
|
|
|
|
void processStop() override;
|
|
|
|
|
|
|
|
void generateBonuses();
|
|
|
|
|
|
|
|
void updateInfo() override;
|
2021-10-16 20:22:55 +03:00
|
|
|
|
2021-10-28 17:06:10 +03:00
|
|
|
~ShooterServer() override;
|
2021-09-13 15:53:43 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif //MINECRAFT_3DZAVR_SERVER_H
|