// Oleg Petruny proprietary.

#include "Minigame.h"

#include "InputMappingContext.h"

#include "CustomPlayerController.h"
#include "PlayerBase.h"

AMinigame::AMinigame()
{
    PrimaryActorTick.bStartWithTickEnabled = false;
    PrimaryActorTick.bCanEverTick = true;
}

void AMinigame::End()
{
    if(callback.IsBound())
        callback.Execute(result, score);

    OnEnd();
}

void AMinigame::Start(APlayerBase* playerPawn, FMinigameEndCallback delegate)
{
    player = playerPawn;
    callback = delegate;

    if(context.IsValid())
        ACustomPlayerController::AppendInputContext(context);

    OnStart();
}
