LEAP Documentation 40220
Documentation for the LEAP project
ProjectXGameState.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 "Debug.h"
7#include "ProjectX.h"
8#include "GameFramework/GameState.h"
9#include "Net/UnrealNetwork.h"
10#include "Components/ActorComponent.h"
11#include "ProjectXDamageType.h"
12#include "GenericOctree.h"
14#include "WeakInterfacePtr.h"
16#include "ProjectXGameState.generated.h"
17
18#define INVALID_TEAM 255
19
20
21class APlayerState;
24class UProjectXPlayerState;
25class APostGameScreen;
26class APickup;
28
29UENUM(BlueprintType)
30enum class EMatchResult : uint8
31{
32 Win = 0,
33 Loss = 1,
34 Tie = 2,
35 None = 255,
36};
37
38UENUM(BlueprintType)
39enum class EGameType : uint8
40{
41 NONE = 0,
42 BaseControl = 1,
43 Assault = 2,
46 KingOfTheHill = 5,
47 VIP = 6,
48 Horde = 7,
49 CUSTOM = 255,
50};
51
52UENUM(BlueprintType)
53enum class EDifficultyLevel : uint8
54{
55 NONE = 0,
56 Bronze = 1,
57 Silver = 2,
58 Gold = 3,
59 Any = 254,
60 CUSTOM = 255,
61};
62
63USTRUCT(Blueprintable)
65{
66 GENERATED_USTRUCT_BODY()
67
68public:
69 UPROPERTY()
70 float EndTime = INDEX_NONE;
71 UPROPERTY()
72 uint8 Type = 0;
73};
74
75USTRUCT(Blueprintable)
77{
78 GENERATED_USTRUCT_BODY()
79
80public:
81 UPROPERTY()
82 int16 Tickets = INDEX_NONE;
83};
84
85USTRUCT(Blueprintable)
87{
88 GENERATED_USTRUCT_BODY()
89
90public:
91 UPROPERTY(BlueprintReadWrite, EditInstanceOnly, Category = "Score Info")
92 uint8 Team;
93 UPROPERTY(BlueprintReadWrite, EditInstanceOnly, Category = "Score Info")
94 float Score;
95};
96
98{
99public:
100 TWeakObjectPtr<AActor> Targetable = nullptr;
101 FBoxSphereBounds BoxSphereBounds;
102
104 {
105 BoxSphereBounds = FBoxSphereBounds(FVector(0.0f, 0.0f, 0.0f), FVector(1.0f, 1.0f, 1.0f), 1.0f);
106 }
107};
108
110{
112 FTargetOctreeElementInfo(FOctreeElementId InId, const FVector& Location) : Id(InId), CachedLocation(Location) {}
113
114public:
115 FOctreeElementId Id;
116 FVector CachedLocation = FVector::ZeroVector;
117};
118
119USTRUCT()
121{
122 GENERATED_BODY()
123
124public:
125 UPROPERTY()
126 FVector_NetQuantize ExpectedTargetLocation = FVector::ZeroVector;
127 UPROPERTY()
128 FVector_NetQuantize SpawnLocation = FVector::ZeroVector;
129 UPROPERTY()
130 TSubclassOf<APickup> PickupClass;
131 UPROPERTY()
132 int32 PickupID = 0;
133 TWeakObjectPtr<APickup> Pickup;
134};
135
137
138DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FKilledAlertSignature, AController*, Controller);
139DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FServerBroadcastMessageSignature, FText, Message);
140DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FTrackableActorAddedSignature, const AActor*, Actor);
141DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FServerBroadcastMarkedLocationSignature, AActor*, MarkedActor, TSubclassOf<UActorComponent>, MarkerToPlace);
144DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnBotSpawnSignature, AProjectXCharacter*, SpawnedCharacter);
145DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnBotKilledSignature, AProjectXCharacter*, KilledCharacter, FVector, SpawnLocation);
146DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FPlayerStateAddedSignature, APlayerState*, AddedPlayerState);
147DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FPlayerStateRemovedSignature, APlayerState*, RemovedPlayerState);
148DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FMatchStateChangedSignature, FName, NewMatchState, FName, PreviousMatchState);
149DECLARE_DYNAMIC_MULTICAST_DELEGATE_FiveParams(FKillFeedSignature, class AProjectXPlayerState*, Killer, class AProjectXPlayerState*, Killed, int32, Data, TSubclassOf<class UProjectXDamageType>, DamageType, bool, bWasHeadshot);
150DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FWinningTeamSignature, int32, WinningTeam);
151DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FTeamScoreChangedSignature, const TArray<FTeamScoreInfo>&, Scores);
152DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FTeamTicketChangedSignature, const TArray<FTeamTicketInfo>&, Tickets);
153DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FWelcomeMessageChangedSignature, const FString&, WelcomeMessage);
154DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FTimerStartSignature, const float, EndTime, const FText&, TimerDescription);
155
156UCLASS(config = Game)
157class PROJECTX_API AProjectXGameState : public AGameState
158{
159 GENERATED_UCLASS_BODY()
160
161public:
163 static TMap<uint32, FTargetOctreeElementInfo> TargetableOctreeElements;
164 static void RegisterTargetableActor(AActor* const Targetable);
165 static void DeRegisterTargetableActor(AActor* const Targetable);
166 TArray<TWeakInterfacePtr<ISpawnTargetInterface>> GetSpawnTargetsRegisteredForScoring() const {return SpawnTargetsRegisteredForScoring; }
167
168 template <class T>
169 TArray<T*> GetTargetableActorsInRadius(const FVector& Location, const float Radius, bool bMustBeAlive = false);
170
171 UFUNCTION(BlueprintPure, Category = GameState)
172 FORCEINLINE class UVehicleRespawnManager* GetVehicleRespawnManager() const { return VehicleRespawnManager; }
173 UFUNCTION(BlueprintPure, Category = GameState)
174 FORCEINLINE int32 GetWinningTeam() const { return WinningTeam; }
175 UFUNCTION(BlueprintPure, Category = GameState)
176 FORCEINLINE USquadComponent* GetSquadComponent() const { return SquadComponent; }
177 UFUNCTION(BlueprintPure, Category = GameState)
178 FORCEINLINE float GetMatchStartTime() const { return MatchStartTime; }
179 UFUNCTION(BlueprintPure, Category = GameState)
180 FORCEINLINE float GetTimeUntilMatchStart() const { return FMath::Clamp(MatchStartTime - GetServerWorldTimeSeconds(), 0.0f, BIG_NUMBER); }
181 UFUNCTION(BlueprintPure, Category = GameState)
182 FORCEINLINE float GetMatchElapsedTime() const { return GetServerWorldTimeSeconds() - MatchStartTime; }
183 UFUNCTION(BlueprintPure, Category = GameState)
184 FORCEINLINE float GetMatchTimeRemaining() const { return GetMatchLength() - GetMatchElapsedTime(); };
185 UFUNCTION(BlueprintPure, Category = GameState)
186 FORCEINLINE float GetMaxPlayers() const { return MaxPlayers; };
187 UFUNCTION(BlueprintPure, Category = GameState)
188 FORCEINLINE TSubclassOf<APickupReviveBeacon> GetReviveBeaconGlobalOverride() const { return GlobalReviveBeaconOverride; }
189
190 UFUNCTION(BlueprintPure, Category = GameState)
191 float GetMatchLength() const;
192 /* Returns the predicted time length of the match based on the time it takes for a match to complete + time it takes it to start */
193 UFUNCTION(BlueprintPure, Category = GameState)
194 float GetMatchEndTime() const;
195 /* Returns the timestamp of the real end of the match, not the predicted one like GetMatchEndTime does, careful, this is a REPLICATED variable, make sure its value is not -1 before using it */
196 UFUNCTION(BlueprintPure, Category = GameState)
197 float GetMatchEndTimestamp() const {return MatchEndTimestamp; }
198 UFUNCTION(BlueprintPure, Category = GameState)
199 float GetPostGameLength() const;
200 UFUNCTION(BlueprintPure, Category = GameState)
201 virtual EMatchResult GetPlayerResult(AProjectXPlayerState* PlayerState);
202 UFUNCTION(BlueprintPure, Category = GameState)
203 bool IsInWarmUp() const;
204 UFUNCTION(BlueprintPure,Category = GameState)
205 FORCEINLINE bool CanShowDeployScreen() const { return bShowDeployScreen;}
206 UFUNCTION(BlueprintPure, Category = "Game Mode")
207 virtual int32 GetTicketCount(uint8 Team) const;
208 UFUNCTION(BlueprintPure, Category = "Game Mode")
209 virtual int32 GetStartingTicketCount(uint8 Team) const;
210 const TArray<FTeamTicketInfo>& GetTeamTicketList() const { return TeamTicketList; }
211 virtual void InitializeGameState(AProjectXGameMode* GameMode);
212 UFUNCTION(BlueprintPure, Category = "GameMode")
213 virtual float GetRedeployRespawnDelay() const;
214 UFUNCTION(BlueprintPure, Category = "GameMode")
215 virtual float GetReviveDuration() const;
216 void RegisterSpawnTargetForScoring(AActor* const Target);
217 void DeRegisterSpawnTargetForScoring(AActor* const Target);
218
219 UFUNCTION(BlueprintCallable, Category = "GameMode")
220 bool CanSpawnInPV() const { return bCanSpawnInPV; }
221
222 virtual float ModifyDamage(AActor* Target, float Damage, struct FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser);
223
224 APostGameScreen* GetPostGameLineup();
225 void UpdateTeamTickets(uint8 Team, int32 Amount = 1, bool bOverride = false);
226 int32 GetTeamTickets(uint8 Team);
227
228 virtual void OnRep_MatchState() override;
229 virtual void HandleMatchWarmupEnded();
230 virtual void HandleMatchHasEnded() override;
231 virtual TSubclassOf<AActor> CheckForActorReplacement(TSubclassOf<AActor> Actor);
232
233 UFUNCTION(BlueprintCallable, Category = "GameState")
234 virtual bool IsMatchInProgress() const override;
235 virtual float GetPlayerRespawnDelay(class AController* Controller) const override;
236 bool GetShouldOpenMapOnPlayerStart() const { return bShouldOpenMapOnPlayerStart; }
237 bool UsesLandingScreen() const { return bUseLandingScreen; }
238
239 UFUNCTION(BlueprintCallable, Category = GameState)
240 const TArray<TSubclassOf<AProjectXCharacter>>& GetPlayerClassList() const;
241
242 virtual int32 GetTeam(const AActor* Target) const;
243 virtual bool IsSquadMate(const AActor* Target, const AActor* EventInstigator) const;
244 virtual bool IsAlly(const AActor* Target, const AActor* EventInstigator) const;
245 virtual bool IsEnemy(const AActor* Target, const AActor* EventInstigator) const;
246 virtual bool IsNeutral(const AActor* Target) const;
247
248 virtual void AddPlayerState(APlayerState* PlayerState) override;
249 virtual void RemovePlayerState(APlayerState* PlayerState) override;
250 /* todo: Winning team should be predictively determined per gamestate based team score */
251 void SetWinningTeam(int32 Team);
252
253 virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
254 virtual void Tick(float DeltaSeconds) override;
255 virtual void BeginPlay() override;
256 virtual void BroadcastTimer(const float TimerDuration, const uint8 Type);
257 virtual void StopTimer();
258 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"))
259 static void BroadcastTimerStatic(const UObject* const WorldContextObject, const float TimerDuration, const uint8 Type);
260 UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"))
261 static void StopBroadcastedTimerStatic(const UObject* const WorldContextObject);
262
263 /* Compares Target to EventInstigator and if both are on the same team returns AllyColour, returning EnemyColour otherwise*/
264 virtual void GetActorColour(const AActor* Target, const FName& ColourName, const AActor* EventInstigator, FLinearColor& LinearColor) const;
265 virtual FText GetTeamName(const AActor* Target) const;
266 virtual FText GetTeamNameByTeam(const int32 Team) const;
267
268 UFUNCTION(BlueprintImplementableEvent)
269 void OnPlayerPawnSpawned(AProjectXCharacter* Character);
270 UFUNCTION(BlueprintNativeEvent, Category = GameState)
271 FText GetRevivePromptOverride(const AProjectXPlayerState* Target, const AProjectXPlayerState* ReviveInstigator) const;
272
273 UFUNCTION(BlueprintCallable)
274 const FLinearColor& GetAllyColour(const FName& ColourName = NAME_None) const;
275 UFUNCTION(BlueprintCallable)
276 const FLinearColor& GetEnemyColour(const FName& ColourName = NAME_None) const;
277 const FLinearColor& GetNeutralColour() const;
278 UFUNCTION(BlueprintPure, Category = GameState, meta = (WorldContext = "WorldContextObject"))
279 static const FText& GetGameTypeTextStatic(UObject* const WorldContextObject, EGameType InGameType);
280 UFUNCTION(BlueprintCallable, Category= GameState)
281 EGameType GetGameType() const;
282
283 virtual void GetPlayersOnTeam(const uint8 Team, TArray<APlayerState*>& Players) const;
284 virtual uint8 GetNumPlayersOnTeam(const uint8 Team) const;
285 UFUNCTION(BlueprintCallable, Category = GameState)
286 virtual void GetTeamScores(TArray<FTeamScoreInfo>& OutTeamScores) const;
287 UFUNCTION(BlueprintCallable)
288 int32 GetNumberOfTeams() const { return TeamTicketList.Num(); }
289 virtual void OnTeamScoreChanged();
290
291 void AddPickupToWorldList(FWorldPickupInfo& WorldPickupInfo);
292 void RemovePickupFromWorldList(int32 InID);
293 bool GetWorldPickupByID(int32 InID, FWorldPickupInfo& OutWorldPickup);
294
295 const int32 GetNewPickupID();
296
297 virtual const FText GetTimerText();
298
299 TArray<FLevelActorState> StateChangedActors;
300
301 UFUNCTION()
302 void OnRep_WelcomeMessage();
303 UFUNCTION()
304 void OnRep_TeamTicketList();
305 UFUNCTION()
306 void OnRep_GenericTimer();
307public:
308 UPROPERTY(BlueprintAssignable)
309 FWinningTeamSignature OnWinningTeamSetEvent;
310 UPROPERTY(BlueprintAssignable)
311 FServerBroadcastMarkedLocationSignature OnServerBroadcastMarkedLocationRecieved;
312 UPROPERTY(BlueprintAssignable)
313 FServerBroadcastMarkedLocationSignature OnServerBroadcastMarkedLocationRemoved;
314 UPROPERTY(BlueprintAssignable, Category = GameState)
315 FKilledAlertSignature OnKilled;
316 UPROPERTY(BlueprintAssignable, Category = GameState)
317 FMatchStartSignature OnMatchStarted;
318 UPROPERTY(BlueprintAssignable, Category = GameState)
319 FPlayerStateAddedSignature OnPlayerStateAdded;
320 UPROPERTY(BlueprintAssignable, Category = GameState)
321 FPlayerStateRemovedSignature OnPlayerStateRemoved;
322 UPROPERTY(BlueprintAssignable, Category = GameState)
323 FMatchStateChangedSignature OnMatchStateChanged;
324 UPROPERTY(BlueprintAssignable, Category = GameState)
325 FKillFeedSignature OnKillFeedUpdate;
326 UPROPERTY(BlueprintAssignable)
327 FTeamScoreChangedSignature OnTeamScoresChanged;
328 UPROPERTY(BlueprintAssignable)
329 FTeamTicketChangedSignature OnTeamTicketsChanged;
330 UPROPERTY(BlueprintAssignable)
331 FPlayerUltimatingSignature OnUltimateEvent;
332 UPROPERTY(BlueprintAssignable)
333 FTrackableActorAddedSignature OnTrackableActorAdded;
334 UPROPERTY(BlueprintAssignable)
335 FWelcomeMessageChangedSignature OnWelcomeMessageChanged;
336 UPROPERTY(BlueprintAssignable)
337 FOnBotSpawnSignature OnBotSpawned;
338 UPROPERTY(BlueprintAssignable)
339 FOnBotKilledSignature OnBotKilled;
340 UPROPERTY(BlueprintAssignable)
341 FTimerStartSignature OnTimerStart;
342
343 //Overrides PlayerClassList with custom list
344 UPROPERTY(Replicated, GlobalConfig, EditDefaultsOnly)
345 TArray<TSubclassOf<AProjectXCharacter>> PlayerClassListOverride;
346 //Overrides the duration of respawn delays
347 UPROPERTY(Replicated, GlobalConfig, EditDefaultsOnly)
348 float RespawnDelayOverride = -1.f;
349 /* Overrides how long the player must wait when redeploying */
350 UPROPERTY(Replicated, GlobalConfig, EditDefaultsOnly)
351 float RedeployRespawnDelayOverride = -1.f;
352 /* Allows or prevents the deploy screen from opening when the player enters the map */
353 UPROPERTY(Replicated, GlobalConfig, EditDefaultsOnly)
354 bool bShouldOpenMapOnPlayerStart = true;
355 /* Allows explosive damage to affect self */
356 UPROPERTY(Replicated, GlobalConfig, EditDefaultsOnly)
357 bool bAllowExplosiveDamageOnSelf = true;
358 /* If we should automatically change to the spectator cam on death */
359 UPROPERTY(Replicated, GlobalConfig, EditDefaultsOnly)
360 bool bUseSpectatorCamOnDeath = false;
361 /* How much friendly fire should be allowed? 1.0 is 100% */
362 UPROPERTY(Replicated, GlobalConfig, EditDefaultsOnly)
363 float FriendlyFirePercent = 0.f;
364 /* Multiplies the damage of ultimates */
365 UPROPERTY(Replicated, GlobalConfig, EditDefaultsOnly)
366 bool bDisableBulletMagnetism = false;
367 /* Multiplies the damage of ultimates */
368 UPROPERTY(Replicated, GlobalConfig, EditDefaultsOnly)
369 float UltimateDamageMultiplier = 1.0f;
370 /* Multiplies the damage of explosives */
371 UPROPERTY(Replicated, GlobalConfig, EditDefaultsOnly)
372 float ExplosiveDamageMultiplier = 1.0f;
373 /* Multiplies the damage of headshots */
374 UPROPERTY(Replicated, GlobalConfig, EditDefaultsOnly)
375 float HeadshotDamageMultiplier = 1.0f;
376 /* Multiplies the damage of ultimates */
377 UPROPERTY(Replicated, GlobalConfig, EditDefaultsOnly)
378 float WeaponDamageMultiplier = 1.0f;
379 /* Multiplies the cooldown of abilities */
380 UPROPERTY(Replicated, GlobalConfig, EditDefaultsOnly)
381 float AbilityCooldownMultiplier = 1.0f;
382 /* Multiplies the distance of the hookshot */
383 UPROPERTY(Replicated, GlobalConfig, EditDefaultsOnly)
384 float HookshotDistanceMultiplier = 1.0f;
385 /* Multiplies the speed of the hookshot */
386 UPROPERTY(Replicated, GlobalConfig, EditDefaultsOnly)
387 float HookshotSpeedMultiplier = 1.0f;
388 UPROPERTY(Replicated, GlobalConfig, EditDefaultsOnly)
389 /* Multiplies the speed of ultimate charge */
390 float UltimateChargeRateMultiplier = 1.0f;
391 /* Modifies the number of grenades a player can carry */
392 UPROPERTY(Replicated, GlobalConfig, EditDefaultsOnly)
393 float GrenadeCountModifier = 0.0f;
394 /* Modifies the number of dash charges */
395 UPROPERTY(Replicated, GlobalConfig, EditDefaultsOnly)
396 int32 DashChargeModifier = 0;
397 /* Overrides the unlimited ammo flag on weapons, rendering their ammo limited */
398 UPROPERTY(Replicated, GlobalConfig, EditDefaultsOnly)
399 bool bIsAmmoLimited = false;
400 /* Altititude Limit Multiplier */
401 UPROPERTY(Replicated, GlobalConfig, EditDefaultsOnly)
402 float AltitudeLimitMultiplier = 1.0f;
403 /* Multiplies the amount of spread weapons have */
404 UPROPERTY(Replicated, GlobalConfig, EditDefaultsOnly)
405 float WeaponSpreadMultiplier = 1.0f;
406 /* Multiplier for the amount of gravity affecting players */
407 UPROPERTY(Replicated, GlobalConfig, EditDefaultsOnly)
408 float GravityMultiplier = 1.0f;
409 /* Multiplier for ground speed */
410 UPROPERTY(Replicated, GlobalConfig, EditDefaultsOnly)
411 float GroundSpeedMultiplier = 1.0f;
412 //Overrides the duration of respawn delays
413 UPROPERTY(Replicated, GlobalConfig, EditDefaultsOnly)
414 bool bCanSpawnInCombat = false;
415
416 /* should show the deploy screen*/
417 UPROPERTY(EditDefaultsOnly)
418 bool bShowDeployScreen = true;
419 /*does this mode use a landing screen*/
420 UPROPERTY(EditDefaultsOnly)
421 bool bUseLandingScreen = false;
422 UPROPERTY(EditDefaultsOnly)
423 bool bCanSpawnInPV = true;
424 /* An override for the revive beacon to be used for all characters */
425 UPROPERTY(GlobalConfig, EditDefaultsOnly)
426 TSubclassOf<APickupReviveBeacon> GlobalReviveBeaconOverride = nullptr;
427
428 UPROPERTY()
429 float ExpMultiplier = 1.0f;
430
431protected:
432 UPROPERTY()
433 class UVehicleRespawnManager* VehicleRespawnManager = NULL;
434 UPROPERTY()
435 class USquadComponent* SquadComponent = NULL;
436 UFUNCTION()
437 void OnRep_WinningTeam();
438 UPROPERTY()
439 TMap<int32, FWorldPickupInfo> WorldPickups;
440
441 UPROPERTY()
442 int32 WorldPickupID = 0;
443
444 TArray<TWeakInterfacePtr<ISpawnTargetInterface>> SpawnTargetsRegisteredForScoring = {};
445
446 /* Replicated team info (just contains tickets; Team ID == Index */
447 UPROPERTY(ReplicatedUsing = OnRep_TeamTicketList)
448 TArray<FTeamTicketInfo> TeamTicketList;
449 UPROPERTY(ReplicatedUsing = OnRep_GenericTimer)
450 FGenericTimerInfo GenericTimer;
451
452 TArray<FTeamTicketInfo> PreviousTeamTicketList;
453
454 FString MatchStart = "VO_MatchStart";
455 FString VictoryVO = "VO_Victory";
456 FString DefeatVO = "VO_Failure";
457 FString FiveMinutesLeft = "VO_5MinsLeft";
458 FString OneMinutesLeft = "VO_1MinLeft";
459 FString TenSecondsLeft = "VO_10SecondsLeft";
460
461private:
462 friend class AProjectXGameMode;
463 UPROPERTY(Replicated)
464 float MatchStartTime = 0.0f;
465 UPROPERTY(Replicated)
466 float MatchLength = 5.0f;
467 UPROPERTY(Replicated)
468 float MatchEndTimestamp = -1.f;
469 UPROPERTY(Replicated)
470 uint8 MaxPlayers;
471 UPROPERTY(Replicated)
472 TArray<int32> StartingTicketCount;
473 UPROPERTY(ReplicatedUsing = OnRep_WinningTeam)
474 int32 WinningTeam = -1;
475 UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_WelcomeMessage, meta=(AllowPrivateAccess = "true"))
476 FString WelcomeMessage = "";
477
478 static TArray<TSubclassOf<AProjectXCharacter>> EmptyClassList;
479
480 FTimerHandle TickTimeHandle;
481
482 void WakeDelayedActors();
483
484 APostGameScreen* Podium = NULL;
485
486public:
487 UFUNCTION(BlueprintPure, Category = GameState, meta = (DisplayName = "Has Match Started", ScriptName = "HasMatchStarted", WorldContext = "WorldContextObject", CallableWithoutWorldContext))
488 static bool HasMatchStartedStatic(const UObject* WorldContextObject);
489 UFUNCTION(BlueprintPure, Category = GameState, meta = (DisplayName = "Get Match Length", ScriptName = "GetMatchLength", WorldContext = "WorldContextObject", CallableWithoutWorldContext))
490 static float GetMatchLengthStatic(const UObject* WorldContextObject);
491 UFUNCTION(BlueprintPure, Category = GameState, meta = (DisplayName = "Get Match Elapsed Time", ScriptName = "GetMatchElapsedTime", WorldContext = "WorldContextObject", CallableWithoutWorldContext))
492 static float GetMatchElapsedTimeStatic(const UObject* WorldContextObject);
493 UFUNCTION(BlueprintPure, Category = GameState, meta = (DisplayName = "Get Server World Time Seconds", ScriptName = "GetServerWorldTimeSeconds", WorldContext = "WorldContextObject", CallableWithoutWorldContext))
494 static float GetServerWorldTimeSecondsStatic(const UObject* WorldContextObject);
495 UFUNCTION(BlueprintCallable, meta=(DisplayName="Get Game State", ScriptName="GetGameState", WorldContext = "WorldContextObject", CallableWithoutWorldContext))
496 static AGameStateBase* GetGameStateNoAutoWorldContext(const UObject* WorldContextObject);
497 UFUNCTION(BlueprintPure, Category = GameState, meta = (WorldContext = "WorldContextObject", CallableWithoutWorldContext))
498 static bool IsAlly(const UObject* WorldContextObject, const AActor* Target, const AActor* EventInstigator);
499 UFUNCTION(BlueprintPure, Category = GameState, meta = (WorldContext = "WorldContextObject", CallableWithoutWorldContext))
500 static bool IsSquadMate(const UObject* WorldContextObject, const AActor* Target, const AActor* EventInstigator);
501 UFUNCTION(BlueprintPure, Category = GameState, meta = (WorldContext = "WorldContextObject", CallableWithoutWorldContext))
502 static bool IsNeutral(const UObject* WorldContextObject, const AActor* Target);
503 UFUNCTION(BlueprintPure, Category = GameState, meta = (WorldContext = "WorldContextObject", CallableWithoutWorldContext))
504 static bool IsEnemy(const UObject* WorldContextObject, const AActor* Target, const AActor* EventInstigator);
505 UFUNCTION(BlueprintPure, Category = GameState, meta = (WorldContext = "WorldContextObject", CallableWithoutWorldContext))
506 static bool IsAllyByTeam(const UObject* WorldContextObject, const int32 Team, const AActor* EventInstigator);
507 UFUNCTION(BlueprintPure, Category = GameState, meta = (WorldContext = "WorldContextObject", CallableWithoutWorldContext))
508 static bool IsNeutralByTeam(const int32 Team);
509 UFUNCTION(BlueprintPure, Category = GameState, meta = (AutoCreateRefTerm = "ColourName"))
510 /*Compares the Target actor with the EventInstigator and returns a Linear Color representing if they are Allies or Enemies (AllyColour or EnemyColour respectively) */
511 static void GetTargetColour(const AActor* Target, const FName& ColourName, const AActor* EventInstigator, FLinearColor& LinearColor);
512 UFUNCTION(BlueprintPure, Category = GameState, meta = (AutoCreateRefTerm = "ColourName"))
513 /*Compares a Team value with the EventInstigator's team and returns a Linear Color representing if those teams match as Allies or Enemies (AllyColour or EnemyColour respectively) */
514 static void GetTargetColourByTeam(const int32 Team, const FName& ColourName, const AActor* EventInstigator, FLinearColor& LinearColor);
515 UFUNCTION(BlueprintPure, Category = GameState, meta = (DisplayName = "Get Team", ScriptName = "GetTeamStatic"))
516 static int32 GetTeamStatic(const AActor* Target);
517 UFUNCTION(BlueprintPure, Category = GameState, meta = (DisplayName = "Get Team Name", ScriptName = "GetTeamNameStatic"))
518 static FText GetTeamNameStatic(const AActor* Target);
519 UFUNCTION(BlueprintPure, Category = GameState, meta = (DisplayName = "Get Team Name By Team", ScriptName = "GetTeamNameByTeam", WorldContext = "WorldContextObject", CallableWithoutWorldContext))
520 static FText GetTeamNameByTeamStatic(const UObject* WorldContextObject, const int32 Team);
521 UFUNCTION(BlueprintPure, Category = "Player Class", meta = (DisplayName = "Get Class List", ScriptName = "GetWeaponList"))
522 static const TArray<TSubclassOf<AProjectXCharacter>>& GetPlayerClassListStatic(TSubclassOf<AProjectXGameState> GameStateClass);
523 static FBoxSphereBounds GetActorBoxSphereBounds(const AActor* const Actor);
524 UFUNCTION()
525 void UpdateGameTimer();
526 void SetWelcomeMessage(const FString& NewWelcomeMessage);
527};
528
530{
531 enum { MaxElementsPerLeaf = 16 };
532 enum { MinInclusiveElementsPerNode = 7 };
533 enum { MaxNodeDepth = 12 };
534
535 typedef TInlineAllocator<MaxElementsPerLeaf> ElementAllocator;
536
537 FORCEINLINE static FBoxSphereBounds GetBoundingBox(const FTargetableOctreeElement& Element)
538 {
539 return Element.BoxSphereBounds;
540 }
541
542 FORCEINLINE static bool AreElementsEqual(const FTargetableOctreeElement& A, const FTargetableOctreeElement& B)
543 {
544 if (A.Targetable.Get() == B.Targetable.Get())
545 {
546 return true;
547 }
548
549 return false;
550 }
551
552 FORCEINLINE_DEBUGGABLE static void SetElementId(const FTargetableOctreeElement& Element, FOctreeElementId Id)
553 {
554 if (Element.Targetable.IsValid())
555 {
556 if (AProjectXGameState::TargetableOctreeElements.Contains(Element.Targetable->GetUniqueID()))
557 {
558 AProjectXGameState::TargetableOctreeElements[Element.Targetable->GetUniqueID()].Id = Id;
559 AProjectXGameState::TargetableOctreeElements[Element.Targetable->GetUniqueID()].CachedLocation = Element.Targetable->GetActorLocation();
560 }
561 else
562 {
563 AProjectXGameState::TargetableOctreeElements.Add(Element.Targetable->GetUniqueID(), FTargetOctreeElementInfo(Id, Element.Targetable->GetActorLocation()));
564 }
565 }
566 }
567
568 FORCEINLINE static void ApplyOffset(FTargetableOctreeElement& Element, FVector Offset)
569 {
570 Element.BoxSphereBounds.Origin = Element.BoxSphereBounds.Origin + Offset;
571 }
572};
573
574template <class T>
575TArray<T*> AProjectXGameState::GetTargetableActorsInRadius(const FVector& Location, const float Radius, bool bMustBeAlive)
576{
577 if (!Octree)
578 {
579 return TArray<T*>();
580 }
581
582 const FBoxCenterAndExtent Query = FBoxCenterAndExtent(Location, FVector(Radius));
583#if WITH_EDITOR
584 // DrawDebugBox(GetWorld(), Query.Center, Query.Extent, FColor().Red, false, 30.0f);
585#endif
586
587 TArray<T*> TargetableActors;
588 for (FTargetableOctree::TConstElementBoxIterator<> OctreeIt(*Octree, Query); OctreeIt.HasPendingElements(); OctreeIt.Advance())
589 {
590 if (!OctreeIt.GetCurrentElement().Targetable.IsValid() || OctreeIt.GetCurrentElement().Targetable->GetWorld() != GetWorld())
591 {
592 continue;
593 }
594
595 if(bMustBeAlive)
596 {
597 IHealthInterface* const HealthInterface = Cast<IHealthInterface>(OctreeIt.GetCurrentElement().Targetable);
598 if(HealthInterface && HealthInterface->IsDead())
599 {
600 continue;
601 }
602 }
603
604 if (T* ClassFilteredActor = Cast<T>(OctreeIt.GetCurrentElement().Targetable.Get()))
605 {
606 TargetableActors.Emplace(ClassFilteredActor);
607 }
608 }
609
610 return MoveTemp(TargetableActors);
611}
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FServerBroadcastMarkedLocationSignature, AActor *, MarkedActor, TSubclassOf< UActorComponent >, MarkerToPlace)
EDifficultyLevel
Definition: ProjectXGameState.h:54
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FKilledAlertSignature, AController *, Controller)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_FiveParams(FKillFeedSignature, class AProjectXPlayerState *, Killer, class AProjectXPlayerState *, Killed, int32, Data, TSubclassOf< class UProjectXDamageType >, DamageType, bool, bWasHeadshot)
TOctree< struct FTargetableOctreeElement, struct FTargetableOctreeSemantics > FTargetableOctree
Definition: ProjectXGameState.h:136
EMatchResult
Definition: ProjectXGameState.h:31
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FMatchStartSignature)
EGameType
Definition: ProjectXGameState.h:40
Definition: Pickup.h:15
Definition: PickupReviveBeacon.h:48
Definition: PostGameScreen.h:28
Definition: ProjectXCharacter.h:128
Definition: ProjectXGameMode.h:115
Definition: ProjectXGameState.h:158
static TMap< uint32, FTargetOctreeElementInfo > TargetableOctreeElements
Definition: ProjectXGameState.h:163
bool UsesLandingScreen() const
Definition: ProjectXGameState.h:237
TArray< FLevelActorState > StateChangedActors
Definition: ProjectXGameState.h:299
TArray< TWeakInterfacePtr< ISpawnTargetInterface > > GetSpawnTargetsRegisteredForScoring() const
Definition: ProjectXGameState.h:166
TArray< T * > GetTargetableActorsInRadius(const FVector &Location, const float Radius, bool bMustBeAlive=false)
Definition: ProjectXGameState.h:575
static FTargetableOctree * Octree
Definition: ProjectXGameState.h:162
Definition: ProjectXPlayerState.h:238
Definition: HealthInterface.h:28
virtual bool IsDead() const
Definition: HealthInterface.cpp:87
Definition: SpawnTargetInterface.h:18
Definition: ProjectXDamageType.h:62
Definition: VehicleRespawnManager.h:24
Definition: ProjectXGameState.h:65
Definition: ProjectXGameState.h:110
FVector CachedLocation
Definition: ProjectXGameState.h:116
FOctreeElementId Id
Definition: ProjectXGameState.h:115
FTargetOctreeElementInfo(FOctreeElementId InId, const FVector &Location)
Definition: ProjectXGameState.h:112
Definition: ProjectXGameState.h:98
FBoxSphereBounds BoxSphereBounds
Definition: ProjectXGameState.h:101
FTargetableOctreeElement()
Definition: ProjectXGameState.h:103
TWeakObjectPtr< AActor > Targetable
Definition: ProjectXGameState.h:100
Definition: ProjectXGameState.h:530
static FORCEINLINE FBoxSphereBounds GetBoundingBox(const FTargetableOctreeElement &Element)
Definition: ProjectXGameState.h:537
static FORCEINLINE void ApplyOffset(FTargetableOctreeElement &Element, FVector Offset)
Definition: ProjectXGameState.h:568
static FORCEINLINE_DEBUGGABLE void SetElementId(const FTargetableOctreeElement &Element, FOctreeElementId Id)
Definition: ProjectXGameState.h:552
TInlineAllocator< MaxElementsPerLeaf > ElementAllocator
Definition: ProjectXGameState.h:535
static FORCEINLINE bool AreElementsEqual(const FTargetableOctreeElement &A, const FTargetableOctreeElement &B)
Definition: ProjectXGameState.h:542
Definition: ProjectXGameState.h:87
Definition: ProjectXGameState.h:77
Definition: ProjectXGameState.h:121