LEAP Documentation 40220
Documentation for the LEAP project
AfflictionOverlapComponent.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 "Components/SceneComponent.h"
7#include "TeamInterface.h"
8#include "AfflictionOverlapComponent.generated.h"
9
10class UPrimitiveComponent;
11class UAfflictionInstance;
12
13DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FActivationToggledSignature, AActor*, TargetActor, bool, bToggle);
14
15/* This component tracks actors inside of it with overlap events and applies afflictions to them based on those triggers */
16UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent), Blueprintable)
17class PROJECTX_API UAfflictionOverlapComponent : public USceneComponent, public ITeamInterface
18{
19 GENERATED_UCLASS_BODY()
20
21public:
22 //Toggles this volume's capabilities On/Off
23 UFUNCTION(BlueprintCallable, Category = "Affliction Overlap Component")
24 virtual void ToggleVolume(bool bToggle);
25 //Gets if this volume is applying afflictions or not (active state)
26 UFUNCTION(BlueprintCallable, Category = "Affliction Overlap Component")
27 virtual bool GetVolumeActiveState() const { return bIsOverlapActive; }
28 //Gets the team this boundary is set to
29 virtual int32 GetTeam() const override { return TeamOwner; }
30 //Sets the new team for this affliction overlap volume and relies the message to all overlapped actors
31 virtual int32 SetTeam(int32 NewTeam) override;
32 //Refresh the overlapping actors' afflictions
33 virtual void RefreshAfflictions();
34 virtual float GetVolumeRadius() const;
35
36protected:
37 //The starting team owner of this volume, this can be changed dynammicaly through UAfflictionOverlapComponent::SetTeam;
38 UPROPERTY(EditAnywhere, ReplicatedUsing = OnRep_TeamOwner, Category = "Affliction Overlap Component", meta = (AllowPrivateAccess = true))
39 int32 TeamOwner = INDEX_NONE;
40 // If true, this soft boundary volume is active and running its logic based on overlap events
41 UPROPERTY(EditAnywhere, ReplicatedUsing = OnRep_IsOverlapActive, Category = "Affliction Overlap Component", meta = (AllowPrivateAccess = true))
42 bool bIsOverlapActive = true;
43 UPROPERTY(EditAnywhere, Category = "Affliction Overlap Component")
44 TSubclassOf<UAfflictionInstance> AfflictionToApplyFriendlies;
45 UPROPERTY(EditAnywhere, Category = "Affliction Overlap Component")
46 TSubclassOf<UAfflictionInstance> AfflictionToApplyNeutrals;
47 UPROPERTY(EditAnywhere, Category = "Affliction Overlap Component")
48 TSubclassOf<UAfflictionInstance> AfflictionToApplyEnemies;
49 // If true, when a vehicle overlaps the logic will run on its occupants instead
50 UPROPERTY(EditAnywhere, Category = "Affliction Overlap Component", meta = (AllowPrivateAccess = true))
51 bool bTargetVehicleOccupants = false;
52 // If true, when bTargetVehicleOccupants is true this volume will also activate its logic for the target vehicle
53 UPROPERTY(EditAnywhere, Category = "Affliction Overlap Component", meta = (AllowPrivateAccess = true, EditCondition = "bTargetVehicleOccupants"))
54 bool bAlsoApplyToVehicle = false;
55 //The components used as a trigger shapes
56 TArray<UPrimitiveComponent*> TriggerVolumes;
57 //Current overlapping actors
58 TSet<TWeakObjectPtr<AActor>> OverlappingActors;
59
60protected:
61 virtual void BeginPlay() override;
62 virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
63 virtual void CollectInitialOverlaps();
64 virtual void ActivateForActor(AActor* NewActor);
65 virtual void DeactivateForActor(AActor* TargetActor);
66 UFUNCTION()
67 virtual void OnPendingCharacterPlayerStateReady(APlayerState* PlayerState, AProjectXCharacter* Character);
68
69 UFUNCTION()
70 void OnRep_TeamOwner();
71 UFUNCTION()
72 void OnRep_IsOverlapActive();
73 UFUNCTION()
74 void OnOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
75 UFUNCTION()
76 void OnOverlapEnd(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);
77 UFUNCTION()
78 void OnOverlapedVehiclePassengerChanged(AProjectXVehicle* Vehicle, UVehicleSeatComponent* Seat = NULL, AProjectXCharacter* PreviousPassenger = NULL);
79
80public:
81 FActivationToggledSignature OnActivationToggledForActor;
82};
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FActivationToggledSignature, AActor *, TargetActor, bool, bToggle)
Definition: ProjectXCharacter.h:128
Definition: ProjectXVehicle.h:56
Definition: TeamInterface.h:26
virtual int32 GetTeam() const
Definition: TeamInterface.h:31
virtual int32 SetTeam(int32 NewTeam)
Definition: TeamInterface.h:33