Files
inventory-system-plugin/Source/ItemInventory/Public/ItemCraftingLibrary.h
Bonchellon 7f7e043a88 Initial commit: Item Interaction Ecosystem plugin (UE5.7)
Server-authoritative, data-driven item/inventory/interaction/carry/equipment/
world-slot/placement/crafting framework. 8 modules, compiles against UE 5.7.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-22 20:49:56 +03:00

39 lines
1.7 KiB
C++

// 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);
};