LEAP Documentation 40220
Documentation for the LEAP project
ProjectXPlayerState.h
Go to the documentation of this file.
1// Copyright Blue Isle Studios Inc 2017. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "Engine.h"
7#include "GameFramework/GameState.h"
8#include "GameFramework/PlayerState.h"
9#include "ProjectX.h"
10#include "OwnedInterface.h"
11#include "ReactsToMatchEvents.h"
12#include "PlayerStats.h"
13#include "PlayerStructs.h"
14#include "ProjectXSaveGame.h"
15#include "CosmeticsManager.h"
17#include "TeamInterface.h"
19
20#include "ProjectXPlayerState.generated.h"
21
22class UWeaponInstance;
23class UPlayerClass;
24class UGlobalAmmoComponent;
28class UMaterial;
31class ADeployable;
32class UTelekenesisComponent;
33class APickup;
35class UAfflictionComponent;
36
37USTRUCT()
39{
40 GENERATED_USTRUCT_BODY()
41
42public:
44 {
45 Weapon = NULL;
46 ProjectileClass = NULL;
47 Origin = FVector_NetQuantize(0, 0, 0);
48 NumUses = 1;
49 DamageModifier = 1.0f;
50 }
51
52 FAuthWeaponTicket(TSubclassOf<class UWeaponInstanceRanged> InWeapon, TSubclassOf<class AActor> InProjectileClass, const FVector_NetQuantize InOrigin, int8 InNumUses, float InDamageModifier)
53 {
54 Weapon = InWeapon;
55 ProjectileClass = InProjectileClass;
56 Origin = InOrigin;
57 NumUses = InNumUses;
58 DamageModifier = InDamageModifier;
59 }
60
61public:
62 UPROPERTY()
63 TSubclassOf<class UWeaponInstanceRanged> Weapon = NULL;
64 //Projectile that was spawned from this ticket.
65 UPROPERTY()
66 TSubclassOf<class AProjectile> ProjectileClass = NULL;
67 //The origin of the projectile spawned by this ticket.
68 UPROPERTY()
69 FVector_NetQuantize Origin = FVector_NetQuantize(0, 0, 0);
70 //How many times can this ticket be used before its expired.
71 UPROPERTY()
72 int8 NumUses = 1;
73 UPROPERTY()
74 float DamageModifier = 1.0f;
75};
76
77USTRUCT(Blueprintable)
79{
80 GENERATED_USTRUCT_BODY()
81
82public:
84 {
85 PlayerClass = NULL;
86 TimeUsed = 0.f;
87 Spawned = 0;
88 }
89
90 FPlayerClassUsage(TSubclassOf<AProjectXCharacter> InPlayerClass)
91 {
92 PlayerClass = InPlayerClass;
93 TimeUsed = 0.f;
94 Spawned = 0;
95 }
96
97public:
98 UPROPERTY()
99 TSubclassOf<AProjectXCharacter> PlayerClass = NULL;
100 //Amount of time this player was alive as this class.
101 UPROPERTY()
102 float TimeUsed = 0.f;
103 //How many times a player has spawned as this class.
104 UPROPERTY()
105 uint16 Spawned = 0;
106
107 bool operator<(const FPlayerClassUsage& Other) const
108 {
109 return TimeUsed > Other.TimeUsed;
110 }
111
112public:
114};
115
116UENUM(BlueprintType)
117enum class EMessageType : uint8
118{
119 Admin = 0,
120 Server = 1,
121 Global = 2,
122 Team = 3,
123 Squad = 4,
124 Whisper = 5,
127 TeamHeal = 8,
128 TeamRepair = 9,
129 SquadPing = 10,
130 None = 255
131};
132
133USTRUCT(Blueprintable)
135{
136 GENERATED_USTRUCT_BODY()
138 {
139 GraffitiMaterial = NULL;
140 Border = NULL;
141 Banner = NULL;
142 }
143public:
144 UPROPERTY(BlueprintReadOnly)
145 UMaterialInstance* GraffitiMaterial = NULL;
146 UPROPERTY(BlueprintReadOnly)
147 UMaterialInstance* Border = NULL;
148 UPROPERTY(BlueprintReadOnly)
149 UMaterialInstance* Banner= NULL;
150};
151
152USTRUCT(Blueprintable)
154{
155 GENERATED_USTRUCT_BODY()
156
157public:
158
159 UPROPERTY(BlueprintReadOnly, Category = "Message")
160 AProjectXPlayerState* SendingPlayerState = nullptr;
161
162 UPROPERTY(BlueprintReadOnly, Category = "Message")
164
165 UPROPERTY(BlueprintReadOnly, Category = "Message")
166 TWeakObjectPtr<AActor> SquadOrderActor = nullptr;
167};
168
169
170USTRUCT(Blueprintable)
172{
173 GENERATED_USTRUCT_BODY()
174
175public:
176 UPROPERTY(BlueprintReadOnly, Category = "Squad")
177 TWeakObjectPtr<AActor> SquadOrderActor = nullptr;
178
179 UPROPERTY(BlueprintReadOnly, Category = "Squad")
181
182 void Reset()
183 {
184 SquadOrderActor = nullptr;
185 SquadOrder = EMessageType::None;
186 }
187
188 bool IsValid()
189 {
190 if (SquadOrderActor.IsValid() || SquadOrder == EMessageType::None)
191 {
192 return false;
193 }
194
195 return true;
196 }
197};
198
199USTRUCT()
201{
202 GENERATED_USTRUCT_BODY()
203
204public:
205 uint16 NumTimesKilledByPlayer = 0;
206 uint16 NumTimesKilledPlayer = 0;
207};
208
209DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FXPChangedSignature, float, XP, float, Delta);
210DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FScoreChangedSignature, float, Score);
211DECLARE_DYNAMIC_MULTICAST_DELEGATE(FPlayerLevelChangedSignature);
212DECLARE_DYNAMIC_MULTICAST_DELEGATE(FPlayerStatsChangedSignature);
213DECLARE_DYNAMIC_MULTICAST_DELEGATE(FPlayerStateObjectChangedSignature);
214DECLARE_DYNAMIC_MULTICAST_DELEGATE(FPLayerStateReadyChangedSignature);
217
219DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FPlayerCurrencyGainedSignature, float, Delta);
220DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FExperienceEventSignature, const UExperienceEvent*,Event, const int, Value, const APlayerState*, B);
221DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FClassEventSignature, TSubclassOf<AProjectXCharacter>, PlayerClass);
222DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FPlayerChangedTeamSignature, AProjectXPlayerState*, PlayerState, uint8, Team);
223DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FSpawnTargetChangedSignature, TScriptInterface<ISpawnTargetInterface>, SpawnTarget);
224DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FTeamChangeCoolDownSignature, float, Duration);
225DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FReviveTimerReceived, float, ReviveStartTime);
226DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FAvatarUpdatedSignature, UTexture2D*, Avatar);
227DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FCurrencyChangedSignature, int32, NewCurrency, int32, Delta);
228DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FMessageReceivedSignature, const FString&, Message, AProjectXPlayerState*, Sender, const EMessageType, MessageType);
229DECLARE_DELEGATE_OneParam(FDelegateMaterialInstanceSignature, UMaterialInstance*);
231DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FQuickChatMessageReceivedSignature, const FQuickChatInfo&, QuickChatData);
232DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnCosmeticsUpdatedSignature, const FString&, PlayerID);
233DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FOnEquipsUpdatedSignature, ECosmeticType, Type, const FString&, ShortCode, const FString&, EquipCode);
234
235
236UCLASS()
237class PROJECTX_API AProjectXPlayerState : public APlayerState, public IOwnedInterface, public IReactsToMatchEvents, public ITeamInterface
238{
239 GENERATED_UCLASS_BODY()
240
241public:
242 bool operator>(const AProjectXPlayerState& Other) const
243 {
244 if (GetXP() != Other.GetXP())
245 {
246 return GetXP() > Other.GetXP();
247 }
248
249 if (GetEliminations() != Other.GetEliminations())
250 {
251 return GetKills() > Other.GetKills();
252 }
253
254 if (GetDeaths() != Other.GetDeaths())
255 {
256 return GetDeaths() < Other.GetDeaths();
257 }
258
259 if (GetUnpackedPing() != Other.GetUnpackedPing())
260 {
261 return GetUnpackedPing() > Other.GetUnpackedPing();
262 }
263
264 return true;
265 }
266
267//~ Begin AActor Interface
268public:
269 virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
270 virtual void BeginPlay() override;
271//~ End AActor Interface
272
273//~ Begin APlayerState Interface
274protected:
275 virtual void OverrideWith(APlayerState* PlayerState) override;
276 virtual void CopyProperties(APlayerState* PlayerState) override;
277//~ End APlayerState Interface
278
279//~ Begin IReactsToMatchEvents Interface
280public:
281 virtual APlayerState* GetOwnedPlayerState() const override;
282//~ End IReactsToMatchEvents Interface
283
284//~ Begin IReactsToMatchEvents Interface
285public:
286 virtual void MatchEnded() override;
287//~ End IReactsToMatchEvents Interface
288
289public:
290 void InitStat();
291 std::string GetNakamaUserId() const;
292 const FString& GetNakamaUserIdAsString() const { return NakamaUserId; }
293 bool IsNakamaUserIdValid() const;
294
295 UFUNCTION()
296 int32 SetTeam(int32 NewTeam) override;
297 //Added assert to check for any potential getters checking this before we've assigned a team.
298 FORCEINLINE virtual int32 GetTeam() const override { return Team; }
299
300 UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category = PlayerState)
301 virtual void ModifyLevel(int32 Delta);
302 UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category = PlayerState)
303 virtual void ModifyKills(AProjectXPlayerState* Killed, TSubclassOf<class UProjectXDamageType> DamageType);
304 UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category = PlayerState)
305 virtual void ModifyDeployablesDestructed(ADeployable* DeployableDestructed, TSubclassOf<class UProjectXDamageType> DamageType);
306 UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category = PlayerState)
307 virtual void ModifyDeaths(int32 Delta, AProjectXPlayerState* KillerState);
308 UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category = PlayerState)
309 virtual void ModifyAssists(int32 Delta, APlayerState* PlayerState, float MaxHealth, float Damage);
310 UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category = PlayerState)
311 virtual void ModifyTeamKills(int32 Delta);
312 UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category = PlayerState)
313 virtual void ModifyXP(EXPEventType Type, APlayerState* TargetState, UObject* Object,float Alpha = 1.0f, const TSubclassOf<UExperienceEvent> ExpereienceEventOverride = NULL);
314 UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category = PlayerState)
315 virtual void ModifyUltimateCharge(int32 Delta);
316 /* Since the revive beacon is only tracked on the owning version of the PS, this gives the opportunity for external simulated proxies to broadcast the revive time to the PlayerState if they know it */
317 UFUNCTION(BlueprintCallable, Category = PlayerState)
318 virtual void BroadcastReviveTimeReceived(float ReviveStartTime);
319 void ModifyCurrency(int32 Delta);
320 UFUNCTION(BlueprintCallable, Category = PlayerState)
321 virtual void SendQuickChat(AProjectXPlayerState* const To, const FString& Message, const EMessageType MessageType, AActor* const SquadOrderActor);
322 UFUNCTION(BlueprintCallable)
323 virtual bool GetIsSpawningOnReviveBeacon() const;
324 UFUNCTION(Server, Reliable)
325 virtual void Server_SendQuickChat(const FQuickChatInfo& QuickChatData);
326 UFUNCTION(Client, Reliable)
327 virtual void Client_SendQuickChat(const FQuickChatInfo& QuickChatData);
328 UFUNCTION(Client, Reliable)
329 virtual void Client_RequestSpawnTarget();
330 UFUNCTION(BlueprintCallable, Category = PlayerState)
331 virtual void SendMessage(const FString& Message, AProjectXPlayerState* const To, const EMessageType MessageType);
332 UFUNCTION(Server, Reliable)
333 virtual void Server_SendMessage(const FString& Message, AProjectXPlayerState* To, const EMessageType MessageType);
334 UFUNCTION(BlueprintCallable, Client, Reliable)
335 virtual void Client_SendMessage(const FString& Message, AProjectXPlayerState* To, const EMessageType MessageType);
336 UFUNCTION(Client, Reliable)
337 virtual void Client_Reliable_UpdateExperienceGains(const FPlayerProgressionUpdates& NewExperienceGains);
338
339 virtual bool IsValidMessage(const FString& Message, const bool bDisplayErrors = false);
340 virtual FString FormatMessage(const FString& Message);
341 virtual FString FilterMatureLanaguage(const FString& SourceString);
342 virtual void DecrementChatSpamMessageCount();
343
344 UFUNCTION(Server, Reliable)
345 virtual void Server_PickupItem(int32 PickUpID, AActor* OverlappedActor);
346
347 void SpawnWorldPickup(TSubclassOf<APickup> PickupClass, const FVector SpawnLocation, const FVector ExpectedLandingPosition);
348
349 UFUNCTION(NetMulticast, Reliable)
350 void MultiCast_PickupSpawned(const FWorldPickupInfo& PickUpInfo);
351
352 UFUNCTION(NetMulticast, Reliable)
353 void MultiCast_DestroyPickup(int32 PickupID);
354
355 UFUNCTION(NetMulticast, Reliable)
356 void MultiCast_SpawnContextObject(const FVector_NetQuantize SpawnLocation, AProjectXPlayerState* SendingPlayerState);
357
358 UFUNCTION(BlueprintPure, Category = PlayerState)
359 FORCEINLINE int32 GetUnpackedPing() const { return GetPing() * 4; }
360 UFUNCTION(BlueprintPure, Category = PlayerState)
361 FORCEINLINE FString GetPingString() const { return FString::FromInt(GetUnpackedPing()); }
362
363 UFUNCTION(BlueprintPure, Category = PlayerState)
364 FORCEINLINE int32 GetLevel() const { return Level; }
365 UFUNCTION(BlueprintPure, Category = PlayerState)
366 FORCEINLINE FString GetLevelString() const { return FString::FromInt(GetLevel()); }
367
368 UFUNCTION(BlueprintPure, Category = PlayerState)
369 FORCEINLINE int32 GetEliminations() const { return Kills + Assists; }
370 UFUNCTION(BlueprintPure, Category = PlayerState)
371 FORCEINLINE FString GetEliminationsString() const { return FString::FromInt(GetEliminations()); }
372 UFUNCTION(BlueprintPure, Category = PlayerState)
373 FORCEINLINE int32 GetKills() const { return Kills; }
374 UFUNCTION(BlueprintPure, Category = PlayerState)
375 FORCEINLINE FString GetKillsString() const { return FString::FromInt(GetKills()); }
376
377 UFUNCTION(BlueprintPure, Category = PlayerState)
378 FORCEINLINE int32 GetDeaths() const { return Deaths; }
379 UFUNCTION(BlueprintPure, Category = PlayerState)
380 FORCEINLINE FString GetDeathsString() const { return FString::FromInt(GetDeaths()); }
381
382 UFUNCTION(BlueprintPure, Category = PlayerState)
383 FORCEINLINE int32 GetAssists() const { return Assists; }
384 UFUNCTION(BlueprintPure, Category = PlayerState)
385 FORCEINLINE FString GetAssistsString() const { return FString::FromInt(GetAssists()); }
386
387 UFUNCTION(BlueprintPure, Category = PlayerState)
388 FORCEINLINE int32 GetTeamKills() const { return TeamKills; }
389 UFUNCTION(BlueprintPure, Category = PlayerState)
390 FORCEINLINE FString GetTeamKillsString() const { return FString::FromInt(GetTeamKills()); }
391 UFUNCTION(BlueprintPure, Category = PlayerState)
392 FORCEINLINE bool IsReady()const {return bReady;}
393 UFUNCTION(BlueprintPure, Category = PlayerState)
394 FORCEINLINE float GetXP() const { return GameXP; }
395
396 /* Returns only the accumulated XP gains from contractor bonuses applied during the match*/
397 UFUNCTION(BlueprintPure, Category = PlayerState)
398 FORCEINLINE float GetGameXPFromMultiplier() const { return GameXPFromMultiplier; }
399 UFUNCTION(BlueprintPure, Category = PlayerState)
400 FORCEINLINE FString GetXPString() const { return FString::FromInt(int32(GetXP())); }
401 UFUNCTION(BlueprintPure, Category = PlayerState)
402 FORCEINLINE bool IsMatchBonusAvailable() const {return bMatchBonusIsAvailable;}
403 UFUNCTION(BlueprintPure, Category = PlayerState)
404 FORCEINLINE bool IsTeamChangeOnCoolDown() const { return !bCanChangeTeam; }
405 UFUNCTION(BlueprintPure, Category = PlayerState)
406 FORCEINLINE int GetUltimateCharge() const { return UltimateCharge; }
407 UFUNCTION(BlueprintPure, Category = PlayerState)
408 FORCEINLINE FString GetUltimateChargeString() const { return FString::FromInt(UltimateCharge); }
409 UFUNCTION(BlueprintPure, Category = PlayerState)
410 FORCEINLINE bool IsUltimateCharged() const {return UltimateCharge >= MaxUltimateCharge;}
411 UFUNCTION(BlueprintPure, Category = PlayerState)
412 FORCEINLINE int GetMaxUltimateCharge() const {return MaxUltimateCharge;}
413 UFUNCTION(BlueprintPure, Category = PlayerState)
414 const FPlayerProgressionUpdates& GetPlayerProgression() const {return PlayerProgressionUpdates; }
415 UFUNCTION(BlueprintPure, Category = PlayerState)
416 const FEquips& GetPlayerEquips() const;
417 const FGeneralEquips& GetGeneralEquips() const { return GeneralEquips; }
418 UFUNCTION(BlueprintPure, Category = PlayerState)
419 float GetExpMulitplier() const{return EXPMultiplier;}
420 virtual void SetExpMultiplier(float NewMultiplier) { EXPMultiplier = NewMultiplier; }
421 void SetMaxUltimateCharge(uint16 NewMaxUltimateCharage) { MaxUltimateCharge = NewMaxUltimateCharage; }
422 FORCEINLINE TWeakObjectPtr<ADecalActor> GetGraffiti() const { return Graffiti; }
423 void UpdateGraffiti(TWeakObjectPtr<ADecalActor> NewGraffiti) { Graffiti = NewGraffiti; }
424 UFUNCTION(BlueprintPure, Category = PlayerState)
425 bool IsLocalPlayerState() const;
426 UFUNCTION(BlueprintPure, Category = PlayerState)
427 virtual FString GetPlayerID() const;
428 UFUNCTION(BlueprintPure, Category = PlayerState)
429 APickupReviveBeacon* GetReviveBeacon() const { return ReviveBeacon.Get(); }
430 UFUNCTION(BlueprintPure, Category = PlayerState)
431 UTexture2D* GetAvatarImage() const { return AvatarReference; }
432 UFUNCTION(BlueprintPure,Category = PlayerState)
433 UAnimMontage* GetTaunt(uint8 TauntNumber) { return TauntMontages.Contains(TauntNumber) ? TauntMontages[TauntNumber] : NULL; }
434 /* NOTE: this should never be directly called - call PlayerController::CanRestartPlayer instead! */
435 UFUNCTION()
436 virtual bool CanRestartPlayer();
437 AProjectXCharacter* GetCharacter() const;
438 UFUNCTION()
439 void OnStatsLoaded();
440 UFUNCTION(BlueprintCallable)
441 void MutePlayerText(APlayerState* Player, bool bToggle);
442
443 UFUNCTION(BlueprintCallable, Category = PlayerState)
444 TSubclassOf<AProjectXCharacter> GetPreferredPlayerClass() const { return PreferredPlayerClass; }
445 UFUNCTION()
446 void SetPreferredPlayerClass(TSubclassOf<AProjectXCharacter> NewPlayerClass);
447
448 UFUNCTION(BlueprintCallable, Category = PlayerState)
449 float GetNextRespawnTime() const { return NextRespawnTime; }
450
451 UFUNCTION(BlueprintCallable, Category = PlayerState)
452 float GetTimeUntilRespawn() const { return (GetWorld() && GetWorld()->GetGameState()) ? FMath::Max(0.f, NextRespawnTime - GetWorld()->GetGameState()->GetServerWorldTimeSeconds()) : MAX_FLT; }
453
454 UFUNCTION()
455 void SetNextRespawnTime(float NewRespawnTime);
456
457 /* Called via AProjectXPlayerState::SetPawn, destroys all the deployables this player's new player class cannot make */
458 UFUNCTION()
459 virtual void DestroyInvalidDeployables(bool bForce = false);
460
461 UFUNCTION()
462 virtual void UpdatePlayerPerkUsage(APawn* InPawn);
463
464 UFUNCTION()
465 void OnEquipsLoaded(bool bSuccess);
466 void LoadMatchBonusAvailable();
467
468 UFUNCTION(BlueprintCallable, Category = PlayerState)
469 virtual FPlayerClassUsage& GetClassUsageByClass(TSubclassOf<AProjectXCharacter> PlayerClass);
470 UFUNCTION(BlueprintCallable, Category = PlayerState)
471 virtual FPlayerClassUsage& GetMostUsedClass();
472
473 const UPlayerProgressionManager* GetPlayerProgressionCDO() const;
474
475 UFUNCTION(BlueprintCallable, Category = PlayerState)
476 FORCEINLINE UGlobalAmmoComponent* GetGlobalAmmoComponent() const { return GlobalAmmoComponent; }
477
478 /* Adds authenticated ticket to this player's list. Returns true if a ticket was found. */
479 virtual bool AddAuthenticatedTicket(const int32 TicketID, const FAuthWeaponTicket& Ticket);
480 /* Consumes a use of an authenticated ticket. Returns true if successfully found a ticket. */
481 virtual bool ConsumeAuthenticatedTicket(const int32 TicketID, TSubclassOf<class UWeaponInstanceRanged> Weapon, TSubclassOf<AProjectile>& ProjectileClass, float& DamageModifier);
482 /* Invalidates a ticket. */
483 virtual void OnTicketExpired(const int32 TicketID);
484
485 UFUNCTION(Server, Reliable)
486 void Server_ProcessProjectileHit(const uint8 ShotID, const int32& ProjectileID, const FHitResult& HitResult, TSubclassOf<class UWeaponInstanceRanged> Weapon, const TArray<FVector_NetQuantize>& FlightPath, UTelekenesisComponent* TelekenesisComponent = nullptr, const FRotator& CustomRotation = FRotator::ZeroRotator);
487
488 UFUNCTION(Server, Reliable)
489 void Server_ProcessExplosiveProjectileHit(const int32& ProjectileID, const FHitResult& HitResult, TSubclassOf<class UWeaponInstanceRanged> Weapon, const TArray<FVector_NetQuantize>& FlightPath, const TArray<AActor*>& RadialDamagedActors);
490 static float ValidateFlightPath(UObject* const WorldContextObject, const TArray<FVector_NetQuantize>& FlightPath, AActor* HitActor = NULL);
491 static float GetFlightPathDistance(const TArray<FVector_NetQuantize>& FlightPath);
492
493 UFUNCTION(BlueprintCallable, Category = PlayerState)
494 static void SortPlayerStates(const TArray<AProjectXPlayerState*>& InPlayerStateList, TArray<AProjectXPlayerState*>& OutPlayerStateList);
495
496 UFUNCTION(BlueprintPure, Category = PlayerState, meta = (WorldContext = "WorldContextObject", CallableWithoutWorldContext))
497 static APlayerState* GetPlayerStateByName(const UObject* WorldContextObject, const FString& Name);
498
499 UFUNCTION(BlueprintPure, Category = PlayerState, meta = (WorldContext = "WorldContextObject", CallableWithoutWorldContext))
500 static AProjectXPlayerState* GetPlayerStateByID(const UObject* WorldContextObject, const FString& ID);
501
502 //Not to be confused with AProjectXPlayerState::GetPlayerStateByID!
503 UFUNCTION(BlueprintPure, Category = PlayerState, meta = (WorldContext = "WorldContextObject", CallableWithoutWorldContext))
504 static AProjectXPlayerState* GetPlayerStateByPlayerID(const UObject* WorldContextObject, int32 ID);
505 UFUNCTION(BlueprintPure, Category = PlayerState, meta = (WorldContext = "WorldContextObject", CallableWithoutWorldContext))
506 static AProjectXPlayerState* GetPlayerStateByNakamaPlayerID(const UObject* WorldContextObject, const FString& ID);
507
508 UFUNCTION(BlueprintPure, Category = ClassUsage)
509 static TSubclassOf<AProjectXCharacter> GetClassFromUsage(const FPlayerClassUsage& ClassUsage) { return ClassUsage.PlayerClass; }
510 UFUNCTION(BlueprintPure, Category = ClassUsage)
511 static float GetTimeFromUsage(const FPlayerClassUsage& ClassUsage) { return ClassUsage.TimeUsed; }
512 UFUNCTION(BlueprintPure, Category = ClassUsage)
513 static int32 GetSpawnCountFromUsage(const FPlayerClassUsage& ClassUsage) { return ClassUsage.Spawned; }
514 UFUNCTION(BlueprintPure, Category = "Base Control")
515 virtual TScriptInterface<ISpawnTargetInterface> GetSpawnTarget() const;
516 UFUNCTION(BlueprintPure, Category = "Base Control")
517 virtual bool HasSpawnTarget() const;
518 UFUNCTION(BlueprintPure,Category = Loadouts)
519 bool HasLoadedCosmetics() const {return bLoadedCosmetics;}
520
521 UFUNCTION(BlueprintCallable,Category = "Player")
522 bool GetKillExplosion(TSoftObjectPtr<UParticleSystem>& Particle, TSoftObjectPtr<USoundCue>& Sound);
523
524 virtual void SetSpawnTarget(TScriptInterface<ISpawnTargetInterface> NewSpawnTarget);
525
526 virtual void StartTeamChangeCoolDown();
527
528 UFUNCTION(BlueprintPure)
529 float GetTeamSwitchingCoolDownRemaining() const;
530
531 void SetAvatar(UTexture2D* NewAvatar);
532 UFUNCTION(BlueprintCallable)
533 void PlayTaunt(uint8 TauntID);
534 UFUNCTION()
535 void OnItemEquipped(ECosmeticType Type, const FString& ShortCode, const FString& EquipCode);
536 UFUNCTION(Server,Reliable,WithValidation)
537 void Server_Reliable_UpdateSessionLockedCosmetics(uint16 CosmeticIDNumber);
538
539 virtual void OnRep_UniqueId() override;
540
541 UFUNCTION()
542 void UpdatePassiveUltimateCharge();
543
544 UFUNCTION()
545 void UpdateKillExplosion(UCosmeticExplosionAsset* CosmeticAsset) { KillExplosionAsset = CosmeticAsset; }
546
547 virtual void AddHealingDone(const float HealedAmount);
548 virtual void AddRepairingDone(const float RepairedAmount, UClass* const TargetClassRepaired);
549 virtual void ActivateHealBufferCheck();
550 virtual void DeactivateHealBufferCheck();
551 virtual void ActivateRepairBufferCheck();
552 virtual void DeactivateRepairBufferCheck();
553 virtual void ToggleReviveBeacon(bool bActivate);
554 UFUNCTION()
555 virtual void UltimateFinished();
556 UFUNCTION()
557 virtual void UltimateStarted(UWeaponInstance* Weapon);
558 virtual void SetReadyStatus(bool bNewReadyStatus);
559 void SetCanChangeTeams(bool bNewCanChangeTeams);
560 void SpawnActorOnProjectileHit(const AProjectile* HitProjectile, const FHitResult& HitResult, const FRotator& CustomRotator = FRotator::ZeroRotator);
561
562 void SetSquadLeader(bool const InSquadLeader);
563
564 void SetCurrentSquadOrder(FSquadOrder const InSquadOrder);
565 FVector GetReviveBeaconSpawnLocation() { return ReviveBeaconSpawnLocation; }
566 UFUNCTION(BlueprintCallable, Category = "Squad")
567 bool IsSquadLeader() { return bSquadLeader; }
568
569 UFUNCTION(BlueprintCallable, Category = "Squad")
570 FSquadOrder GetCurrentSquadOrder() { return CurrentSquadOrder; }
571
572 /*Returns 1 if player is nemesis 2 if they killed their nemesis*/
573 int32 IsPlayerStateNemesis(AProjectXPlayerState* const NemesisPlayerState);
574
575 UFUNCTION(BlueprintCallable, Category = "Spawn")
576 void PlayAnnouncerSpawnSound();
577
578 void ModifyKillsByClass(AProjectXPlayerState* Killed);
579
580 UFUNCTION(Client, Unreliable)
581 void Client_PlayAnnouncer(const FString& VoiceToPlay);
582
583 UFUNCTION(Server, Reliable, WithValidation)
584 void Server_UpdateStat(EStatNames StatToUpdate, int32 Value, UObject* InObject /* = nullptr */, const EStatUpdateBehaviour& StatUpdateBehaviour /* = EStatUpdateBehaviour::NONE */, int32 InDebugMapType /*= 0*/, const FString& InDebugMapName /*= ""*/);
585
586 UFUNCTION(Client, Reliable)
587 void Client_UnlockAchievement(const EAchievementData AchievementToUnlock);
588
589 UFUNCTION(BlueprintCallable, Server, Reliable, WithValidation, Category = "PlayerState")
590 void Server_KickPlayer(AProjectXPlayerState* PlayerToKick);
591
592 UFUNCTION(Client, Reliable)
593 void Client_QueryAchievements();
594
595 float UltChargeMultiplier = 1.0f;
596 static TArray<FString> MessageHistory;
597public:
598 UPROPERTY(BlueprintAssignable, Category = PlayerState)
599 FPlayerStatsChangedSignature OnPlayerStatsChanged;
600 UPROPERTY(BlueprintAssignable, Category = PlayerState)
601 FXPChangedSignature OnXPChanged;
602 UPROPERTY(BlueprintAssignable, Category = PlayerState)
603 FPlayerCurrencyGainedSignature OnUltimateChargeChanged;
604 UPROPERTY(BlueprintAssignable, Category = PlayerState)
605 FXPChangedSignature OnTotalXPChanged;
606 UPROPERTY(BlueprintAssignable, Category = PlayerState)
607 FPlayerCurrencyGainedSignature OnCurrencyGained;
608 UPROPERTY(BlueprintAssignable, Category = PlayerState)
609 FScoreChangedSignature OnPlayerScoreChanged;
610 UPROPERTY(BlueprintAssignable, Category = PlayerState)
611 FPlayerLevelChangedSignature OnPlayerLevelChanged;
612 UPROPERTY(BlueprintAssignable, Category = PlayerState)
613 FExperienceEventSignature OnExpGained;
614 UPROPERTY(BlueprintAssignable, Category = PlayerState)
615 FClassEventSignature OnPlayerClassChanged;
616 UPROPERTY(BlueprintAssignable, Category = PlayerState)
617 FReviveTimerReceived OnReviveTimerReceived;
618 UPROPERTY(BlueprintAssignable, Category = PlayerState)
619 FPlayerStateObjectChangedSignature OnPlayerStateNextRespawnTimeChanged;
620 UPROPERTY(BlueprintAssignable)
621 FPlayerChangedTeamSignature OnPlayerChangedTeam;
622 UPROPERTY(BlueprintAssignable)
623 FSpawnTargetChangedSignature OnSpawnPointChanged;
624 UPROPERTY(BlueprintAssignable)
625 FTeamChangeCoolDownSignature OnTeamChangeCoolDownStart;
626 UPROPERTY(BlueprintAssignable)
627 FTeamChangeCoolDownSignature OnTeamChangeCoolDownFinish;
628 UPROPERTY(BlueprintAssignable)
629 FAvatarUpdatedSignature OnAvatarChangeDelegateEvent;
630 UPROPERTY(BlueprintAssignable, Category = PlayerState)
631 FCurrencyChangedSignature OnCurrencyUpdated;
632 UPROPERTY(BlueprintAssignable)
633 FMessageReceivedSignature OnMessageReceieved;
634 UPROPERTY(BlueprintAssignable)
635 FOnSquadLeaderChanged OnSquadLeaderChanged;
636 UPROPERTY(BlueprintAssignable)
637 FQuickChatMessageReceivedSignature OnQuickChatMessageReceived;
638 UPROPERTY(BlueprintAssignable)
639 FUltimateTriggeredSignature OnUltimateTriggered;
640 UPROPERTY(BlueprintAssignable)
641 FUltimateUsedSignature OnUltimateUsed;
642 UPROPERTY(BlueprintAssignable)
643 FOnCosmeticsUpdatedSignature OnCosmeticsUpdated;
644 UPROPERTY(BlueprintAssignable)
645 FPlayerKillSignature OnPlayerKillEvent;
646 UPROPERTY(BlueprintAssignable)
647 FOnEquipsUpdatedSignature OnEquipsUpdated;
648 UPROPERTY(BlueprintAssignable, Category = PlayerState)
649 FPlayerStatsChangedSignature OnGameXPFromMultiplierReceived;
650 UPROPERTY(BlueprintAssignable, Category = PlayerState)
651 FPLayerStateReadyChangedSignature OnPlayerStateReadyEvent;
652 UPROPERTY(BlueprintAssignable, Category = PlayerState)
653 FPlayerStatsChangedSignature OnPlayerProgressionRewardedEvent;
654
655protected:
656 UFUNCTION()
657 virtual void OnRep_Kills(uint16 LastKills);
658 UFUNCTION()
659 virtual void OnRep_Deaths(uint16 LastDeaths);
660 UFUNCTION()
661 virtual void OnRep_Assists(uint16 LastAssists);
662 virtual void OnRep_Score() override;
663 UFUNCTION()
664 virtual void OnRep_GameXP(uint16 LastXP);
665 UFUNCTION()
666 virtual void OnRep_Level(uint16 PreviousLevel);
667 UFUNCTION()
668 virtual void OnRep_UltimateCharge();
669 UFUNCTION()
670 virtual void OnRep_PlayerClass();
671 UFUNCTION()
672 virtual void OnRep_Team();
673 UFUNCTION()
674 virtual void OnRep_CanSwitchTeams();
675 UFUNCTION()
676 virtual void OnRep_SquadLeader();
677 UFUNCTION()
678 virtual void OnRep_NextRespawnTime();
679 UFUNCTION()
680 virtual void OnRep_Ready();
681 UFUNCTION()
682 virtual void OnPlayerStateRemovedFromGameState(APlayerState* RemovedPlayerState);
683 UFUNCTION()
684 virtual void DoHealBonusXPBufferCheck();
685 UFUNCTION()
686 virtual void DoRepairBonusXPBufferCheck();
687 UFUNCTION(BlueprintCallable)
688 void LoadGeneralCosmetics(ECosmeticType Type, const FEquips& LoadingEquips,const FString& EquipCode);
689 void LoadCosmeticMaterialAsset(TSoftObjectPtr<UMaterialInstance> AssetPointer, FDelegateMaterialInstanceSignature Callback);
690 void LoadPlayerPerk();
691 UFUNCTION(Server, Reliable)
692 void Server_SendNakamaUserId(const FString& InNakamaUserId);
693 UFUNCTION(Server, Reliable)
694 void Server_Reliable_ToggleReviveBeacon(bool bActive);
695 UFUNCTION(Server, Reliable)
696 void Server_Reliable_PlayTaunt(uint8 TauntID);
697 UFUNCTION(NetMulticast,UnReliable)
698 void Multicast_Unreliable_PlayTaunt(uint8 TauntID);
699 UFUNCTION(NetMulticast, Reliable)
700 void Multicast_Reliable_EquipCosmeticItem(ECosmeticType Type, uint16 ShortCodeIndex, uint16 EquipCodeIndex);
701 UFUNCTION(Server,Reliable)
702 void Server_Reliable_EquipItem(ECosmeticType Type, uint16 ShortCodeIndex, uint16 EquipCodeIndex);
703 UFUNCTION(Client, Reliable)
704 void Client_Reliable_SendGameXPFromMultiplier(uint16 BonusEXP);
705
706protected:
707 UPROPERTY(ReplicatedUsing = OnRep_Kills)
708 uint16 Kills = 0;
709 UPROPERTY(ReplicatedUsing = OnRep_Deaths)
710 uint16 Deaths = 0;
711 UPROPERTY(ReplicatedUsing = OnRep_Assists)
712 uint16 Assists = 0;
713 UPROPERTY(ReplicatedUsing = OnRep_Level)
714 uint16 Level = 0;
715 UPROPERTY(ReplicatedUsing = OnRep_GameXP)
716 uint16 GameXP = 0;
717 UPROPERTY(ReplicatedUsing = OnRep_UltimateCharge)
718 uint16 UltimateCharge = 0;
719 UPROPERTY(ReplicatedUsing = OnRep_Team)
720 uint8 Team = UINT8_MAX;
721 UPROPERTY(ReplicatedUsing = OnRep_CanSwitchTeams)
722 bool bCanChangeTeam = true;
723 UPROPERTY(ReplicatedUsing = OnRep_PlayerClass)
724 TSubclassOf<AProjectXCharacter> PreferredPlayerClass = NULL;
725 UPROPERTY(ReplicatedUsing = OnRep_SquadLeader)
726 bool bSquadLeader = false;
727 UPROPERTY(Replicated)
728 FSquadOrder CurrentSquadOrder;
729 UPROPERTY(ReplicatedUsing = OnRep_NextRespawnTime)
730 float NextRespawnTime = 0.f;
731 UPROPERTY(ReplicatedUsing = OnRep_Ready)
732 bool bReady = false;
733 UPROPERTY(BlueprintReadOnly, Replicated, meta = (AllowPrivateAccess = true))
734 bool bIsAdmin = false;
735 UPROPERTY(Replicated)
736 TWeakObjectPtr<APickupReviveBeacon> ReviveBeacon;
737
738 UPROPERTY()
739 TSubclassOf<AProjectXCharacter> PawnPlayerClass = NULL;
740 UPROPERTY()
741 TWeakObjectPtr<AActor> SpawnTarget = NULL;
742 TWeakObjectPtr<ADecalActor> Graffiti;
743
744 UPROPERTY()
745 FGeneralEquips GeneralEquips;
746 UPROPERTY()
747 float SpawnWorldTime = -1.f;
748
749 /* Next time this player is allowed to spawn at */
750
751 UPROPERTY()
752 TMap<int32, FAuthWeaponTicket> AuthenticatedTicketMap;
753 UPROPERTY(EditDefaultsOnly)
754 UCosmeticExplosionAsset* KillExplosionAsset = NULL;
755 TMap<uint8,UAnimMontage*> TauntMontages;
756 UPROPERTY(Transient)
757 UTexture2D* AvatarReference = NULL;
758 UPROPERTY()
759 UGlobalAmmoComponent* GlobalAmmoComponent = NULL;
760
761 /* How long between team switching do you have to wait*/
762 UPROPERTY(EditDefaultsOnly, Category = Team)
763 float TeamSwitchCoolDownDuration = 0.0f;
764 /*Total Ultimate Charge*/
765 UPROPERTY(EditDefaultsOnly, Category = Ultimate)
766 int32 MaxUltimateCharge = 2;
767 /* The time (in seconds) between checks on the accumulated healing done buffer to award healing bonus XP events */
768 UPROPERTY(EditDefaultsOnly, Category = "Bonus XP Events")
769 float HealBonusBufferCheckTime = 2.0f;
770 /* The minimum amount of healing done needed to trigger the Ally Healed Bonus XP Event */
771 UPROPERTY(EditDefaultsOnly, Category = "Bonus XP Events")
772 float HealBonusThreshold = 2.0f;
773 /* The time (in seconds) between checks on the accumulated repairing done buffer to award repair bonus XP events */
774 UPROPERTY(EditDefaultsOnly, Category = "Bonus XP Events")
775 float RepairBonusBufferCheckTime = 2.0f;
776 /* The minimum amount of repairing done needed to trigger the repair Bonus XP Events */
777 UPROPERTY(EditDefaultsOnly, Category = "Bonus XP Events")
778 float RepairBonusThreshold = 300.f;
779 int32 Currency = 0;
780 bool bUsedUltimate = false;
781
782 //The accumulated XP gained from contractor bonuses
783 uint16 GameXPFromMultiplier = 0;
784 float EXPMultiplier = 1.0f;
785 bool bMatchBonusIsAvailable = false;
786 TArray<FPlayerClassUsage> PlayerClassUsageList;
787 FPlayerProgressionUpdates PlayerProgressionUpdates;
788 uint16 TeamKills = 0;
789 FTimerHandle TeamSwitchTimer;
790 FTimerHandle ChatSpamTimer;
791 uint8 ChatSpamMessageCount;
792 /* A tracking of the interaction between players in terms of kills. (PlayerState's UniqueNetID -> How many times this player Killed us, How many times this player was Killed by us). Tracking info might reset based on Nemesis actions */
793 TMap<uint32, FNemesisTrackingInfo> NemesisInfoMap = TMap<uint32, FNemesisTrackingInfo>();
794 uint32 LastKillerID = 0;
795 /* The accumulated healing done that's checked every HealBonusBufferCheckTime to award healing bonus xp events */
796 float HealBonusXPBuffer = 0.f;
797 FTimerHandle HealBonusXPCheckTimerHandle;
798 /* The accumulated repair done that's checked every RepairBonusBufferCheckTime to award repair bonus xp events per class*/
799 TMap<UClass*, float> RepairBonusXPBuffer = TMap<UClass*, float>();
800 FTimerHandle RepairBonusXPCheckTimerHandle;
801
802 FEquips Equips;
803
804 FString EnemyDeployableDestroyed = "VO_EquipementDestroyed_Enemy";
805
806 FString KilledLitEnemy = "VO_TheyWereLit";
807
808 FString DoubleKill = "VO_DoubleKill";
809 FString TripleKill = "VO_TripleKill";
810 FString QuadKill = "VO_QuadKill";
811 FString QuintKill = "VO_QuintKill";
812
813 FString BecomeNemesis = "VO_Nemesis";
814 FString AquiredNemesis = "VO_Nemesis_Recieve";
815 FString NemesisKilled = "VO_NemesisPayback";
816 FString PayBack = "VO_Payback";
817 FString Avenger = "VO_Avenger";
818 FString Saviour = "VO_Saviour";
819 FString Death = "VO_Death";
820
821 FString AssaultClassID = "Assault";
822 FString EngineerClassID = "Engineer";
823 FString ExplosiveClassID = "Explosive";
824 FString HeavyClassID = "Heavy";
825 FString SpecOpsClassID = "SpecOps";
826 FString SniperClassID = "Sniper";
827
828 FString Assault = "VO_SpawnAssault";
829 FString Sniper = "VO_SpawnSniper";
830 FString Heavy = "VO_SpawnHeavy";
831 FString Engineer = "VO_SpawnEngineer";
832 FString SpecOps = "VO_SpawnSpecops";
833 FString Explosive = "VO_SpawnTech";
834 FString NakamaUserId = "b297c970-8355-4768-9f41-6b03ccd8a938";
835
836 bool bLoadedCosmetics = false;
837 FVector ReviveBeaconSpawnLocation = FVector::ZeroVector;
838};
839
840//Helpers for APlayerState::OverrideWith() and APlayerState::CopyProperties()
841#define COPY_PROPERTY(p, v) \
842{ \
843 p->v = v; \
844}
ECosmeticType
Definition: CosmeticAssetBase.h:21
EXPEventType
Definition: PlayerStats.h:13
EStatUpdateBehaviour
Definition: PlayerStats.h:142
EStatNames
Definition: PlayerStats.h:86
EAchievementData
Definition: ProjectXGameInstance.h:191
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FScoreChangedSignature, float, Score)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FXPChangedSignature, float, XP, float, Delta)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FExperienceEventSignature, const UExperienceEvent *, Event, const int, Value, const APlayerState *, B)
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FPlayerLevelChangedSignature)
DECLARE_DELEGATE_OneParam(FDelegateMaterialInstanceSignature, UMaterialInstance *)
EMessageType
Definition: ProjectXPlayerState.h:118
Definition: Deployable.h:47
Definition: Pickup.h:15
Definition: PickupReviveBeacon.h:48
Definition: ProjectXCharacter.h:128
Definition: ProjectXPlayerState.h:238
bool operator>(const AProjectXPlayerState &Other) const
Definition: ProjectXPlayerState.h:242
FORCEINLINE TWeakObjectPtr< ADecalActor > GetGraffiti() const
Definition: ProjectXPlayerState.h:422
FORCEINLINE int32 GetUnpackedPing() const
Definition: ProjectXPlayerState.h:359
FORCEINLINE int32 GetKills() const
Definition: ProjectXPlayerState.h:373
FORCEINLINE int32 GetDeaths() const
Definition: ProjectXPlayerState.h:378
const FGeneralEquips & GetGeneralEquips() const
Definition: ProjectXPlayerState.h:417
FORCEINLINE int32 GetEliminations() const
Definition: ProjectXPlayerState.h:369
void UpdateGraffiti(TWeakObjectPtr< ADecalActor > NewGraffiti)
Definition: ProjectXPlayerState.h:423
const FString & GetNakamaUserIdAsString() const
Definition: ProjectXPlayerState.h:292
virtual void SetExpMultiplier(float NewMultiplier)
Definition: ProjectXPlayerState.h:420
void SetMaxUltimateCharge(uint16 NewMaxUltimateCharage)
Definition: ProjectXPlayerState.h:421
FORCEINLINE float GetXP() const
Definition: ProjectXPlayerState.h:394
Definition: Projectile.h:18
Definition: OwnedInterface.h:20
Definition: ReactsToMatchEvents.h:16
Definition: SpawnTargetInterface.h:18
Definition: TeamInterface.h:26
Definition: BroadcastMessageExperienceEvent.h:12
Definition: CosmeticAssetBase.h:265
Definition: ExperienceEvent.h:18
Definition: PlayerProgressionManager.h:76
Definition: WeaponInstance.h:220
Definition: WeaponInstanceRanged.h:27
Definition: ProjectXPlayerState.h:39
FAuthWeaponTicket(TSubclassOf< class UWeaponInstanceRanged > InWeapon, TSubclassOf< class AActor > InProjectileClass, const FVector_NetQuantize InOrigin, int8 InNumUses, float InDamageModifier)
Definition: ProjectXPlayerState.h:52
FAuthWeaponTicket()
Definition: ProjectXPlayerState.h:43
Definition: CosmeticsManager.h:105
Definition: ProjectXPlayerState.h:135
Definition: ProjectXPlayerState.h:201
Definition: ProjectXPlayerState.h:79
FPlayerClassUsage()
Definition: ProjectXPlayerState.h:83
FPlayerClassUsage(TSubclassOf< AProjectXCharacter > InPlayerClass)
Definition: ProjectXPlayerState.h:90
static FPlayerClassUsage InvalidEntry
Definition: ProjectXPlayerState.h:113
Definition: PlayerStructs.h:64
Definition: ProjectXPlayerState.h:154
Definition: ProjectXPlayerState.h:172
bool IsValid()
Definition: ProjectXPlayerState.h:188
Definition: ProjectXGameState.h:121