Save and load inventory tests
This commit is contained in:
BIN
Binary file not shown.
Plugins/SlotBasedInventorySystem/Content/Tests/UnitTests/UnitTest_InventorySystem_SaveAndLoad.uasset
LFS
BIN
Binary file not shown.
BIN
Binary file not shown.
+12
@@ -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();
|
||||
|
||||
+3
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user