2020-08-27 08:10:21 +02:00
|
|
|
#pragma once
|
|
|
|
|
2021-01-04 09:35:21 +01:00
|
|
|
#include <DataTypes.h>
|
|
|
|
|
2020-08-27 08:10:21 +02:00
|
|
|
#include "NetCommon.h"
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Event types for <see cref="IGameServer">.
|
|
|
|
/// </summary>
|
|
|
|
enum class GameServerEventType
|
|
|
|
{
|
|
|
|
None = 0,
|
|
|
|
|
|
|
|
PlayerConnected = 1,
|
|
|
|
PlayerDisconnected = 2,
|
|
|
|
ChatMessage = 3,
|
|
|
|
WorldLoaded = 4,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct GameServerEvent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~GameServerEvent() = default;
|
|
|
|
GameServerEvent(GameServerEventType type) noexcept { this->type = type; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
GameServerEventType type;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PlayerConnectedEvent : GameServerEvent
|
|
|
|
{
|
|
|
|
PlayerConnectedEvent() noexcept : GameServerEvent(GameServerEventType::PlayerConnected) { }
|
|
|
|
|
2021-01-04 09:35:21 +01:00
|
|
|
std::shared_ptr<PlayerInfo> info;
|
2020-08-27 08:10:21 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct PlayerDisconnectedEvent : GameServerEvent
|
|
|
|
{
|
|
|
|
PlayerDisconnectedEvent() noexcept : GameServerEvent(GameServerEventType::PlayerDisconnected) { }
|
|
|
|
|
2021-01-04 09:35:21 +01:00
|
|
|
std::shared_ptr<PlayerInfo> info;
|
2020-08-27 08:10:21 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ChatMessageEvent : GameServerEvent
|
|
|
|
{
|
|
|
|
ChatMessageEvent() noexcept : GameServerEvent(GameServerEventType::ChatMessage) { }
|
|
|
|
|
2021-01-04 09:35:21 +01:00
|
|
|
tstring_view message{};
|
|
|
|
PlayerIndex senderIndex{};
|
2020-08-27 08:10:21 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct WorldLoadedEvent : GameServerEvent
|
|
|
|
{
|
|
|
|
WorldLoadedEvent() noexcept : GameServerEvent(GameServerEventType::WorldLoaded) { }
|
|
|
|
};
|