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

@@ -44,16 +44,6 @@
{ {
"Name": "FunctionalTestingEditor", "Name": "FunctionalTestingEditor",
"Enabled": true "Enabled": true
},
{
"Name": "RestartEditor",
"Enabled": true,
"MarketplaceURL": "com.epicgames.launcher://ue/marketplace/product/a00eb1e478ae4a8fb655aa22f9125b07"
},
{
"Name": "BlueprintAssist",
"Enabled": true,
"MarketplaceURL": "com.epicgames.launcher://ue/marketplace/content/9e895371fa3a471c87337860d6f341ff"
} }
] ]
} }

View File

@@ -21,6 +21,18 @@ const FInventoryContent& USlotInventoryComponent::GetContent() const
return Content; 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 int32 USlotInventoryComponent::GetContentCapacity() const
{ {
return Content.Slots.Num(); return Content.Slots.Num();

View File

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