-
Notifications
You must be signed in to change notification settings - Fork 3
/
MatchSessionP2PServerSubsystem_Starter.cpp
69 lines (56 loc) · 1.78 KB
/
MatchSessionP2PServerSubsystem_Starter.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright (c) 2023 AccelByte Inc. All Rights Reserved.
// This is licensed software from AccelByte Inc, for limitations
// and restrictions contact your company contract manager.
#include "MatchSessionP2PServerSubsystem_Starter.h"
#include "MatchSessionP2PLog.h"
#include "Core/GameModes/AccelByteWarsGameMode.h"
#include "Core/Player/AccelByteWarsPlayerState.h"
#pragma region "Game specific"
void UMatchSessionP2PServerSubsystem_Starter::OnAuthenticatePlayerComplete_PrePlayerSetup(
APlayerController* PlayerController)
{
Super::OnAuthenticatePlayerComplete_PrePlayerSetup(PlayerController);
// get GameMode
AGameModeBase* GameMode = GetWorld()->GetAuthGameMode();
if (!ensure(GameMode))
{
return;
}
const AAccelByteWarsGameMode* AbGameMode = Cast<AAccelByteWarsGameMode>(GameMode);
if (!ensure(AbGameMode))
{
return;
}
// get PlayerState
APlayerState* PlayerState = PlayerController->PlayerState;
if (!ensure(PlayerState))
{
return;
}
AAccelByteWarsPlayerState* AbPlayerState = Cast<AAccelByteWarsPlayerState>(PlayerState);
if (!ensure(AbPlayerState))
{
return;
}
AbGameMode->AssignTeamManually(AbPlayerState->TeamId);
}
#pragma endregion
void UMatchSessionP2PServerSubsystem_Starter::Initialize(FSubsystemCollectionBase& Collection)
{
Super::Initialize(Collection);
UOnlineSession* BaseOnlineSession = GetWorld()->GetGameInstance()->GetOnlineSession();
if (!ensure(BaseOnlineSession))
{
return;
}
OnlineSession = Cast<UMatchSessionP2POnlineSession>(BaseOnlineSession);
// TODO: Add your delegate setup here
}
void UMatchSessionP2PServerSubsystem_Starter::Deinitialize()
{
Super::Deinitialize();
// TODO: Add your delegate cleanup here
}
#pragma region "Matchmaking with P2P implementations"
// TODO: Add your module implementations here.
#pragma endregion