// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "Items/EatableItems.h"
#include "InventoryComponent.generated.h"

//OUR DELEGATE IS CALLED FONINVENTORYUPDATED
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnInventoryUpdated);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnItemAdd, const FString&, ItemDisplayName, const int&, StackAmount);

UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class THE_TWILIGHT_ABYSS_API UInventoryComponent : public UActorComponent
{
	GENERATED_BODY()

public:
	// Sets default values for this component's properties
	UInventoryComponent();

protected:
	// Called when the game starts
	virtual void BeginPlay() override;

public:
	UPROPERTY()
	TSubclassOf<UUserWidget> InventoryNotificationWidgetClass;
	UPROPERTY()
	UUserWidget* InventoryNotificationWidgetInstance;
	
	bool AddItem(class UBaseItem* BaseItem); //adds the item to the player

	bool Remove(class UBaseItem* BaseItem); //removes the item from the player

	UPROPERTY(EditDefaultsOnly, Instanced)
	TArray<class UBaseItem*> DefaultItems; //Items you start the game with IF YOU WANT YOU CAN JUST NOT USE THIS

	UPROPERTY(EditDefaultsOnly, Category= "Inventory")
	int32 MaxItemSlots;

	UPROPERTY(BlueprintAssignable, Category= "Inventory")
	FOnInventoryUpdated OnInventoryUpdated; //This is our delegate
	UPROPERTY(BlueprintAssignable, Category= "Inventory")
	FOnItemAdd OnItemAdd;

	UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category= "Items")
	TArray<class UBaseItem*> Items; // The items currently in the inventory

	UFUNCTION(BlueprintCallable, Category= "Inventory")
	class UBaseItem* GetItem(int Index);

	UFUNCTION()
	void RemoveItem(UEatableItems* Item);

	UFUNCTION()
	int GetItemAmount(const int& ItemID);

	UFUNCTION()
	void RemoveItemID(const int& ItemID);

	UFUNCTION()
	UBaseItem* GetItemByID(const int& ItemID);
};