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
15DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FFollowTargetChanged, bool, IsFollowing, AActor*, TargetActor);
16
17class UFloatingPawnMovement;
18
22UCLASS()
23class AGRARSENSE_API ASpectator : public ADefaultPawn
24{
25 GENERATED_BODY()
26
27public:
28
32 UFUNCTION(BlueprintCallable)
33 void TeleportSpectator(const FTransform& Transform);
34
38 UFUNCTION(BlueprintCallable)
39 void TeleportToActorLocation(const AActor* Actor);
40
44 UFUNCTION(BlueprintCallable)
45 void FollowActor(AActor* Actor, bool DisableInputs = true, const float DistanceToActor = 150.0f, const float HeightOffset = 10.0f);
46
50 UFUNCTION(BlueprintCallable)
51 void TeleportToActorFollowLocation(AActor* Actor, const float DistanceToActor = 1500.0f, const float HeightOffset = 500.0f);
52
57 UFUNCTION(BlueprintCallable)
58 void StopFollowingAnyActor(bool EnableInputs = true);
59
64 UFUNCTION(BlueprintCallable)
65 void SetNiagaraComponentVisibility(bool Visible);
66
70 UFUNCTION(BlueprintCallable)
71 void SetMaxSpeed(float MaxSpeed = 1500.0f);
72
76 UFUNCTION(BlueprintCallable)
77 float GetMaxSpeed();
78
83 UFUNCTION(BlueprintCallable)
84 AActor* GetTargetActor()
85 {
86 return Target.Get();
87 }
88
92 UFUNCTION(BlueprintCallable)
93 bool IsNiagaraComponentVisible()
94 {
95 if (NiagaraComponent)
96 {
97 return NiagaraComponent->IsVisible();
98 }
99
100 return false;
101 }
102
107 UFUNCTION(BlueprintCallable)
108 bool IsSpectatorFollowingAnyActor()
109 {
110 return GetTargetActor() != nullptr;
111 }
112
117 UFUNCTION(BlueprintCallable)
118 UFloatingPawnMovement* GetFloatingPawnMovement();
119
124 UFUNCTION(BlueprintCallable)
125 void TeleportToLevelTeleportLocation(FLevelTeleportLocation TeleportLocation);
126
130 UPROPERTY(BlueprintAssignable)
131 FFollowTargetChanged OnFollowTargetChanged;
132
133protected:
134
135 virtual void BeginPlay() override;
136
137 virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
138
139 UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
140 UNiagaraComponent* NiagaraComponent = nullptr;
141
142private:
143
144 TWeakObjectPtr<AActor> Target;
145
146};
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FFollowTargetChanged, bool, IsFollowing, AActor *, TargetActor)