LEAP Documentation 40220
Documentation for the LEAP project
ShieldGenerator.h
Go to the documentation of this file.
1// Copyright Blue Isle Studios Inc 2021. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "../BaseControl/CapturePoint.h"
7#include "../Team/SpawnTargetInterface.h"
11#include "ShieldGenerator.generated.h"
12
13DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FShieldGeneratorEventSignature, class AShieldGenerator*, Generator);
14DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FShieldGeneratorHealthEventSignature, class AShieldGenerator*, Generator, float, Delta);
15
20
21/*
22 Shield Generators are standard Capture Points, but they have some custom logic assigned to them where it goes through a fixed phase before they unlock their full "Capture Point" potential:
23 During their functioning state, the shield generator is assigned to a team and needs to be destroyed by another team.
24 ShieldParts are assigned to this shield generator and the enemy team can destroy those parts
25 When all parts are destroyed, this generator becomes a standard Capture Point that can be controlled for spawning purposes.
26*/
27
28UCLASS()
30{
31 GENERATED_BODY()
32
33public:
35
36 virtual bool CanSpawnPlayer(const AProjectXPlayerState* InInstigator) const override;
37
38 virtual void SetLocked(bool bNewLocked) override;
39 virtual void Initialize(int32 NumberOfCheckPointsOverride = INDEX_NONE, float PerPlayerCaptureRateOverride = INDEX_NONE) override;
40
41 virtual float GetObjectiveHealth() const override;
42 virtual float GetObjectiveMaxHealth() const override;
43 virtual bool GetIsObjectiveDead() const { return IsDead(); }
44 virtual int32 GetObjectiveTeam() const { return GetShieldTeam(); }
45 virtual int32 GetObjectiveSortOrder() const { return GetSortOrder(); }
46 virtual bool GetIsObjectiveProperlyInitialized() const { return bIsProperlyInitialized; }
47
48 UFUNCTION(BlueprintCallable, Category = "Shield Generator")
49 virtual bool IsDead() const { return ShieldPartsAlive <= 0; }
50 //Gets the team this ShieldGenerator originally was set to, even before turning itself into a capture point
51 UFUNCTION(BlueprintCallable, Category = "Shield Generator")
52 virtual int32 GetShieldTeam() const { return ShieldTeam == UINT8_MAX? GetTeam() : ShieldTeam; }
53 UFUNCTION(BlueprintPure, Category = "Shield Generator")
54 FORCEINLINE bool GetTurnsIntoCapturePoint() const { return bTurnIntoCapturePoint; }
55
56 UPROPERTY(BlueprintAssignable, Category = "Shield Generator Events")
57 FShieldGeneratorEventSignature OnShieldGeneratorDestroyed;
58 UPROPERTY(BlueprintAssignable, Category = "Shield Generator Events")
59 FShieldGeneratorEventSignature OnShieldUnderAttack;
60 UPROPERTY(BlueprintAssignable, Category = "Shield Generator Events")
61 FShieldGeneratorHealthEventSignature OnShieldHealthChanged;
62 UPROPERTY(BlueprintAssignable, Category = "Shield Generator Events")
63 FShieldGeneratorEventSignature OnShieldProperlyInitialized;
64
65protected:
66 // Called when the game starts or when spawned
67 virtual void BeginPlay() override;
68 virtual void DestroyShieldGenerator();
69 UFUNCTION(BlueprintImplementableEvent)
70 void OnShieldGeneratorInitialized();
71
72 UFUNCTION()
73 virtual void CheckForInitialization();
74 UFUNCTION()
75 virtual void OnShieldPartTakeDamage(ADestroyableObjective* Objective, const float Damage, struct FDamageEvent const& DamageEvent, class AController* EventInstigator, class AActor* DamageCauser, class APlayerState* InstigatorPlayerState);
76 UFUNCTION()
77 virtual void OnShieldPartDestroyed(ADestroyableObjective* Objective, const float Damage, struct FDamageEvent const& DamageEvent, class AController* EventInstigator, class AActor* DamageCauser, class APlayerState* InstigatorPlayerState);
78 UFUNCTION()
79 virtual void OnShieldGeneratorHealthChanged(float Delta);
80
81 // The damageable parts that make this Shield Generator
82 UPROPERTY(EditInstanceOnly, Category = "Shield Generator")
83 TArray<ADestroyableObjective*> ShieldParts;
84 // Should this Shield generator become a capture point when it's destroyed?
85 UPROPERTY(EditInstanceOnly, Category = "Shield Generator")
86 bool bTurnIntoCapturePoint = false;
87 // The autonomous turrets assigned to defend this shield generator
88 UPROPERTY(EditInstanceOnly, Category = "Shield Generator")
89 TArray<ADeployableAutonomousTurret*> DefensiveTurrets;
90
91private:
92 uint8 ShieldPartsAlive = 0;
93 bool bIsProperlyInitialized = false;
94
95 FTimerHandle InitializationTimerHandle;
96 //ACapturePoint has an entire team knowledge attached to it. We need to have a separate set as a cached team for when this becomes a controllable capture point but we still want to know who originally owned this shield generator
97 uint8 ShieldTeam = UINT8_MAX;
98};
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FShieldGeneratorHealthEventSignature, class AShieldGenerator *, Generator, float, Delta)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FShieldGeneratorEventSignature, class AShieldGenerator *, Generator)
Definition: CapturePoint.h:77
Definition: DeployableAutonomousTurret.h:14
virtual void BeginPlay() override
Definition: DeployableAutonomousTurret.cpp:35
virtual int32 GetTeam() const override
Definition: DeployableAutonomousTurret.h:17
virtual bool IsDead() const override
Definition: Deployable.cpp:162
Definition: DestroyableObjective.h:23
Definition: ProjectXPlayerState.h:238
Definition: ShieldGenerator.h:30
virtual bool GetIsObjectiveProperlyInitialized() const
Definition: ShieldGenerator.h:46
virtual int32 GetObjectiveTeam() const
Definition: ShieldGenerator.h:44
virtual bool GetIsObjectiveDead() const
Definition: ShieldGenerator.h:43
virtual int32 GetObjectiveSortOrder() const
Definition: ShieldGenerator.h:45
Definition: StartPointVolume.h:14
Definition: AllOutWarfareObjectiveInterface.h:19