Added wardrobe
This commit is contained in:
@@ -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))
|
||||
|
||||
@@ -41,7 +41,16 @@ public:
|
||||
void DropClothing(const EClothingSlotType ClothingType);
|
||||
bool IsClothingTypeOn(const EClothingSlotType ClothingType);
|
||||
void TakeClothing(UClothingItemInstance* ClothingItemInstance);
|
||||
|
||||
// Equip an item arriving from off-body storage: writes the EquippedItems save record and
|
||||
// applies it to its slot. Slot-occupant / bodysuit-exclusion handling is the caller's job
|
||||
// (see UInventorySubsystem::EquipFromWardrobe), so displaced items can be routed deliberately.
|
||||
void EquipSlot(UClothingItemInstance* ClothingItemInstance);
|
||||
|
||||
UClothingItemInstance* RemoveClothing(EClothingSlotType ClothingSlotType);
|
||||
|
||||
// Slots that must be vacated when SlotType is equipped, per the bodysuit exclusion rule (§6.5).
|
||||
static TArray<EClothingSlotType> GetBodysuitExcludedSlots(EClothingSlotType SlotType);
|
||||
void SetClothingSlotItem(const EClothingSlotType ClothingSlotType, UClothingItemInstance* ClothingItemInstance);
|
||||
TArray<UClothingItemInstance*> GetEquippedClothing() const;
|
||||
UClothingItemInstance* GetSlotClothing(EClothingSlotType SlotType);
|
||||
|
||||
Reference in New Issue
Block a user