// Project Lab - NHTV Igad

#pragma once

#include "Engine/DataAsset.h"
#include "Items/ItemBase.h"
#include "AbilityInfo.generated.h"

UENUM(BlueprintType)
enum class EAbilityCategory : uint8
{
	Unassigned = 0,
	Ranged,
	Melee
};
UENUM(BlueprintType)
enum class EAbilityType : uint8
{
	Basic,
	Ability
};
UENUM(BlueprintType)
enum class EAbilityActionType : uint8
{
	Normal,
	Toggle,
	Hold
};


USTRUCT()
struct FAbilityItem
{
	GENERATED_BODY()

	UPROPERTY(EditAnywhere)
	USkeletalMesh* mesh;
	UPROPERTY(EditAnywhere)
	EItemTypeEnum type;
};

UCLASS(BlueprintType)
class UNREALPROJECT_API UAbilityInfo : public UDataAsset
{
	GENERATED_BODY()
public:
	UAbilityInfo();

	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Ability")
	FString name;
	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Ability")
	FString description;
	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Ability")
	float cooldown;
	UPROPERTY(EditDefaultsOnly)
	TArray<TSubclassOf<class AAbilityEventGroup>> events;
	UPROPERTY(EditDefaultsOnly)
	TSubclassOf<class APreCastAbilityEventGroup> precastEvent;
	UPROPERTY(EditDefaultsOnly)
	TSubclassOf<class AAbilityState> abilityState;
	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Ability")
	UTexture2D* icon;
	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Ability")
	float AICastRange;
	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Ability")
	bool passive;
	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Ability")
	bool rotateTowardsPlayer;
	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Ability")
	int32 mana;

	// The action type of the ability, Toggle, Hold or Normal
	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Ability")
	EAbilityActionType actionType;
	// The type of the ability Ability(On AbilityBar) or Basic(Left Mouse Click).
	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Ability")
	EAbilityType abilityType;
	// If the ability is Ranged or Melee
	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Ability")
	EAbilityCategory abilityCategory;

	UPROPERTY(EditAnywhere)
		bool isVisible;
	UPROPERTY(EditAnywhere, meta = (EditCondition = "isVisible"))
		TArray<FAbilityItem> itemsToEquip;

	bool IsHoldOrToggle() const
	{
		return actionType == EAbilityActionType::Hold || actionType == EAbilityActionType::Toggle;
	}

	uint32 GetStaticHash() const;

private:
	uint32 m_hash;
};
