// Oleg Petruny proprietary.

#pragma once

#include "Components/SceneComponent.h"

#include "Interactable/Interactable.h"

#include "InteractableActivator.generated.h"

DECLARE_DELEGATE_TwoParams(FInteractableActivated, AInteractable*, EActivatorType);
DECLARE_DELEGATE_TwoParams(FInteractableDeactivated, AInteractable*, EActivatorType);

/**
 * Activates interactable based on type
 */
UCLASS(Abstract, Blueprintable, BlueprintType, ClassGroup = InteractableActivator, meta = (ShortTooltip = "Activates interactable based on type"), MinimalAPI)
class UInteractableActivator : public USceneComponent
{
    GENERATED_BODY()

public:
    /** Append itself to CustomGameInstance modificators registry */
    UInteractableActivator(const FObjectInitializer& ObjectInitializer);
    virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;

    virtual bool AutoInstantiateInPlayer() { return false; }

    /** Resets activator state forcing to rescan */
    UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
    LOST_EDGE_API void Rescan();
    virtual void Rescan_Implementation() {}

    FInteractableActivated interactableActivatedDelegate;
    FInteractableActivated interactableDeactivatedDelegate;

protected:
    /** Activator scan function in game thread tick */
    UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
    LOST_EDGE_API void Scan();
    virtual void Scan_Implementation() PURE_VIRTUAL(UInteractableActivator::Scan_Implementation, );

    UPROPERTY(EditDefaultsOnly)
    EActivatorType activatorType;

    UPROPERTY(EditDefaultsOnly)
    float scanDistance = 250;

    class UWorld* world;
    class APlayerBase* player;
    ECollisionChannel collisionChannel;
};
