// Copyright (c) 2026 GregOrigin. All Rights Reserved.
#pragma once

#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "FRPGItemData.h"
#include "URPGInventoryComponent.generated.h"

DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnInventoryChanged);
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnItemAdded);

UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class CODEFORGE_API URPGInventoryComponent : public UActorComponent
{
	GENERATED_BODY()

public:
	URPGInventoryComponent();

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "RPG")
	TArray<FRPGItemData> Items;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "RPG")
	int32 MaxSlots = 20;

	UPROPERTY(BlueprintReadOnly, Category = "RPG")
	float CurrentWeight = 0.0f;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "RPG")
	float MaxWeight = 100.0f;

	UPROPERTY(BlueprintAssignable, Category = "RPG")
	FOnInventoryChanged OnInventoryChanged;

	UPROPERTY(BlueprintAssignable, Category = "RPG")
	FOnItemAdded OnItemAdded;

	UFUNCTION(BlueprintCallable, Category = "RPG")
	bool AddItem(const FRPGItemData& Item);

	UFUNCTION(BlueprintCallable, Category = "RPG")
	bool RemoveItem(int32 SlotIndex);

	UFUNCTION(BlueprintPure, Category = "RPG")
	int32 GetItemCount() const;
};