// Project Lab - NHTV Igad

#pragma once

#include "GameFramework/Actor.h"
#include "CharacterSettings.h"
#include "CharacterCarousel.generated.h"

UCLASS()
class UNREALPROJECT_API ACharacterCarousel : public AActor
{
	GENERATED_BODY()

public:
	// Sets default values for this actor's properties
	ACharacterCarousel();

	// Called when the game starts or when spawned
	virtual void BeginPlay() override;
	virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;

	// Called every frame
	virtual void Tick(float DeltaSeconds) override;


	UFUNCTION(BlueprintCallable, Category = "Carousel")
	void Reset();

	UFUNCTION(BlueprintCallable, Category = "Carousel")
	void Next();
	UFUNCTION(BlueprintCallable, Category = "Carousel")
	void Previous();

	UFUNCTION(BlueprintCallable, Category = "Carousel")
	void ToggleSelect(bool enabled);

	UFUNCTION(BlueprintCallable, Category = "Carousel")
	void CreateNewCharacter(const FString& name);
	UFUNCTION(BlueprintCallable, Category = "Carousel")
	void DeleteCharacter(int32 index);

	// Index of the current selected character
	UPROPERTY(BlueprintReadWrite, Category = "Carousel")
	int32 selectedCharacterIndex;

	// Wether the current character is also selected
	UPROPERTY(BlueprintReadWrite, Category = "Carousel")
	bool selected;

	UPROPERTY(EditAnywhere, Category = "Carousel")
	TSubclassOf<class ACharacterBase> characterBlueprint;

	UFUNCTION(BlueprintCallable, Category = "Carousel")
	class ACharacterBase* GetCharacterModel(int32 index);
	UFUNCTION(BlueprintCallable, Category = "Carousel")
	int32 GetCharacterNum();

	UPROPERTY(EditAnywhere, Category = "Carousel")
	FVector selectedCharacterOffset;

	UFUNCTION(BlueprintCallable, Category = "Carousel")
	void SaveCharacterName(const FString& name, int32 index);
	UFUNCTION(BlueprintCallable, Category = "Carousel")
	FString GetCharacterName(int32 index);

private:
	TArray<class ACharacterBase*> m_characters;
	float m_visualSelected;
	float m_zoom;
};
