From 67aa1bac761eed19d5d5483d53d7bb4a89adf402 Mon Sep 17 00:00:00 2001 From: amasson Date: Tue, 30 Jul 2024 18:07:00 +0200 Subject: [PATCH] Save and load inventory tests --- Aura.uproject | 10 ---------- ...tTest_InventorySystem_ContentModifications.uasset | 4 ++-- .../UnitTest_InventorySystem_SaveAndLoad.uasset | 3 +++ ...InventorySystem_SaveAndLoad_SaveGameObject.uasset | 3 +++ .../Private/Components/SlotInventoryComponent.cpp | 12 ++++++++++++ .../Public/Components/SlotInventoryComponent.h | 3 +++ 6 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 Plugins/SlotBasedInventorySystem/Content/Tests/UnitTests/UnitTest_InventorySystem_SaveAndLoad.uasset create mode 100644 Plugins/SlotBasedInventorySystem/Content/Tests/UnitTests/UnitTest_InventorySystem_SaveAndLoad_SaveGameObject.uasset diff --git a/Aura.uproject b/Aura.uproject index be0426f..3eda780 100644 --- a/Aura.uproject +++ b/Aura.uproject @@ -44,16 +44,6 @@ { "Name": "FunctionalTestingEditor", "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" } ] } \ No newline at end of file diff --git a/Plugins/SlotBasedInventorySystem/Content/Tests/UnitTests/UnitTest_InventorySystem_ContentModifications.uasset b/Plugins/SlotBasedInventorySystem/Content/Tests/UnitTests/UnitTest_InventorySystem_ContentModifications.uasset index 5597e9e..bf81bcd 100644 --- a/Plugins/SlotBasedInventorySystem/Content/Tests/UnitTests/UnitTest_InventorySystem_ContentModifications.uasset +++ b/Plugins/SlotBasedInventorySystem/Content/Tests/UnitTests/UnitTest_InventorySystem_ContentModifications.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:42f70e0feb8eab1d6738fea8c7ced6429d6d0191f56398ba928110068d200e25 -size 279989 +oid sha256:1af200a304b9897fd4296d1030aa16fd1db741571032a5ec1dd49e590ca9134c +size 302422 diff --git a/Plugins/SlotBasedInventorySystem/Content/Tests/UnitTests/UnitTest_InventorySystem_SaveAndLoad.uasset b/Plugins/SlotBasedInventorySystem/Content/Tests/UnitTests/UnitTest_InventorySystem_SaveAndLoad.uasset new file mode 100644 index 0000000..6f3e731 --- /dev/null +++ b/Plugins/SlotBasedInventorySystem/Content/Tests/UnitTests/UnitTest_InventorySystem_SaveAndLoad.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f17213e91ab9d5e3d0570f5f61c7731a8ee0be05379c2f8138eddb5f853471e4 +size 144524 diff --git a/Plugins/SlotBasedInventorySystem/Content/Tests/UnitTests/UnitTest_InventorySystem_SaveAndLoad_SaveGameObject.uasset b/Plugins/SlotBasedInventorySystem/Content/Tests/UnitTests/UnitTest_InventorySystem_SaveAndLoad_SaveGameObject.uasset new file mode 100644 index 0000000..c860ff2 --- /dev/null +++ b/Plugins/SlotBasedInventorySystem/Content/Tests/UnitTests/UnitTest_InventorySystem_SaveAndLoad_SaveGameObject.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0c58bd254b7a367369a6d7f5502a847b76dcd6bf5821053043aebd380144cd4d +size 9175 diff --git a/Plugins/SlotBasedInventorySystem/Source/SlotBasedInventorySystem/Private/Components/SlotInventoryComponent.cpp b/Plugins/SlotBasedInventorySystem/Source/SlotBasedInventorySystem/Private/Components/SlotInventoryComponent.cpp index 02986b0..3c5773a 100644 --- a/Plugins/SlotBasedInventorySystem/Source/SlotBasedInventorySystem/Private/Components/SlotInventoryComponent.cpp +++ b/Plugins/SlotBasedInventorySystem/Source/SlotBasedInventorySystem/Private/Components/SlotInventoryComponent.cpp @@ -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(); diff --git a/Plugins/SlotBasedInventorySystem/Source/SlotBasedInventorySystem/Public/Components/SlotInventoryComponent.h b/Plugins/SlotBasedInventorySystem/Source/SlotBasedInventorySystem/Public/Components/SlotInventoryComponent.h index 5bbae28..b7b67fb 100644 --- a/Plugins/SlotBasedInventorySystem/Source/SlotBasedInventorySystem/Public/Components/SlotInventoryComponent.h +++ b/Plugins/SlotBasedInventorySystem/Source/SlotBasedInventorySystem/Public/Components/SlotInventoryComponent.h @@ -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;