5#include "CoreMinimal.h"
8#include "InteractionComponent.generated.h"
17UCLASS(Blueprintable, BlueprintType, ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent) )
24 UInteractionComponent();
26 UPROPERTY(BlueprintAssignable, Category = "
Interaction")
27 FOnTraceEvent OnTraceEventHit;
29 UPROPERTY(BlueprintAssignable, Category = "
Interaction")
30 FOnTraceEvent OnTraceEventAny;
35 UFUNCTION(BlueprintCallable, Category = "
Interaction")
36 void Aim(const
bool bValue);
41 UFUNCTION(BlueprintPure, BlueprintCallable, Category = "
Interaction")
42 float GetUseLength()
const{
return UseLength;};
44 UFUNCTION(BlueprintPure, BlueprintCallable, Category =
"Interaction")
45 float GetTraceLength()
const{
return TraceLength;};
47 UFUNCTION(BlueprintCallable, Category =
"Interaction")
48 bool GetIsTracing()
const {
return bIsTracing;}
51 UFUNCTION(BlueprintCallable, Category =
"Interaction")
52 void UpdateInteractionData();
55 UFUNCTION(BlueprintCallable, Category = "
Interaction")
56 void StartTraceForward();
58 UFUNCTION(BlueprintCallable, Category = "
Interaction")
59 void StopTraceForward();
62 UFUNCTION(BlueprintCallable, Category = "
Interaction")
63 void StartTraceInteractForward();
65 UFUNCTION(BlueprintCallable, Category = "
Interaction")
66 void StopTraceInteractForward();
68 UFUNCTION(BlueprintCallable, Category = "
Interaction")
69 FHitResult TraceTowardLocation(const FVector& TargetLocation);
73 UFUNCTION(BlueprintCallable, Category = "
Interaction")
75 UFUNCTION(BlueprintCallable, Category = "
Interaction")
79 UFUNCTION(BlueprintCallable, Category = "
Interaction")
82 UFUNCTION(BlueprintCallable, Category = "
Interaction")
85 UFUNCTION(BlueprintCallable, Category = "
Interaction")
86 FHitResult GetHitResult();
87 UFUNCTION(BlueprintCallable, Category = "
Interaction")
88 FVector GetTraceEndLocation();
90 UFUNCTION(BlueprintCallable, Category = "
Interaction")
91 void ChangeInteractionSelection(const
bool bUpSelection);
94 UFUNCTION(BlueprintCallable, Category = "
Interaction")
96 UFUNCTION(BlueprintCallable, Category = "
Interaction")
97 void HideCustomPrompt() const;
99 UFUNCTION(BlueprintCallable, Category = "
Interaction")
100 int32 GetSelectedInteraction()
const{
return SelectedInteraction;};
101 UFUNCTION(BlueprintCallable, Category =
"Interaction")
107 bool bBindOverlap = false;
110 bool bInteractOnAim = false;
113 bool bStartLocationOffset = false;
116 bool bDoesTraceTick = false;
119 float TraceTickRate = 0.1f;
122 float InteractionTime = 0.6f;
124 float OverlapCheckFrequency = 0.5f;
127 AActor* GetFocusedActor()
const {
return FocusedActor;};
129 AActor* GetCurrentOverlapActor()
const{
return CurrentOverlapActor;};
131 AActor* GetInteractionActor()
const{
return InteractionActor;};
133 TArray<AActor*>& GetCurrentOverlappedActors() {
return CurrentOverlappedActors;};
134 int32 GetCurrentNumOfOverlappedActors()
const {
return CurrentOverlappedActors.Num();};
139 virtual void BeginPlay()
override;
140 virtual void ComponentSetupComplete()
override;
144 void TraceInteractForward();
147 void TraceForward(
const bool bInteract =
true,
const bool bUseOverrideLength =
false,
const float OverrideLength = 2000.0f);
149 AActor* GetClosestOverlapActor();
153 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category =
"Interaction|Distance")
154 float TraceLength = 2000.0f;
156 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Interaction|Distance")
157 float UseLength = 1000.0f;
160 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Interaction|Ping")
164 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Interaction|Ping")
167 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Interaction|Ping")
168 float PingLength = 5000.0f;
169 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Interaction|Ping")
170 int32 MaxPingActors = 3;
173 float DebugPointSize = 50.0f;
175 float DebugPointTime = 20.0f;
177 int32 DebugPointPriority = 1;
180 UPROPERTY(ReplicatedUsing=OnInteractionActorReplicated, VisibleAnywhere, BlueprintReadOnly, Category="
Interaction|Actors")
181 AActor* InteractionActor;
183 UPROPERTY(Replicated, VisibleAnywhere, BlueprintReadOnly, Category="
Interaction|Actors")
184 AActor* FocusedActor;
186 UPROPERTY(Replicated, VisibleAnywhere, BlueprintReadOnly, Category="
Interaction|Actors")
187 AActor* CurrentOverlapActor;
189 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="
Interaction|Actors")
190 TArray<AActor*> CurrentOverlappedActors;
192 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "
Interaction|Ping")
193 TArray<AActor*> PingActors;
196 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="
Interaction|Widget")
197 TSoftClassPtr<UUserWidget> InteractionCrosshairWidgetClass;
198 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="
Interaction|Widget")
199 TSoftClassPtr<UUserWidget> InteractionContextWidgetClass;
203 void CompareOverlapDistances();
210 void OnInteractionActorReplicated(AActor* LastActor);
213 void ActorOverlap(AActor* OverlappedActor, AActor* OtherActor);
215 void ActorEndOverlap(AActor* OverlappedActor, AActor* OtherActor);
217 void StartFocusOnActor(AActor* Actor) const;
218 void EndFocusOnActor(AActor* Actor) const;
219 void InteractAfterDelay();
222 UFUNCTION(
Server, Reliable)
223 void Server_FocusOnActor(const
bool bStartFocus, AActor* ActorToFocus);
224 void FocusOnActor(const
bool bStartFocus, AActor* ActorToFocus);
226 void Server_Interact(const int32 Index);
230 void Server_SpawnPingActor(const
FPingData& PingData, const FVector& SpawnLocation);
234 void CheckForOverlappedActors();
238 AActor* GetCurrentActor() const;
241 bool GetCurrentActorInteractionData(
FInteractionData& InteractionData) const;
244 void UpdateHUD(const
bool bStartFocus, AActor* ActorToFocus) const;
246 void UpdateHUDSelection() const;
247 void StartHUDSelection(const
bool bStart = true, const
float Multiplier = 1.0f) const;
249 void SetupInteractionCrosshairWidget();
250 void SetupInteractionContextWidget();
254 UPROPERTY(EditDefaultsOnly, Category = "
Interaction|Ping")
255 TSubclassOf<AActor> PingActorToSpawn;
257 int32 SelectedInteraction = 0;
264 FVector CurrentTraceEnd = FVector::ZeroVector;
266 FHitResult CurrentHitResult;
268 FTimerHandle TraceForwardTimerHandle;
269 FTimerHandle TraceInteractForwardTimerHandle;
270 FTimerHandle UpdateHUDTimerHandle;
271 FTimerHandle UseActionTimerHandle;
274 FTimerHandle CheckOverlapsTimerHandle;
277 bool bIsTracing = false;
EInteractionType
Definition BaseData.h:149
@ Use
Definition InteractionComponent.cpp:798
UCLASS(Blueprintable, BlueprintType, ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent)) class CHATSYSTEM_API UChatSystemComponent
Definition ChatSystemComponent.h:13
DECLARE_LOG_CATEGORY_EXTERN(LogInteraction, Display, All)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnTraceEvent, const FHitResult &, HitResult)
Definition InteractionCrosshair.h:21
Definition InteractionHUD.h:17
Definition InteractionInterface.h:18
Definition Interaction.Build.cs:6
Represents a character component that can be added to an actor.
Definition BaseData.h:420
Definition InteractionData.h:37