1
0
mirror of https://github.com/ncblakely/GiantsTools synced 2024-12-23 15:57:22 +01:00
GiantsTools/Sdk/Include/Network/Public/IGameServer.h

81 lines
2.7 KiB
C
Raw Normal View History

2020-08-27 08:10:21 +02:00
#pragma once
#include <vector>
#include <functional>
#include <memory>
2021-01-24 00:40:09 +01:00
#include "Core/Public/Core.h"
2020-08-27 08:10:21 +02:00
#include "GameServerEvents.h"
#include "NetCommon.h"
/// <summary>
/// Defines an API for communicating with the game server.
/// </summary>
2021-01-24 00:40:09 +01:00
DEFINE_SERVICE_MULTI("{B2D67EE7-8063-488F-B3B9-E7DA675CB752}", IGameServer, IEventSource<GameServerEventType, GameServerEvent>)
2020-08-27 08:10:21 +02:00
{
virtual ~IGameServer() = default;
/// <summary>
/// Sends a chat message to all players or to a specified player.
/// </summary>
/// <param name="message">The chat message.</param>
/// <param name="color">Text color.</param>
/// <param name="flags">Flags for the message.</param>
/// <param name="indexTo">The index to send the message to. If 0, it will be sent to all players.</param>
2021-01-24 00:40:09 +01:00
virtual void SendChatMessage(const tstring_view& message, ChatColor color, ChatFlag flags, PlayerIndex indexTo) = 0;
2020-08-27 08:10:21 +02:00
/// <summary>
/// Bans the player at the specified index.
/// </summary>
/// <param name="index">The player index.</param>
2021-01-24 00:40:09 +01:00
virtual void BanPlayer(int index) = 0;
2020-08-27 08:10:21 +02:00
2021-02-28 09:46:21 +01:00
/// <summary>
/// Removes the IP address from the ban list.
/// </summary>
/// <param name="index">The IP address.</param>
virtual void UnbanPlayer(const IPAddress & ipAddress) = 0;
/// <summary>
/// Gets the IP addresses that are currently banned.
/// </summary>
virtual const std::vector<IPAddress> GetBans() const = 0;
/// <summary>
/// Kicks the player at the specified index.
/// </summary>
/// <param name="index">The player index.</param>
/// <param name="reason">The reason for kicking the player.</param>
2021-01-24 00:40:09 +01:00
virtual void KickPlayer(int index, KickReason reason) = 0;
2020-08-27 08:10:21 +02:00
/// <summary>
/// Gets player data for the specified index.
/// </summary>
/// <param name="index">The zero-based player index.</param>
/// <throws>std::out_of_range</throws>
2021-01-24 00:40:09 +01:00
virtual const std::shared_ptr<PlayerInfo> GetPlayer(int index) const = 0;
2020-08-27 08:10:21 +02:00
/// <summary>
/// Gets data for all players in the current game.
/// </summary>
2021-01-24 00:40:09 +01:00
virtual std::vector<std::shared_ptr<PlayerInfo>> GetPlayers() const = 0;
2020-08-27 08:10:21 +02:00
/// <summary>
/// Toggles or increments the specified game option.
/// Note: the behavior of this method is the same as changing an option from the F1 in-game menu.
/// </summary>
/// <param name="option"></param>
/// <returns></returns>
2021-01-24 00:40:09 +01:00
virtual void ChangeGameOption(GameOption option) = 0;
2020-08-27 08:10:21 +02:00
/// <summary>
/// Gets details for the current game.
/// </summary>
2021-01-24 00:40:09 +01:00
virtual const std::shared_ptr<NetGameDetails> GetGameDetails() const = 0;
/// <summary>
/// Modifies the settings for the current game.
/// </summary>
/// <param name="gameDetails">The game details.</param>
2021-01-24 00:40:09 +01:00
virtual void ChangeGameDetails(const NetGameDetails& gameDetails) = 0;
2021-02-28 09:46:21 +01:00
};