// Oleg Petruny proprietary.

#pragma once

#include "GameFramework/Actor.h"

#include "Minigame.generated.h"

UENUM(BlueprintType)
enum class EMinigameResult : uint8
{
    Loss,
    Win,
};

DECLARE_DYNAMIC_DELEGATE_TwoParams(FMinigameEndCallback, EMinigameResult, result, int32, score);

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

public:
    AMinigame();

    UFUNCTION(BlueprintCallable)
    virtual void Start(class APlayerBase* playerPawn, FMinigameEndCallback delegate);

    UFUNCTION(BlueprintImplementableEvent)
    void OnStart();

    UFUNCTION(BlueprintCallable)
    virtual void End();

    UFUNCTION(BlueprintCallable)
    virtual void Restart();

    UFUNCTION(BlueprintImplementableEvent)
    void OnEnd();

    UFUNCTION(BlueprintPure)
    class UInputMappingContext* GetInputMappings();

protected:
    FMinigameEndCallback callback;
    class APlayerBase* player;

    UPROPERTY(EditAnywhere, BlueprintReadWrite)
    int32 score = 0;

    UPROPERTY(EditAnywhere, BlueprintReadWrite)
    EMinigameResult result = EMinigameResult::Loss;

    UPROPERTY(EditAnywhere, BlueprintReadWrite)
    bool ended = false;

    UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
    TSoftObjectPtr<class UInputMappingContext> context = nullptr;
};

