Agrarsense
Spectator.h
Go to the documentation of this file.
1// Copyright (c) 2023 FrostBit Software Lab at the Lapland University of Applied Sciences
2//
3// This work is licensed under the terms of the MIT license.
4// For a copy, see <https://opensource.org/licenses/MIT>.
5
6#pragma once
7
8#include "CoreMinimal.h"
9#include "GameFramework/DefaultPawn.h"
10#include "NiagaraComponent.h"
12
13#include "Spectator.generated.h"
14
15class AOverlapSensor;
16
17DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FFollowTargetChanged, bool, IsFollowing, AActor*, TargetActor);
18
19class UFloatingPawnMovement;
20
24UCLASS()
25class AGRARSENSE_API ASpectator : public ADefaultPawn
26{
27 GENERATED_BODY()
28
29public:
30
34 UFUNCTION(BlueprintCallable)
35 void TeleportSpectator(const FTransform& Transform);
36
40 UFUNCTION(BlueprintCallable)
41 void TeleportToActorLocation(const AActor* Actor);
42
46 UFUNCTION(BlueprintCallable)
47 void FollowActor(AActor* Actor, bool DisableInputs = true, const float DistanceToActor = 150.0f, const float HeightOffset = 10.0f);
48
49
53 UFUNCTION(BlueprintCallable)
54 void TeleportToFollowLocation(FVector TargetLocation, const float DistanceToLocation, const float HeightOffset);
55
59 UFUNCTION(BlueprintCallable)
60 void TeleportToActorFollowLocation(AActor* Actor, const float DistanceToActor = 1500.0f, const float HeightOffset = 500.0f);
61
66 UFUNCTION(BlueprintCallable)
67 void StopFollowingAnyActor(bool EnableInputs = true);
68
73 UFUNCTION(BlueprintCallable)
74 void SetNiagaraComponentVisibility(bool Visible);
75
79 UFUNCTION(BlueprintCallable)
80 void SetMaxSpeed(float MaxSpeed = 1500.0f);
81
85 UFUNCTION(BlueprintCallable)
86 float GetMaxSpeed();
87
92 UFUNCTION(BlueprintCallable)
93 AActor* GetTargetActor()
94 {
95 return Target.Get();
96 }
97
101 UFUNCTION(BlueprintCallable)
102 bool IsNiagaraComponentVisible()
103 {
104 if (NiagaraComponent)
105 {
106 return NiagaraComponent->IsVisible();
107 }
108
109 return false;
110 }
111
116 UFUNCTION(BlueprintCallable)
117 bool IsSpectatorFollowingAnyActor()
118 {
119 return GetTargetActor() != nullptr;
120 }
121
122 UFUNCTION(BlueprintCallable)
123 AOverlapSensor* GetOverlapSensor() const
124 {
125 return OverlapSensor;
126 }
127
132 UFUNCTION(BlueprintCallable)
133 UFloatingPawnMovement* GetFloatingPawnMovement();
134
139 UFUNCTION(BlueprintCallable)
140 void TeleportToLevelTeleportLocation(FLevelTeleportLocation TeleportLocation);
141
145 UPROPERTY(BlueprintAssignable)
146 FFollowTargetChanged OnFollowTargetChanged;
147
148protected:
149
150 virtual void BeginPlay() override;
151
152 virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
153
154 UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
155 UNiagaraComponent* NiagaraComponent = nullptr;
156
157 UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
158 AOverlapSensor* OverlapSensor = nullptr;
159
160private:
161
162 TWeakObjectPtr<AActor> Target;
163
164};
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FFollowTargetChanged, bool, IsFollowing, AActor *, TargetActor)