// Project Lab - NHTV Igad

#pragma once

#include "GameFramework/Actor.h"
#include "NetworkCharacter.h"
#include "TeamData.h"
#include "DealDamageProxy.h"
#include "AbilityIndicator.generated.h"

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

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

	UFUNCTION()
		void Init(float duration, FVector offset, FRotator rotationOffset, FVector scale, bool center, AActor* followActor = nullptr, FLinearColor color = FLinearColor(1,1,1,1));

	virtual void BeginPlay() override;
	virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;

	virtual void Tick(float DeltaSeconds) override;

	UFUNCTION(BlueprintNativeEvent)
		void CalculatePosition();
	UFUNCTION(BluePrintCallable, category = "AbilityIndicators")
		void ForceDestroy();

	UPROPERTY(EditDefaultsOnly, category = "AbilityIndicators")
		UMaterial* outlineMat;
	UPROPERTY(EditDefaultsOnly, category = "AbilityIndicators")
		UTexture2D* outlineTexture;

	UPROPERTY(BlueprintReadWrite, Replicated, ReplicatedUsing = CalculatePosition, meta = (ExposeOnSpawn), category = "AbilityIndicators")
		AActor* m_followActor;

	void SetOffset(FVector offset);
	void SetRotationOffset(FRotator rotationOffset);

	UPROPERTY(EditDefaultsOnly)
		UTeamData* teamData;
protected:
	UPROPERTY()
		UMaterialInstanceDynamic* m_outlineMat;

	virtual void SetDecalLocations();
	UPROPERTY()
		ADecalActor* m_outlineDecal;
	UPROPERTY(Replicated)
		bool m_center;

	UPROPERTY(Replicated)
		float m_duration;
	UPROPERTY(Replicated)
		FLinearColor m_color;
	UPROPERTY(Replicated)
		FVector m_offset;
	UPROPERTY(Replicated)
		FRotator m_rotationOffset;
	UPROPERTY(Replicated)
		FVector m_scale;

	UPROPERTY()
		float m_lifeTime;
};

UCLASS()
class UNREALPROJECT_API AFillingAbilityIndicator : public AAbilityIndicator
{
	GENERATED_BODY()

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

	virtual void BeginPlay() override;
	virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;


	virtual void Tick(float DeltaSeconds) override;

	UPROPERTY(EditDefaultsOnly, category = "AbilityIndicators")
		UMaterial* fillMat;
	UPROPERTY(EditDefaultsOnly, category = "AbilityIndicators")
		UTexture2D* fillTexture;



private:
	virtual void SetDecalLocations() override;
	UPROPERTY()
		UMaterialInstanceDynamic* m_fillMat;

	UPROPERTY()
		ADecalActor* m_fillDecal;

};
