52 lines
1.5 KiB
C++
52 lines
1.5 KiB
C++
#pragma once
|
|
#include <string>
|
|
#include <unordered_map>
|
|
#include <vector>
|
|
#include "ClientState.h"
|
|
|
|
// NetworkInterface.h - »нтерфейс дл¤ разных типов соединений
|
|
namespace ZL {
|
|
|
|
struct ProjectileInfo {
|
|
int shooterId = -1;
|
|
uint64_t clientTime = 0;
|
|
Eigen::Vector3f position = Eigen::Vector3f::Zero();
|
|
//Eigen::Vector3f direction = Eigen::Vector3f::Zero();
|
|
Eigen::Matrix3f rotation = Eigen::Matrix3f::Identity();
|
|
float velocity = 0;
|
|
};
|
|
|
|
struct DeathInfo {
|
|
int targetId = -1;
|
|
uint64_t serverTime = 0;
|
|
Eigen::Vector3f position = Eigen::Vector3f::Zero();
|
|
int killerId = -1;
|
|
};
|
|
|
|
struct BoxDestroyedInfo {
|
|
int boxIndex = -1;
|
|
uint64_t serverTime = 0;
|
|
Eigen::Vector3f position = Eigen::Vector3f::Zero();
|
|
int destroyedBy = -1;
|
|
};
|
|
|
|
class INetworkClient {
|
|
public:
|
|
virtual ~INetworkClient() = default;
|
|
virtual void Connect(const std::string& host, uint16_t port) = 0;
|
|
virtual void Send(const std::string& message) = 0;
|
|
virtual bool IsConnected() const = 0;
|
|
virtual void Poll() = 0; // ƒл¤ обработки вход¤щих пакетов
|
|
virtual std::unordered_map<int, ClientStateInterval> getRemotePlayers() = 0;
|
|
|
|
virtual std::vector<std::pair<Eigen::Vector3f, Eigen::Matrix3f>> getServerBoxes() = 0;
|
|
|
|
virtual std::vector<ProjectileInfo> getPendingProjectiles() = 0;
|
|
|
|
virtual std::vector<DeathInfo> getPendingDeaths() = 0;
|
|
virtual std::vector<int> getPendingRespawns() = 0;
|
|
virtual int GetClientId() const { return -1; }
|
|
virtual std::vector<BoxDestroyedInfo> getPendingBoxDestructions() = 0;
|
|
};
|
|
}
|