Space Plunder
Loading...
Searching...
No Matches
InteractableActorComponent.h
Go to the documentation of this file.
1// Fill out your copyright notice in the Description page of Project Settings.
2
3#pragma once
4
5#include "CoreMinimal.h"
9#include "InteractableActorComponent.generated.h"
10
11
12DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnInteract, AActor*, Caller, const EInteractionType, InteractionType);
13DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnEndInteract, AActor*, Caller);
15DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnEndOverlap, AActor*, Caller);
16DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnStartFocus, AActor*, Caller);
17DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnEndFocus, AActor*, Caller);
18DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnToggleSwitch, AActor*, Caller, const bool, bOn);
19DECLARE_DYNAMIC_MULTICAST_DELEGATE(FInteractionDataUpdated);
20
21
22USTRUCT(Blueprintable)
24{
25 GENERATED_BODY()
26
27 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Interact")
28 AActor* Actor = nullptr;
29
30 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Interact")
31 bool bOverlapping = false;
32 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Interact")
33 bool bFocused = false;
34 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Interact")
35 bool bInteracting = false;
36
38
39 explicit FInteractionActor(AActor* InActor) : Actor(InActor)
40 {
41
42 }
43
45 {
46 return Actor == Other.Actor;
47 }
48 bool operator==(const AActor* Other) const
49 {
50 return Actor == Other;
51 }
52 bool IsValid() const
53 {
54 return Actor != nullptr;
55 }
56};
57
58
59UCLASS(Blueprintable, BlueprintType, ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent))
60class INTERACTION_API UInteractableActorComponent : public UCommonActorComponent, public IInteractionInterface
61{
62 GENERATED_BODY()
63
64public:
65 UInteractableActorComponent();
66
67 virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
68
69 virtual FVector GetInteractionLocation() const override;
70 virtual UPrimitiveComponent* GetGrabComponent() const override;
71
72 virtual void StartFocus(AActor* Caller) override;
73 virtual void EndFocus(AActor* Caller) override;
74 virtual void OnInteract(AActor* Caller, const int32 SelectedInteraction = 0) override;
75 virtual void OnEndInteract(AActor* Caller) override;
76
77 virtual bool OnOverlap(AActor* Caller) override;
78 virtual void OnEndOverlap(AActor* Caller) override;
79
80 virtual void ToggleSwitch(AActor* Caller, const bool bOn) override;
81
82 virtual void InteractionDataUpdated() const override;
83 virtual void UpdateInteractionData() override;
84
85
86 virtual float GetAimAssistInfluence() const override{return AimAssistInfluence;};
87
88 UFUNCTION(BlueprintCallable, Category = "Interaction")
89 TArray<EInteractionType> GetVisibleInteractionTypes() const;
90
91 // UFUNCTION(BlueprintCallable, Category = "Interaction")
92 // virtual bool GetIsActorOverlapping() const {return bActorOverlapped;};
93 // UFUNCTION(BlueprintCallable, Category = "Interaction")
94 // virtual void SetIsActorOverlapping(const bool bValue) {bActorOverlapped = bValue;};
95 virtual FInteractionData& GetInteractionData() override {return InteractionData;};
96
97 // Delegates
98 UPROPERTY(BlueprintAssignable, Category = "Interaction")
99 FOnStartFocus OnStartFocusDelegate;
100 UPROPERTY(BlueprintAssignable, Category = "Interaction")
101 FOnEndFocus OnEndFocusDelegate;
102 UPROPERTY(BlueprintAssignable, Category = "Interaction")
103 FOnInteract OnInteractDelegate;
104 UPROPERTY(BlueprintAssignable, Category = "Interaction")
105 FOnEndInteract OnEndInteractDelegate;
106 UPROPERTY(BlueprintAssignable, Category = "Interaction")
107 FOnOverlap OnOverlapDelegate;
108 UPROPERTY(BlueprintAssignable, Category = "Interaction")
109 FOnEndOverlap OnEndOverlapDelegate;
110 UPROPERTY(BlueprintAssignable, Category = "Interaction")
111 FOnToggleSwitch OnToggleSwitchDelegate;
112 UPROPERTY(BlueprintAssignable, Category = "Interaction")
113 FInteractionDataUpdated OnInteractionDataUpdated;
114
115 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Interaction|General")
116 bool bPickupOnOverlap = false;
117 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Interaction|General")
118 float AimAssistInfluence = 0.5f;
119 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Interaction|General")
120 bool bLoseFocusAfterInteract = false;
121 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Interaction|General")
122 bool bOutlineMeshOnFocus = true;
123 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Interaction|General", meta=(EditCondition=bOutlineMeshOnFocus))
124 int32 OutlineFocusValue = 1;
125 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Interaction|General")
126 bool bAlwaysShowOutline = false;
127 UPROPERTY(ReplicatedUsing=OnRep_InteractionData, EditAnywhere, BlueprintReadWrite, Category="Interaction")
129
131 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Interaction|Display")
132 FCharacterInfo DisplayInfo;
133
134protected:
135 virtual void BeginPlay() override;
136
137 virtual bool SaveGame() override;
138 virtual bool LoadGame() override;
139
140 UFUNCTION()
141 void OnRep_InteractionData();
142
143 void ShowMeshOutline(const bool bOn) const;
144
145
146
147 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Debugging")
148 bool bShowInteractLogs = false;
149
150
151
152 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Interaction")
153 TArray<FInteractionActor> CurrentActors;
154
155private:
156 bool bActorOverlapped = false;
157
158
159};
EInteractionType
Definition BaseData.h:149
EAIStimuliType
Definition BaseData.h:198
UCLASS(Blueprintable, BlueprintType, ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent)) class CHATSYSTEM_API UChatSystemComponent
Definition ChatSystemComponent.h:13
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FInteractionDataUpdated)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnInteract, AActor *, Caller, const EInteractionType, InteractionType)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnEndInteract, AActor *, Caller)
Definition InteractionInterface.h:18
Definition Interaction.Build.cs:6
Definition BaseData.h:310
Definition InteractableActorComponent.h:24
FInteractionActor(AActor *InActor)
Definition InteractableActorComponent.h:39
bool operator==(const FInteractionActor &Other) const
Definition InteractableActorComponent.h:44
bool operator==(const AActor *Other) const
Definition InteractableActorComponent.h:48
bool IsValid() const
Definition InteractableActorComponent.h:52
Definition BaseData.h:420