// Project Lab - NHTV Igad

#pragma once

#include "Blueprint/UserWidget.h"
#include "CombatTextWidget.generated.h"

/**
 * 
 */



UCLASS()
class UNREALPROJECT_API UCombatTextWidget : public UUserWidget
{
	GENERATED_BODY()
	
public:
	virtual void NativeConstruct();
	virtual void NativeDestruct();
	virtual void NativeTick(const FGeometry& geometry, float deltaTime) override;

	UPROPERTY(EditAnywhere, Category = "CombatText")
	TSubclassOf<class UCombatTextText> textWidget;

	UPROPERTY(BlueprintReadWrite, Category = "CombatText")
	class UCanvasPanel* canvas;

	UFUNCTION(BlueprintCallable, Category = "CombatText")
	void CreateCombatText(const FVector& position, const FString& text, const FLinearColor& color);

	UFUNCTION(BlueprintCallable, Category = "CombatText")
	void CreateArcingCombatText(const FVector& position, const FString& text, const FLinearColor& color);


private:
	struct CombatText
	{
		CombatText(const FVector& position, const FString& text, const FLinearColor& color, bool arc) : position(position), text(text), color(color), lifeTime(0), arc(arc) {}
		FVector position;
		FString text;
		FLinearColor color;
		float lifeTime;
		bool arc;
		FVector2D arcDir;

		UCombatTextText* textObject;
	};

	TArray<CombatText> m_combatTexts;

	UCombatTextText* m_CreateTextObject(const FString& text, const FLinearColor& color);
};
