LEAP Documentation 40220
Documentation for the LEAP project
ProjectXSpawnerObjective.h
Go to the documentation of this file.
1// Copyright Blue Isle Studios Inc 2022. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "GameFramework/Actor.h"
8#include "ProjectXGameMode.h"
9#include "WeakInterfacePtr.h"
10#include "SpawnInterface.h"
11#include "WaveSpawner.h"
12#include "ProjectXSpawnerObjective.generated.h"
13
14class AWaveSpawner;
15class UUserWidget;
18
19UENUM(BlueprintType)
20enum class EObjectiveState: uint8
21{
22 NONE = 0,
23 WarmUp = 1,
24 InProgress = 2,
25 Complete = 3,
26 CleanUp = 4,
27};
28
29UENUM(BlueprintType)
30enum class EObjectiveComplete : uint8
31{
32 NONE = 0,
33 VICTORY = 1,
34 LOSS = 2
35};
36
37USTRUCT(BlueprintType)
39{
40 GENERATED_USTRUCT_BODY()
41
43 UPROPERTY(BlueprintReadOnly)
45 UPROPERTY(BlueprintReadOnly)
46 float ObjectiveStartTime = -1;
47};
48
49DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FObjectiveStatusUpdatedSignature,AProjectXSpawnerObjective*,ObjectiveController,const FObjectiveStatus&, ObjectiveStatus);
50
51UCLASS()
52class PROJECTX_API AProjectXSpawnerObjective : public AActor, public IReactsToMatchEvents, public ISpawnInterface
53{
54 GENERATED_UCLASS_BODY()
55public:
56 UFUNCTION(BlueprintCallable)
57 EObjectiveState GetObjectiveStat() const { return ObjectiveStatus.State; }
58 UFUNCTION(BlueprintCallable)
59 UUserWidget* const GetObjectiveWidget() const { return ObjectiveWidget.IsValid()? ObjectiveWidget.Get() : NULL; }
60 UFUNCTION(BlueprintCallable)
61 virtual bool GetWaveInfoOverride(EWaveSpawnerState State,FWaveStateInfo& FoundInfo) const;
62 virtual void BeginSpawning_Implementation() override;
63 virtual void StopSpawning_Implementation() override;
64 virtual bool IsAnObjective() const override{ return true;}
65 virtual AProjectXSpawnerObjective* GetObjective() override { return this; }
66 virtual bool IsObjectiveComplete() const { return ObjectiveCompletion != EObjectiveComplete::NONE; }
67 virtual void SetObjectiveSucceded(bool bSuccess);
68 virtual FSpawnProgressSignature& GetSpawnCompleteEvent() override { return OnObjectiveSpawnedEvent; }
69 virtual FSpawnEventCompleteSignature& GetEventCompleteEvent() override { return OnObjectiveCompletedEvent; }
70 virtual const TArray<TWeakObjectPtr<AActor>>& GetSharedObjectives() const { return SharedObjectiveActors; }
71
72 virtual void BeginPlay() override;
73 virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
74
75 virtual void StartWarmup();
76 virtual void StartObjective();
77 virtual void EndObjective();
78 virtual void StartCleanup();
79 virtual void ToggleObjectiveWidget(bool bWidgetActive);
80
81 UPROPERTY(BlueprintAssignable)
82 FSpawnEventCompleteSignature OnObjectiveCompletedEvent;
83 UPROPERTY(BlueprintAssignable)
84 FSpawnProgressSignature OnObjectiveSpawnedEvent;
85 UPROPERTY(BlueprintAssignable)
86 FObjectiveStatusUpdatedSignature OnObjectiveStatusUpdatedEvent;
87
88protected:
89 virtual void InitializeGamePlayObjects() {}
90 virtual void CollectSharedObjectivesList(TArray<TWeakObjectPtr<AActor>> SharedActors) {}
91 virtual void UpdateObjectiveStat(EObjectiveState State);
92
93 UFUNCTION()
94 virtual void RequestObjectiveStatusUpdateDelayed();
95 UFUNCTION()
96 virtual void RequestObjectiveStatusUpdate();
97 UFUNCTION()
98 virtual void WarmupStarted();
99 UFUNCTION()
100 virtual void ObjectiveStarted();
101 UFUNCTION()
102 virtual void ObjectiveComplete();
103 UFUNCTION()
104 virtual void CleanupComplete();
105
106 UFUNCTION(BlueprintNativeEvent)
107 void OnWarmupStarted();
108 UFUNCTION(BlueprintNativeEvent)
109 void OnObjectiveStarted();
110 UFUNCTION(BlueprintNativeEvent)
111 void OnObjectiveComplete();
112 UFUNCTION(BlueprintNativeEvent)
113 void OnCleanupCompleted();
114 UFUNCTION(BlueprintImplementableEvent)
115 void OnObjectiveWidgetToggled(UUserWidget* ObjectiveOwnedWidget,bool bToggled);
116 UFUNCTION()
117 void OnRep_ObjectiveStatus();
118
119 UPROPERTY(ReplicatedUsing = OnRep_ObjectiveStatus)
121
122 //duration of warmup period between wave staring and the objecive starting
123 UPROPERTY(EditAnywhere)
124 float WarmupDuration = 0.0f;
125 //duration of clean up period, between the objective being completed and the wave being ended
126 UPROPERTY(EditAnywhere)
127 float CleanUpDuration = 0.0;
128 //should this destroy itself when the objective is finished
129 UPROPERTY(EditAnywhere)
130 bool bDestroyWhenFinishedSpawning = false;
131 /*display debug information*/
132 UPROPERTY(EditAnywhere)
133 bool bDebug = false;
134 /*override the current wave info with valid objective info*/
135 UPROPERTY(EditAnywhere)
136 TMap<EWaveSpawnerState,FWaveStateInfo> WaveInfoOverride;
137 /*Objectives that are linked to this one*/
138 UPROPERTY(EditAnywhere)
139 TArray<AProjectXSpawnerObjective*> LinkedObjectives= TArray<AProjectXSpawnerObjective*>();
140 /*HUD ui element spawned for this objective*/
141 UPROPERTY(EditDefaultsOnly)
142 TSubclassOf<UUserWidget> ObjectiveWidgetClass = NULL;
143 /* How does the player count affect the scaling of this objective*/
144 UPROPERTY(EditDefaultsOnly)
145 float PlayerScalingValue = 1.0f;
146
147 UPROPERTY()
148 TWeakObjectPtr<UUserWidget> ObjectiveWidget = NULL;
149 TWeakObjectPtr<AWaveSpawner> OwnedSpawner = NULL;
150
151 TArray<TWeakInterfacePtr<IReactsToObjectiveInterface>> ReactsToObjectiveObjects = TArray<TWeakInterfacePtr<IReactsToObjectiveInterface>>();
152
153 //actors that are potentially shared amongst other objectives
154 TArray<TWeakObjectPtr<AActor>> SharedObjectiveActors = TArray<TWeakObjectPtr<AActor>>();
156
157private:
158 FTimerHandle DurationTimerHandle = FTimerHandle();
159};
EObjectiveComplete
Definition: ProjectXSpawnerObjective.h:31
EObjectiveState
Definition: ProjectXSpawnerObjective.h:21
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FObjectiveStatusUpdatedSignature, AProjectXSpawnerObjective *, ObjectiveController, const FObjectiveStatus &, ObjectiveStatus)
EWaveSpawnerState
Definition: WaveSpawner.h:61
Definition: ProjectXSpawnerObjective.h:53
virtual FSpawnEventCompleteSignature & GetEventCompleteEvent() override
Definition: ProjectXSpawnerObjective.h:69
virtual void CollectSharedObjectivesList(TArray< TWeakObjectPtr< AActor > > SharedActors)
Definition: ProjectXSpawnerObjective.h:90
virtual FSpawnProgressSignature & GetSpawnCompleteEvent() override
Definition: ProjectXSpawnerObjective.h:68
virtual const TArray< TWeakObjectPtr< AActor > > & GetSharedObjectives() const
Definition: ProjectXSpawnerObjective.h:70
virtual AProjectXSpawnerObjective * GetObjective() override
Definition: ProjectXSpawnerObjective.h:65
virtual bool IsObjectiveComplete() const
Definition: ProjectXSpawnerObjective.h:66
virtual bool IsAnObjective() const override
Definition: ProjectXSpawnerObjective.h:64
Definition: WaveSpawner.h:115
Definition: ReactsToMatchEvents.h:16
Definition: ReactsToObjectiveInterface.h:18
Definition: SpawnInterface.h:24
Definition: HUDBasicUserWidget.h:14
Definition: ProjectXSpawnerObjective.h:39
Definition: WaveSpawner.h:81