#pragma once

#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "LightUpdate.h"
#include "LightMaterialUpdate.h"
#include "Engine/Scene.h"
#include "OnLightTimelineFinished.h"
#include "LightIntensityTimelineComponent.generated.h"

class UCurveFloat;
class UMaterialHelper;
class ULightComponent;

UCLASS(Blueprintable, meta=(BlueprintSpawnableComponent))
class GFXUTILITIES_API ULightIntensityTimelineComponent : public UActorComponent
{
	GENERATED_BODY()

public:
	UPROPERTY(EditInstanceOnly, BlueprintReadWrite, Transient)
	TArray<FLightUpdate> lights;

	UPROPERTY(EditInstanceOnly, BlueprintReadWrite, Transient)
	TArray<FLightMaterialUpdate> materialHelpers;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	UCurveFloat* intensityCurve;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	bool randomizeStart;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	bool randomizeLength;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	float minLength;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	float maxLength;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	bool normalizeCurve;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	bool startTicking;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	ELightUnits inputLightUnit;

	UPROPERTY(BlueprintReadWrite, BlueprintAssignable)
	FOnLightTimelineFinished OnTimelineFinished;

public:
	UFUNCTION(BlueprintCallable, BlueprintCosmetic)
	void SetRandomizeLength(bool isRandom);

	UFUNCTION(BlueprintCallable, BlueprintCosmetic)
	void SetMinLength(float newMinValue);

	UFUNCTION(BlueprintCallable, BlueprintCosmetic)
	void SetMaxLength(float newMaxValue);

	UFUNCTION(BlueprintCallable, BlueprintCosmetic)
	void SetLightToMaxValue();

	UFUNCTION(BlueprintCallable, BlueprintCosmetic)
	void SetLightCurve(UCurveFloat* lightcurve);

	UFUNCTION(BlueprintCallable, BlueprintCosmetic)
	void Reset();

	UFUNCTION(BlueprintCallable, BlueprintCosmetic)
	void RegisterForTick();

	UFUNCTION(BlueprintCallable, BlueprintCosmetic)
	void DeactivateTick();

	UFUNCTION(BlueprintCallable, BlueprintCosmetic)
	void AddMaterialHelper(UMaterialHelper* matHelper, FName propName, float multiplier);

	UFUNCTION(BlueprintCallable, BlueprintCosmetic)
	void AddLight(ULightComponent* light, float multiplier);

public:
	ULightIntensityTimelineComponent();
};

FORCEINLINE uint32 GetTypeHash(const ULightIntensityTimelineComponent) { return 0; }
