-
Notifications
You must be signed in to change notification settings - Fork 3
/
StatsEssentialsSubsystem.h
90 lines (77 loc) · 3.76 KB
/
StatsEssentialsSubsystem.h
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// Copyright (c) 2023 AccelByte Inc. All Rights Reserved.
// This is licensed software from AccelByte Inc, for limitations
// and restrictions contact your company contract manager.
#pragma once
#include "CoreMinimal.h"
#include "Core/AssetManager/TutorialModules/TutorialModuleSubsystem.h"
#include "OnlineStatisticInterfaceAccelByte.h"
#include "StatsEssentialsSubsystem.generated.h"
UCLASS()
class ACCELBYTEWARS_API UStatsEssentialsSubsystem : public UTutorialModuleSubsystem
{
GENERATED_BODY()
public:
#pragma region Available stats code list
inline static FString StatsCode_HighestElimination = "unreal-highestscore-elimination";
inline static FString StatsCode_HighestTeamDeathMatch = "unreal-highestscore-teamdeathmatch";
inline static FString StatsCode_HighestSinglePlayer = "unreal-highestscore-singleplayer";
inline static FString StatsCode_KillCount = "unreal-killcount";
#pragma endregion
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
/**
* @brief Update users stats
* @param LocalUserNum LocalUserNum to determine who's credential is going to be used for the API call
* @param UpdatedUsersStats User stats to be updated
* @param OnCompleteClient Call upon completion if current instance is not a dedicated server
* @param OnCompleteServer Call upon completion if current instance is a dedicated server
* @return True if Async Task started successfully, false if task already running
*/
bool UpdateUsersStats(
const int32 LocalUserNum,
const TArray<FOnlineStatsUserUpdatedStats>& UpdatedUsersStats,
const FOnlineStatsUpdateStatsComplete& OnCompleteClient = {},
const FOnUpdateMultipleUserStatItemsComplete& OnCompleteServer = {});
/**
* @brief Query local user's stats
* @param LocalUserNum LocalUserNum to determine who's credential is going to be used for the API call and who's stats to be retrieved
* @param StatNames Stats code to be retrieved. Set empty array to retrieve all of the user's stats
* @param OnComplete Call upon completion
* @return True if Async Task started successfully, false if task already running
*/
bool QueryLocalUserStats(
const int32 LocalUserNum,
const TArray<FString>& StatNames,
const FOnlineStatsQueryUsersStatsComplete& OnComplete);
/**
* @brief Query users's stats
* @param LocalUserNum LocalUserNum to determine who's credential is going to be used for the API call
* @param StatsUsers Users who's stats to be retrieved
* @param StatNames Stats code to be retrieved. Set empty array to retrieve all of the user's stats
* @param OnComplete Call upon completion
* @return True if Async Task started successfully, false if task already running
*/
bool QueryUserStats(
const int32 LocalUserNum,
const TArray<FUniqueNetIdRef>& StatsUsers,
const TArray<FString>& StatNames,
const FOnlineStatsQueryUsersStatsComplete& OnComplete);
/**
* @brief Reset all connected users stats value to 0
* @param LocalUserNum LocalUserNum to determine who's credential is going to be used for the API call
* @param OnCompleteClient Call upon completion if current instance is not a dedicated server
* @param OnCompleteServer Call upon completion if current instance is a dedicated server
* @return True if Async Task started successfully, false if task already running
*/
bool ResetConnectedUsersStats(
const int32 LocalUserNum,
const FOnlineStatsUpdateStatsComplete& OnCompleteClient = {},
const FOnUpdateMultipleUserStatItemsComplete& OnCompleteServer = {});
private:
UFUNCTION()
void UpdatePlayersStatOnGameEnds();
IOnlineIdentityPtr IdentityPtr;
FOnlineStatisticAccelBytePtr ABStatsPtr;
FOnlineStatsQueryUsersStatsComplete OnQueryUsersStatsComplete;
FOnlineStatsUpdateStatsComplete OnUpdateStatsComplete;
FOnUpdateMultipleUserStatItemsComplete OnServerUpdateStatsComplete;
};