Clothing system refactor

This commit is contained in:
olehhapuk
2026-05-29 22:13:09 +03:00
parent b6b81caf4e
commit 1c8ee03083
59 changed files with 417 additions and 227 deletions
@@ -2,7 +2,7 @@
#include "NakedDesireGameMode.h"
#include "Kismet/GameplayStatics.h"
#include "NakedDesire/Clothing/ClothingItem.h"
#include "NakedDesire/Clothing/ClothingItemDefinition.h"
#include "NakedDesire/Clothing/ClothingItemInstance.h"
#include "NakedDesire/Interactables/ItemPickup.h"
#include "UObject/ConstructorHelpers.h"
@@ -34,10 +34,10 @@ void ANakedDesireGameMode::BuyItem(UClothingItemInstance* ClothingItemInstance)
return;
}
if (SaveGame->Money < ClothingItemInstance->GetClothingItem()->BasePrice)
if (SaveGame->Money < ClothingItemInstance->GetClothingItemDefinition()->BasePrice)
return;
SaveGame->Money -= ClothingItemInstance->GetClothingItem()->BasePrice;
SaveGame->Money -= ClothingItemInstance->GetClothingItemDefinition()->BasePrice;
Wardrobe->AddItem(ClothingItemInstance);
}
@@ -71,12 +71,12 @@ void ANakedDesireGameMode::BeginPlay()
}
USaveSubsystem* SaveSubsystem = UGameplayStatics::GetGameInstance(GetWorld())->GetSubsystem<USaveSubsystem>();
for (const auto& Item : SaveSubsystem->GetCurrentSave()->GetWorldItems())
for (const FItemSaveRecord& Item : SaveSubsystem->GetCurrentSave()->GetWorldItems())
{
UClothingItemInstance* NewItemInstance = NewObject<UClothingItemInstance>(this);
NewItemInstance->Init(Item.Definition.Get());
NewItemInstance->Condition = Item.Condition;
NewItemInstance->SetInstanceId(Item.InstanceId);
UClothingItemInstance* NewItemInstance = Cast<UClothingItemInstance>(UItemInstance::CreateFromRecord(this, Item));
if (!NewItemInstance)
continue;
AItemPickup* NewItemPickup = GetWorld()->SpawnActor<AItemPickup>(ItemPickupClass, Item.WorldTransform);
NewItemPickup->SetItem(NewItemInstance);
}