Add GameLift matchmaking backfill server support (#4622)

* Add GameLift matchmaking backfill server support

Signed-off-by: onecent1101 <liug@amazon.com>
This commit is contained in:
Vincent Liu
2021-10-13 16:59:37 -07:00
committed by GitHub
parent 2474ffc5a1
commit 6823ea2274
25 changed files with 1194 additions and 92 deletions
@@ -0,0 +1,44 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <AzCore/RTTI/BehaviorContext.h>
#include <AzCore/std/containers/unordered_map.h>
#include <AzCore/std/string/string.h>
namespace AWSGameLift
{
//! AWSGameLiftPlayer
//! Information on each player to be matched
//! This information must include a player ID, and may contain player attributes and latency data to be used in the matchmaking process
//! After a successful match, Player objects contain the name of the team the player is assigned to
struct AWSGameLiftPlayer
{
AZ_RTTI(AWSGameLiftPlayer, "{B62C118E-C55D-4903-8ECB-E58E8CA613C4}");
static void Reflect(AZ::ReflectContext* context);
AWSGameLiftPlayer() = default;
virtual ~AWSGameLiftPlayer() = default;
// A map of region names to latencies in millseconds, that indicates
// the amount of latency that a player experiences when connected to AWS Regions
AZStd::unordered_map<AZStd::string, int> m_latencyInMs;
// A collection of key:value pairs containing player information for use in matchmaking
// Player attribute keys must match the playerAttributes used in a matchmaking rule set
// Example: {"skill": "{\"N\": 23}", "gameMode": "{\"S\": \"deathmatch\"}"}
AZStd::unordered_map<AZStd::string, AZStd::string> m_playerAttributes;
// A unique identifier for a player
AZStd::string m_playerId;
// Name of the team that the player is assigned to in a match
AZStd::string m_team;
};
} // namespace AWSGameLift
@@ -0,0 +1,58 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AWSGameLiftPlayer.h>
namespace AWSGameLift
{
void AWSGameLiftPlayer::Reflect(AZ::ReflectContext* context)
{
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<AWSGameLiftPlayer>()
->Version(0)
->Field("latencyInMs", &AWSGameLiftPlayer::m_latencyInMs)
->Field("playerAttributes", &AWSGameLiftPlayer::m_playerAttributes)
->Field("playerId", &AWSGameLiftPlayer::m_playerId)
->Field("team", &AWSGameLiftPlayer::m_team);
if (AZ::EditContext* editContext = serializeContext->GetEditContext())
{
editContext->Class<AWSGameLiftPlayer>("AWSGameLiftPlayer", "")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
->DataElement(
AZ::Edit::UIHandlers::Default, &AWSGameLiftPlayer::m_latencyInMs, "LatencyInMs",
"A set of values, expressed in milliseconds, that indicates the amount of latency that"
"a player experiences when connected to AWS Regions")
->DataElement(
AZ::Edit::UIHandlers::Default, &AWSGameLiftPlayer::m_playerAttributes, "PlayerAttributes",
"A collection of key:value pairs containing player information for use in matchmaking")
->DataElement(
AZ::Edit::UIHandlers::Default, &AWSGameLiftPlayer::m_playerId, "PlayerId",
"A unique identifier for a player")
->DataElement(
AZ::Edit::UIHandlers::Default, &AWSGameLiftPlayer::m_team, "Team",
"Name of the team that the player is assigned to in a match");
}
}
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
{
behaviorContext->Class<AWSGameLiftPlayer>("AWSGameLiftPlayer")
->Attribute(AZ::Script::Attributes::Storage, AZ::Script::Attributes::StorageType::Value)
->Property("LatencyInMs", BehaviorValueProperty(&AWSGameLiftPlayer::m_latencyInMs))
->Property("PlayerAttributes", BehaviorValueProperty(&AWSGameLiftPlayer::m_playerAttributes))
->Property("PlayerId", BehaviorValueProperty(&AWSGameLiftPlayer::m_playerId))
->Property("Team", BehaviorValueProperty(&AWSGameLiftPlayer::m_team));
}
}
} // namespace AWSGameLift