// Copyright ExByte Studios. Item Interaction Ecosystem. #pragma once #include "CoreMinimal.h" #include "Kismet/BlueprintFunctionLibrary.h" #include "GameplayTagContainer.h" #include "ItemCraftingLibrary.generated.h" class UInventoryComponent; /** * Crafting + loot helpers (section 6). All server-authoritative: crafting consumes * inputs and produces the output through the inventory's validated operations; * loot rolls fresh instances from a loot table into a container. */ UCLASS() class ITEMINVENTORY_API UItemCraftingLibrary : public UBlueprintFunctionLibrary { GENERATED_BODY() public: /** True if Inventory holds every ingredient (and the station requirement is met). */ UFUNCTION(BlueprintCallable, Category = "Item|Crafting", meta = (WorldContext = "WorldContext")) static bool CanCraft(const UObject* WorldContext, UInventoryComponent* Inventory, FName RecipeId, FGameplayTag AvailableStation); /** Server: consume the recipe inputs and add its output. Returns true on success. */ UFUNCTION(BlueprintCallable, Category = "Item|Crafting", meta = (WorldContext = "WorldContext")) static bool Craft(const UObject* WorldContext, UInventoryComponent* Inventory, FName RecipeId, FGameplayTag AvailableStation); /** Server: roll a loot table and add the results into an inventory. */ UFUNCTION(BlueprintCallable, Category = "Item|Loot", meta = (WorldContext = "WorldContext")) static void RollLootIntoInventory(const UObject* WorldContext, UInventoryComponent* Inventory, FName TableId, int32 RollCount); private: /** Removes Count of ItemId across stacks. Returns true if the full amount was removed. */ static bool ConsumeItem(UInventoryComponent* Inventory, FName ItemId, int32 Count); };