5#include "CoreMinimal.h"
6#include "Components/ActorComponent.h"
7#include "InteractableComponent.generated.h"
10#define INTERACT_WIDGET_PATH TEXT("/Game/CustomContents/UI/Widgets/WBP_InteractWidget.WBP_InteractWidget_C")
19 PickUp
UMETA(DisplayName =
"Pick Up"),
20 Button
UMETA(DisplayName =
"Button"),
21 Kiosk
UMETA(DisplayName =
"Kiosk"),
40UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
41class ONEPIECE_API UInteractableComponent :
public UActorComponent
46 UInteractableComponent();
49 virtual
void BeginPlay() override;
50 virtual
void TickComponent(
float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
51 virtual
void GetLifetimeReplicatedProps(TArray<class FLifetimeProperty>& OutLifetimeProps) const override;
54 void InitDetectionRange();
62 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Interaction")
66 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Interaction")
67 FString InteractionPrompt = TEXT("Press E to Interact");
70 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Interaction")
71 TObjectPtr<class UBoxComponent> DetectionRange;
74 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Interaction")
75 float DetectionDistance = 250.0f;
78 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Debug")
79 bool bShowDetectionDebug = true;
82 UPROPERTY(BlueprintReadOnly, Category = "Interaction")
83 bool bCanInteract = true;
90 UPROPERTY(BlueprintAssignable, Category = "Interaction")
91 FOnInteractionTriggered OnInteractionTriggered;
94 UPROPERTY(BlueprintAssignable, Category = "Interaction")
95 FOnOutlineStateChanged OnOutlineStateChanged;
99 void OnRep_HoldingOwner();
106 void OnRep_IsPickedUp();
110 UFUNCTION(BlueprintPure, Category = "Interaction")
111 FORCEINLINE
bool IsPickedUp()
const {
return bIsPickedUp;}
114 UFUNCTION(BlueprintCallable, Category =
"Interaction")
115 void PickUp(class AActor* NewHoldingOwner);
122 UFUNCTION(Server, Reliable, WithValidation)
123 void Server_PickUp(class AActor* NewHoldingOwner);
126 UFUNCTION(BlueprintCallable, Category = "Interaction")
134 UFUNCTION(Server, Reliable, WithValidation)
138 UFUNCTION(BlueprintCallable, Category = "Debug")
139 void ShowDebugInfo(AActor* ViewerActor);
146 UFUNCTION(BlueprintCallable, Category = "Interaction")
147 void TriggerInteraction(AActor* Interactor);
154 UFUNCTION(BlueprintCallable, Category = "Interaction")
155 void SetOutlineState(
bool bEnabled);
159 UPROPERTY(ReplicatedUsing=OnRep_HoldingOwner)
160 AActor* HoldingOwner;
166 UPROPERTY(ReplicatedUsing=OnRep_IsPickedUp, BlueprintReadOnly, Category = "Interaction")
167 bool bIsPickedUp = false;
176 void OnDetectionBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
177 UPrimitiveComponent* OtherComp, int32 OtherBodyIndex,
178 bool bFromSweep, const FHitResult& SweepResult);
181 void OnDetectionEndOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
182 UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);
189 bool bOriginalSimulatePhysics = false;
192 TEnumAsByte<ECollisionEnabled::Type> OriginalCollisionType;
199 UPrimitiveComponent* GetOwnerPrimitiveComponent() const;
205 void InitWidget(
class UWidgetComponent* InWidgetComp);
206 void UpdateInteractPrompt(
const FString& NewPrompt);
208 bool IsWidgetShowEnable(
const class ACharacter* Character)
const;
212 UFUNCTION(BlueprintCallable, Category =
"Interaction")
213 void SetWidgetVisibility(
bool bVisible);
221 UFUNCTION(BlueprintCallable, Category = "Interaction")
222 void ShowInteractWidget();
225 UFUNCTION(BlueprintCallable, Category = "Interaction")
226 void HideInteractWidget();
229 void BillboardInteractWidget();
234 TObjectPtr<class UWidgetComponent> WidgetComp;
EInteractionType
상호작용 타입 정의
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnInteractionTriggered, AActor *, Interactor)
상호작용 델리게이트