38 lines
1.3 KiB
C++
38 lines
1.3 KiB
C++
#include <blitz/protocol/PacketFactory.h>
|
|
|
|
#include <array>
|
|
#include <functional>
|
|
|
|
namespace blitz {
|
|
namespace protocol {
|
|
namespace PacketFactory {
|
|
|
|
using PacketCreator = std::function<std::unique_ptr<Packet>()>;
|
|
|
|
static const std::array<std::unique_ptr<Packet>, static_cast<std::size_t>(PacketType::PACKET_COUNT)> Packets = {
|
|
std::make_unique<packets::PlayerLogin>(),
|
|
std::make_unique<packets::UpdateHealth>(),
|
|
std::make_unique<packets::LoggingSuccess>(),
|
|
std::make_unique<packets::PlayerDeath>(),
|
|
std::make_unique<packets::PlayerJoin>(),
|
|
std::make_unique<packets::PlayerLeave>(),
|
|
std::make_unique<packets::PlayerList>(),
|
|
std::make_unique<packets::PlayerStats>(),
|
|
std::make_unique<packets::ServerConfig>(),
|
|
std::make_unique<packets::ServerTps>(),
|
|
std::make_unique<packets::UpdateGameState>(),
|
|
std::make_unique<packets::KeepAlive>(),
|
|
std::make_unique<packets::Disconnect>(),
|
|
std::make_unique<packets::ChatMessage>(),
|
|
std::make_unique<packets::PlayerPositionAndRotation>(),
|
|
std::make_unique<packets::PlayerShoot>(),
|
|
};
|
|
|
|
const std::unique_ptr<Packet>& CreateReadOnlyPacket(PacketType a_Type) {
|
|
return Packets[static_cast<std::size_t>(a_Type)];
|
|
}
|
|
|
|
} // namespace PacketFactory
|
|
} // namespace protocol
|
|
} // namespace blitz
|