Files
inventory-system-plugin/Source/ItemInventory/Public/ItemSaveLibrary.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.6 KiB
C++

// Copyright ExByte Studios. Item Interaction Ecosystem.
#pragma once
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "ItemSaveGame.h"
#include "ItemSaveLibrary.generated.h"
class UInventoryComponent;
/**
* Save / load of inventories with redirect + version migration (section 26).
* Stores only ItemId/InstanceId/Quantity/RuntimeProperties/StateTags/container/slot
* - never icons, meshes, names or actor pointers (section 26 "do not save").
*/
UCLASS()
class ITEMINVENTORY_API UItemSaveLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
/** Snapshots an inventory's items + containers (drops transient locks). */
UFUNCTION(BlueprintCallable, Category = "Item|Save")
static FInventorySaveData CaptureInventory(UInventoryComponent* Inventory);
/** Server: rebuilds an inventory from a snapshot, migrating each item. */
UFUNCTION(BlueprintCallable, Category = "Item|Save", meta = (WorldContext = "WorldContext"))
static void RestoreInventory(const UObject* WorldContext, UInventoryComponent* Inventory, const FInventorySaveData& Data);
/** Writes one inventory under Key into a save slot (loads/creates the slot file). */
UFUNCTION(BlueprintCallable, Category = "Item|Save")
static bool SaveInventoryToSlot(UInventoryComponent* Inventory, const FString& SlotName, FName Key);
/** Server: loads one inventory under Key from a save slot. */
UFUNCTION(BlueprintCallable, Category = "Item|Save", meta = (WorldContext = "WorldContext"))
static bool LoadInventoryFromSlot(const UObject* WorldContext, UInventoryComponent* Inventory, const FString& SlotName, FName Key);
};