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
47
51 UFUNCTION(BlueprintCallable)
52 void TeleportToFollowLocation(FVector TargetLocation, const float DistanceToLocation, const float HeightOffset);
53
57 UFUNCTION(BlueprintCallable)
58 void TeleportToActorFollowLocation(AActor* Actor, const float DistanceToActor = 1500.0f, const float HeightOffset = 500.0f);
59
64 UFUNCTION(BlueprintCallable)
65 void StopFollowingAnyActor(bool EnableInputs = true);
66
71 UFUNCTION(BlueprintCallable)
72 void SetNiagaraComponentVisibility(bool Visible);
73
77 UFUNCTION(BlueprintCallable)
78 void SetMaxSpeed(float MaxSpeed = 1500.0f);
79
83 UFUNCTION(BlueprintCallable)
84 float GetMaxSpeed();
85
90 UFUNCTION(BlueprintCallable)
91 AActor* GetTargetActor()
92 {
93 return Target.Get();
94 }
95
99 UFUNCTION(BlueprintCallable)
100 bool IsNiagaraComponentVisible()
101 {
102 if (NiagaraComponent)
103 {
104 return NiagaraComponent->IsVisible();
105 }
106
107 return false;
108 }
109
114 UFUNCTION(BlueprintCallable)
115 bool IsSpectatorFollowingAnyActor()
116 {
117 return GetTargetActor() != nullptr;
118 }
119
124 UFUNCTION(BlueprintCallable)
125 UFloatingPawnMovement* GetFloatingPawnMovement();
126
131 UFUNCTION(BlueprintCallable)
132 void TeleportToLevelTeleportLocation(FLevelTeleportLocation TeleportLocation);
133
137 UPROPERTY(BlueprintAssignable)
138 FFollowTargetChanged OnFollowTargetChanged;
139
140protected:
141
142 virtual void BeginPlay() override;
143
144 virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
145
146 UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
147 UNiagaraComponent* NiagaraComponent = nullptr;
148
149private:
150
151 TWeakObjectPtr<AActor> Target;
152
153};
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FFollowTargetChanged, bool, IsFollowing, AActor *, TargetActor)