Added world items to save game

This commit is contained in:
2026-05-28 22:36:29 +03:00
parent 78840dcfb1
commit 8c49583a69
8 changed files with 41 additions and 13 deletions
@@ -123,6 +123,12 @@ void UClothingManager::SpawnClothingPickup(UClothingItemInstance* ItemInstance)
UE_LOG(LogTemp, Warning, TEXT("UClothingManager::SpawnClothingPickup NewItemPickup == nullptr"));
return;
}
USaveSubsystem* SaveSubsystem = UGameplayStatics::GetGameInstance(GetWorld())->GetSubsystem<USaveSubsystem>();
FItemSaveRecord ItemSaveRecord;
ItemSaveRecord.Init(ItemInstance);
ItemSaveRecord.WorldTransform = NewItemPickup->GetActorTransform();
SaveSubsystem->GetCurrentSave()->WorldItems.Push(ItemSaveRecord);
NewItemPickup->SetItem(ItemInstance);
}
@@ -184,10 +190,6 @@ void UClothingManager::TakeClothing(UClothingItemInstance* ClothingItemInstance)
ItemSaveRecord.Init(ClothingItemInstance);
SaveSubsystem->GetCurrentSave()->EquippedItems.Push(ItemSaveRecord);
SaveSubsystem->GetCurrentSave()->DroppedItems.RemoveAll([ClothingItemInstance](const FItemSaveRecord& Item)
{
return Item.InstanceId == ClothingItemInstance->GetInstanceId();
});
PutOnClothing(ClothingItemInstance);
}
@@ -235,11 +237,6 @@ void UClothingManager::DropClothing(const EClothingSlotType ClothingType)
if (!ClothingItemInstance)
return;
USaveSubsystem* SaveSubsystem = UGameplayStatics::GetGameInstance(GetWorld())->GetSubsystem<USaveSubsystem>();
FItemSaveRecord ItemSaveRecord;
ItemSaveRecord.Init(ClothingItemInstance);
SaveSubsystem->GetCurrentSave()->DroppedItems.Push(ItemSaveRecord);
SpawnClothingPickup(ClothingItemInstance);
OnClothingDropped.Broadcast(ClothingItemInstance);