#pragma once

#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "Engine/HitResult.h"
#include "InteractionDetectorComponent.generated.h"

class UPrimitiveComponent;
class AInteractable;
class AActor;
class ADBDPlayer;

UCLASS(Blueprintable, meta=(BlueprintSpawnableComponent))
class DEADBYDAYLIGHT_API UInteractionDetectorComponent : public UActorComponent
{
	GENERATED_BODY()

private:
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Instanced, meta=(AllowPrivateAccess=true))
	UPrimitiveComponent* _detectionPrimitive;

	UPROPERTY(BlueprintReadWrite, Transient, meta=(AllowPrivateAccess=true))
	TSet<AInteractable*> _overlappingInteractables;

	UPROPERTY(BlueprintReadWrite, Transient, Export, meta=(AllowPrivateAccess=true))
	TSet<UPrimitiveComponent*> _overlappingPrimitiveComponents;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(AllowPrivateAccess=true))
	TSet<AActor*> _ignoredActors;

public:
	UFUNCTION(BlueprintCallable)
	void SetDetectionPrimitive(UPrimitiveComponent* detectionPrimitive);

private:
	UFUNCTION(BlueprintCallable)
	void OnLocallyObservedChanged(ADBDPlayer* player);

public:
	UFUNCTION(BlueprintPure)
	UPrimitiveComponent* GetDetectionPrimitive() const;

private:
	UFUNCTION(BlueprintCallable)
	void EndOverlapCallback(UPrimitiveComponent* hitComponent, AActor* otherActor, UPrimitiveComponent* otherComp, int32 otherBodyIndex);

	UFUNCTION()
	void BeginOverlapCallback(UPrimitiveComponent* hitComponent, AActor* otherActor, UPrimitiveComponent* otherComp, int32 otherBodyIndex, bool fromSweep, const FHitResult& sweepResult);

public:
	UFUNCTION(BlueprintCallable)
	void AddIgnoredActor(AActor* ignored);

public:
	UInteractionDetectorComponent();
};

FORCEINLINE uint32 GetTypeHash(const UInteractionDetectorComponent) { return 0; }
