1
0
mirror of https://github.com/ncblakely/GiantsTools synced 2024-11-24 07:05:37 +01:00
GiantsTools/Sdk/Include/IGameServer.h

80 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>
#include <DataTypes.h>
2020-08-27 08:10:21 +02:00
#include <IComponent.h>
2020-09-22 07:30:26 +02:00
#include <IEventSource.h>
2020-08-27 08:10:21 +02:00
#include "GameServerEvents.h"
#include "NetCommon.h"
// {B2D67EE7-8063-488F-B3B9-E7DA675CB752}
2020-09-22 07:30:26 +02:00
inline const GUID IID_IGameServer = { 0xb2d67ee7, 0x8063, 0x488f, 0xb3, 0xb9, 0xe7, 0xda, 0x67, 0x5c, 0xb7, 0x52 };
2020-08-27 08:10:21 +02:00
/// <summary>
/// Defines an API for communicating with the game server.
/// </summary>
2020-09-22 07:30:26 +02:00
struct IGameServer : IComponent, 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>
virtual void STDMETHODCALLTYPE SendChatMessage(const tstring_view& message, ChatColor color, int 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>
/// <returns></returns>
2020-08-27 08:10:21 +02:00
virtual void STDMETHODCALLTYPE BanPlayer(int index) = 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>
/// <returns></returns>
2020-08-27 08:10:21 +02:00
virtual void STDMETHODCALLTYPE KickPlayer(int index, KickReason reason) = 0;
/// <summary>
/// Gets player data for the specified index.
/// </summary>
/// <param name="index">The zero-based player index.</param>
/// <throws>std::out_of_range</throws>
virtual const std::shared_ptr<PlayerInfo> STDMETHODCALLTYPE GetPlayer(int index) const = 0;
2020-08-27 08:10:21 +02:00
/// <summary>
/// Gets data for all players in the current game.
/// </summary>
virtual std::vector<std::shared_ptr<PlayerInfo>> STDMETHODCALLTYPE 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>
2020-08-27 08:10:21 +02:00
virtual void STDMETHODCALLTYPE ChangeGameOption(GameOption option) = 0;
/// <summary>
/// Gets details for the current game.
/// </summary>
virtual const std::shared_ptr<NetGameDetails> STDMETHODCALLTYPE GetGameDetails() const = 0;
/// <summary>
/// Modifies the settings for the current game.
/// </summary>
/// <param name="gameDetails">The game details.</param>
virtual void STDMETHODCALLTYPE ChangeGameDetails(const NetGameDetails& gameDetails) = 0;
2020-08-27 08:10:21 +02:00
};
struct DECLSPEC_UUID("{B2D67EE7-8063-488F-B3B9-E7DA675CB752}") IGameServer;