// Oleg Petruny proprietary.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"

#include "Interactable.generated.h"

//#define INTERACTABLE_DEBUG
//#define INTERACTABLE_ACTIVATOR_DEBUG
//#define INTERACTABLE_MODIFICATOR_DEBUG

UENUM(BlueprintType, meta = (Bitflags, UseEnumValuesAsMaskValuesInEditor = "true"))
enum class EActivatorType : uint8
{
    None = 0 UMETA(Hidden),
    Use = 1 << 0,
    Saw = 1 << 1,
    Collide = 1 << 2,
    Custom1 = 1 << 3 UMETA(DisplayName = "Custom 1"),
    Custom2 = 1 << 4 UMETA(DisplayName = "Custom 2"),
    Custom3 = 1 << 5 UMETA(DisplayName = "Custom 3"),
    Custom4 = 1 << 6 UMETA(DisplayName = "Custom 4"),
    Custom5 = 1 << 7 UMETA(DisplayName = "Custom 5")

};
ENUM_CLASS_FLAGS(EActivatorType);

UCLASS(Blueprintable, BlueprintType, MinimalAPI)
class AInteractable : public AActor
{
    GENERATED_BODY()

public:
    int32 GetActivatedFlags();

    void _Activate(EActivatorType type);
    UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
    void Activate(EActivatorType type);
    virtual void Activate_Implementation(EActivatorType type) {}

    void _Deactivate(EActivatorType type);
    UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
    void Deactivate(EActivatorType type);
    virtual void Deactivate_Implementation(EActivatorType type) {}

    TSet<class UInteractableModificator*> activationLockers;

protected:
    virtual void BeginPlay() override;
    virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;

    UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (Bitmask, BitmaskEnum = "EActivatorType"))
    int32 activated = 0;

    UPROPERTY()
    TMap<EActivatorType, class UInteractableModificator*> modificators;

    class APlayerBase* player = nullptr;
    TArray<UMeshComponent*> meshes;

};

