Added wardrobe

This commit is contained in:
2026-05-31 21:00:55 +03:00
parent 49310a992b
commit f94dce1bfb
39 changed files with 787 additions and 111 deletions
+46 -29
View File
@@ -146,48 +146,65 @@ void UClothingManager::SpawnClothingPickup(UClothingItemInstance* ItemInstance)
void UClothingManager::PutOnClothing(UClothingItemInstance* ClothingItemInstance)
{
if (!ClothingItemInstance)
if (!ClothingItemInstance || !ClothingItemInstance->GetClothingItemDefinition())
return;
// Pure apply-to-slot + notify. Exclusion / occupant handling lives with the caller, and the
// EquippedItems save record is written by EquipSlot — hydration reuses this without re-adding.
const EClothingSlotType ClothingSlotType = ClothingItemInstance->GetClothingItemDefinition()->SlotType;
SetClothingSlotItem(ClothingSlotType, ClothingItemInstance);
const UClothingItemDefinition* ClothingItem = ClothingItemInstance->GetClothingItemDefinition();
if (ClothingItem->SlotType == EClothingSlotType::Bodysuit)
{
DropClothing(EClothingSlotType::Top);
DropClothing(EClothingSlotType::Bottom);
DropClothing(EClothingSlotType::UnderwearTop);
DropClothing(EClothingSlotType::UnderwearBottom);
}
else if (ClothingItem->SlotType == EClothingSlotType::Top ||
ClothingItem->SlotType == EClothingSlotType::Bottom ||
ClothingItem->SlotType == EClothingSlotType::UnderwearTop ||
ClothingItem->SlotType == EClothingSlotType::UnderwearBottom)
{
DropClothing(EClothingSlotType::Bodysuit);
}
OnClothingEquip.Broadcast(ClothingItemInstance);
}
void UClothingManager::TakeClothing(UClothingItemInstance* ClothingItemInstance)
void UClothingManager::EquipSlot(UClothingItemInstance* ClothingItemInstance)
{
const EClothingSlotType SlotType = ClothingItemInstance->GetClothingItemDefinition()->SlotType;
if (EquippedClothing.Contains(SlotType))
{
DropClothing(SlotType);
}
SetClothingSlotItem(SlotType, ClothingItemInstance);
if (!ClothingItemInstance)
return;
USaveSubsystem* SaveSubsystem = UGameplayStatics::GetGameInstance(GetWorld())->GetSubsystem<USaveSubsystem>();
SaveSubsystem->GetCurrentSave()->AddEquippedItem(ClothingItemInstance);
PutOnClothing(ClothingItemInstance);
}
void UClothingManager::TakeClothing(UClothingItemInstance* ClothingItemInstance)
{
if (!ClothingItemInstance || !ClothingItemInstance->GetClothingItemDefinition())
return;
const EClothingSlotType SlotType = ClothingItemInstance->GetClothingItemDefinition()->SlotType;
// World-pickup path: a displaced garment swaps back out to the world (no wardrobe nearby).
if (IsClothingTypeOn(SlotType))
DropClothing(SlotType);
for (const EClothingSlotType ExcludedSlot : GetBodysuitExcludedSlots(SlotType))
{
if (IsClothingTypeOn(ExcludedSlot))
DropClothing(ExcludedSlot);
}
EquipSlot(ClothingItemInstance);
}
TArray<EClothingSlotType> UClothingManager::GetBodysuitExcludedSlots(const EClothingSlotType SlotType)
{
switch (SlotType)
{
case EClothingSlotType::Bodysuit:
return { EClothingSlotType::Top, EClothingSlotType::Bottom,
EClothingSlotType::UnderwearTop, EClothingSlotType::UnderwearBottom };
case EClothingSlotType::Top:
case EClothingSlotType::Bottom:
case EClothingSlotType::UnderwearTop:
case EClothingSlotType::UnderwearBottom:
return { EClothingSlotType::Bodysuit };
default:
return {};
}
}
UClothingItemInstance* UClothingManager::RemoveClothing(const EClothingSlotType ClothingSlotType)
{
if (!EquippedClothing.Contains(ClothingSlotType))