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>
57 lines
2.5 KiB
C++
57 lines
2.5 KiB
C++
// Copyright ExByte Studios. Item Interaction Ecosystem.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "Kismet/BlueprintFunctionLibrary.h"
|
|
#include "ItemInstanceData.h"
|
|
#include "ItemFeatureLibrary.generated.h"
|
|
|
|
class UInventoryComponent;
|
|
|
|
/**
|
|
* Feature processing (section 21). Everything is LAZY: nothing ticks per item.
|
|
* Call these on events - container open, save load, interaction, world-time pulse.
|
|
* State (freshness, last-update time, charge, fuel) lives in the item's runtime
|
|
* properties so it travels with the instance.
|
|
*/
|
|
UCLASS()
|
|
class ITEMINVENTORY_API UItemFeatureLibrary : public UBlueprintFunctionLibrary
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
/**
|
|
* Recomputes time-based features (rotting) for one item up to "now".
|
|
* Returns true if the item changed. If the item should transform (e.g. raw_meat
|
|
* -> rotten_meat) OutTransformItemId is set to the replacement id.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category = "Item|Features", meta = (WorldContext = "WorldContext"))
|
|
static bool UpdateLazyFeatures(const UObject* WorldContext, UPARAM(ref) FItemInstanceData& Item, FName& OutTransformItemId);
|
|
|
|
/** Server: run lazy updates across a whole inventory, applying any transforms. */
|
|
UFUNCTION(BlueprintCallable, Category = "Item|Features", meta = (WorldContext = "WorldContext"))
|
|
static void UpdateInventoryFeatures(const UObject* WorldContext, UInventoryComponent* Inventory);
|
|
|
|
// --- Direct feature operations (debug tools, gameplay) ---
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "Item|Features", meta = (WorldContext = "WorldContext"))
|
|
static void ForceRot(const UObject* WorldContext, UPARAM(ref) FItemInstanceData& Item, FName& OutTransformItemId);
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "Item|Features")
|
|
static void BreakItem(UPARAM(ref) FItemInstanceData& Item);
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "Item|Features")
|
|
static void DrainBattery(UPARAM(ref) FItemInstanceData& Item, float DrainPerSecond, float Seconds);
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "Item|Features")
|
|
static float AddFuel(UPARAM(ref) FItemInstanceData& Item, float Amount, float MaxFuel);
|
|
|
|
/** Moves up to Amount of fuel from one item to another, respecting ToMaxFuel. Returns moved. */
|
|
UFUNCTION(BlueprintCallable, Category = "Item|Features")
|
|
static float TransferFuel(UPARAM(ref) FItemInstanceData& From, UPARAM(ref) FItemInstanceData& To, float Amount, float ToMaxFuel);
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "Item|Features")
|
|
static void SetWetness(UPARAM(ref) FItemInstanceData& Item, float Wetness);
|
|
};
|