// Oleg Petruny proprietary.

#pragma once

#include "Minigame/Minigame.h"

#include "CrossyRoadManager.generated.h"

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

public:
    ACrossyRoadManager();

    virtual void Start(class APlayerBase* playerPawn, FMinigameEndCallback delegate) override;
    virtual void End() override;

    void Hit();
    void Finish();

protected:
    struct ObstacleData
    {
        class ACrossyRoadObstacle* actor;
        class USplineComponent* line;
        float time;
        float speed;
    };

    virtual void PostInitializeComponents() override;
    virtual void Tick(float deltaTime) override;

    void CreateObstacle(int32 index = -1);
    void RotateLine(class USplineComponent* line);

    void Up();
    void Down();
    void Left();
    void Right();

    UPROPERTY(EditDefaultsOnly)
    TSet<TSubclassOf<class ACrossyRoadObstacle>> obstacleClasses;

    UPROPERTY(EditAnywhere)
    class UCameraComponent* camera;

    UPROPERTY(EditAnywhere)
    class USkeletalMeshComponent* mannequin;

    UPROPERTY(EditDefaultsOnly)
    float speed = 2;

    UPROPERTY(EditDefaultsOnly)
    float spawnDelay = 3;
    float time = spawnDelay;

    TArray<class USplineComponent*> lines;
    TMap<class USplineComponent*, bool> linesRotated;

    TArray<ObstacleData> obstacles;
    TArray<int32> inputHandlers;
    class USceneComponent* playerPos;
    float playerLineTime = 0.5f;
};
