LEAP Documentation 40220
Documentation for the LEAP project
MainMenuGameMode.h
Go to the documentation of this file.
1// Copyright Blue Isle Studios Inc 2018. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "PlayerStats.h"
8#include "GameFramework/GameModeBase.h"
9#include "MainMenuGameMode.generated.h"
10
11DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnStatsLoadedSignature);
13DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnProgressionDataLoadedSignature);
14DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FMeshUpdatedSignature, TSoftObjectPtr<USkeletalMesh>, Mesh);
15DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FPurchaseResponseSignature, AActor*, Item, bool, bSuccess);
16DECLARE_DYNAMIC_MULTICAST_DELEGATE(FPurchaseRequestSignature);
17
18class UWeaponInstance;
20class AGameSession;
21
22USTRUCT(BlueprintType)
24{
25 GENERATED_BODY()
27
28 int32 NumberOfVisits = 0;
29 bool bFavourited = false;
30
31 bool bSynced = false;
32};
33
34USTRUCT(BlueprintType)
36{
37 GENERATED_BODY()
38 TMap<FString, FSavedServerInfo> Servers = TMap<FString,FSavedServerInfo>();
39
40 bool bSynced = false;
41};
42
43UCLASS()
44class PROJECTX_API AMainMenuGameMode : public AGameModeBase
45{
46 GENERATED_BODY()
47
48protected:
49 virtual void PostLogin(APlayerController * NewPlayer) override;
50
51 TMap<FString,TSubclassOf<UWeaponInstance>> WeaponClasses;
52 TMap<FString, TSubclassOf<AProjectXCharacter>> PlayerClasses;
53
54 void RequestServerHistoryInfo(std::string cursor = "");
55 void RequestServerHistoryInfoResponse(std::vector<NAKAMA_NAMESPACE::NStorageObject> ServerInfo);
56
57 UFUNCTION()
58 void OnStoreLoaded();
59 UFUNCTION()
60 void OnNakamaManagerInitialized();
61
62 virtual TSubclassOf<AGameSession> GetGameSessionClass() const override;
63
64 UFUNCTION()
65 void OnStoreTimerExpired();
66 UFUNCTION(BlueprintPure, meta = (WorldContext = "WorldContextObject"), Category = PlayerState)
67 static void GetPlayerID(const UObject* WorldContextObject, APlayerState* PlayerState, FString& ID);
68
69public:
70 UFUNCTION(BlueprintPure, Category = ServerInfo)
71 FORCEINLINE bool IsFavouriteServer(const FString& ServerName) const { return ServerHistory.Servers.Contains(ServerName) ? ServerHistory.Servers[ServerName].bFavourited : false; }
72 UFUNCTION(BlueprintPure, Category = ServerInfo)
73 FORCEINLINE bool IsInHistory(const FString& ServerName) const { return ServerHistory.Servers.Contains(ServerName) ? ServerHistory.Servers[ServerName].NumberOfVisits > 0 : false; }
74 void UpdateImage(const FString& ID, EStatClassifier StatType);
75 UFUNCTION(BlueprintPure, Category = PlayerInfo)
76 FORCEINLINE TSubclassOf<UWeaponInstance> GetWeaponClassByName(const FString& WeaponID) const { return WeaponClasses.Contains(WeaponID) ? WeaponClasses[WeaponID] : NULL; }
77 UFUNCTION(BlueprintCallable, Category = PlayerInfo)
78 TSubclassOf<AProjectXCharacter> GetCharacterClassByWeaponName(const FString& WeaponID) const;
79 UFUNCTION(BlueprintCallable, Category = MainMenuGameMod)
80 FText GetClassDisplayText(const FString& ID, EStatClassifier Type);
81 UFUNCTION(BlueprintCallable, Category = MainMenuGameMode)
82 TSoftObjectPtr<USkeletalMesh> GetMesh(const FString& ID, EStatClassifier Type);
83 UFUNCTION(BlueprintCallable)
84 void PurchaseItemRequest(int32 ItemID);
85 UFUNCTION(BlueprintCallable, Category = Server)
86 void ToggleFavouriteServer(const FString& ServerID, bool bFavourited);
87 UFUNCTION(BlueprintCallable, Category = Server)
88 void IncrementServerVisits(const FString& ServerID);
89 UFUNCTION()
90 void OnNakamaConnected();
91 void SaveServerHistoryInfo();
92
93 UPROPERTY(BlueprintAssignable, Category = MainMenuGameMode)
94 FOnStatsLoadedSignature OnDataLoaded;
95 UPROPERTY(BlueprintAssignable, Category = MainMenuGameMode)
96 FMeshUpdatedSignature OnMeshUpdated;
97 UPROPERTY(BlueprintAssignable, Category = MainMenuGameMode)
98 FPurchaseRequestSignature OnPurchaseRequest;
99 UPROPERTY(BlueprintAssignable, Category = MainMenuGameMode)
100 FPurchaseResponseSignature OnPurchaseResponse;
101 UPROPERTY(BlueprintAssignable, Category = MainMenuGameMode)
102 FServerInfoSignature OnServerInfoLoaded;
103
104protected:
105 FString LocalPlayerID;
106 FPlayerServerHistory ServerHistory;
107
108 FTimerHandle DailyTimer;
109 FTimerHandle FeatureTimer;
110};
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FPurchaseResponseSignature, AActor *, Item, bool, bSuccess)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FMeshUpdatedSignature, TSoftObjectPtr< USkeletalMesh >, Mesh)
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnStatsLoadedSignature)
EStatClassifier
Definition: PlayerStats.h:75
Definition: MainMenuGameMode.h:45
TMap< FString, TSubclassOf< UWeaponInstance > > WeaponClasses
Definition: MainMenuGameMode.h:51
TMap< FString, TSubclassOf< AProjectXCharacter > > PlayerClasses
Definition: MainMenuGameMode.h:52
Definition: ProjectXCharacter.h:128
Definition: WeaponInstance.h:220
Definition: MainMenuGameMode.h:36
Definition: MainMenuGameMode.h:24