Save and load inventory tests

This commit is contained in:
2024-07-30 18:07:00 +02:00
parent b5dbcf0441
commit 67aa1bac76
6 changed files with 23 additions and 12 deletions

View File

@@ -21,6 +21,18 @@ const FInventoryContent& USlotInventoryComponent::GetContent() const
return Content;
}
void USlotInventoryComponent::SetContent(const FInventoryContent& NewContent)
{
if (NewContent.Slots.Num() != GetContentCapacity())
{
SetContentCapacity(NewContent.Slots.Num());
}
for (int32 SlotIndex = 0; SlotIndex < NewContent.Slots.Num(); SlotIndex++)
{
SetSlotValueAtIndex(SlotIndex, NewContent.Slots[SlotIndex]);
}
}
int32 USlotInventoryComponent::GetContentCapacity() const
{
return Content.Slots.Num();

View File

@@ -31,6 +31,9 @@ public:
UFUNCTION(BlueprintCallable, Category = "Content")
const FInventoryContent& GetContent() const;
UFUNCTION(BlueprintCallable, Category = "Content")
void SetContent(const FInventoryContent& NewContent);
UFUNCTION(BlueprintCallable, Category = "Content|Capacity")
int32 GetContentCapacity() const;