Clothings lots config rework
This commit is contained in:
@@ -23,58 +23,40 @@ void UClothingManager::BeginPlay()
|
||||
HydrateClothing();
|
||||
}
|
||||
|
||||
bool UClothingManager::IsBodyTypeExposed(const EBodyPart BodyPart)
|
||||
void UClothingManager::SetClothingSlotItem(const EClothingSlotType ClothingSlotType, UClothingItemInstance* ClothingItemInstance)
|
||||
{
|
||||
for (const auto& ClothingSlot : ClothingSlots)
|
||||
if (ClothingItemInstance)
|
||||
EquippedClothing.Add(ClothingSlotType, ClothingItemInstance);
|
||||
else
|
||||
EquippedClothing.Remove(ClothingSlotType);
|
||||
}
|
||||
|
||||
TArray<UClothingItemInstance*> UClothingManager::GetEquippedClothing() const
|
||||
{
|
||||
TArray<TObjectPtr<UClothingItemInstance>> Items;
|
||||
EquippedClothing.GenerateValueArray(Items);
|
||||
return Items;
|
||||
}
|
||||
|
||||
UClothingItemInstance* UClothingManager::GetSlotClothing(const EClothingSlotType SlotType)
|
||||
{
|
||||
if (EquippedClothing.Contains(SlotType))
|
||||
return EquippedClothing[SlotType];
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool UClothingManager::IsBodyPartExposed(const EBodyPart BodyPart)
|
||||
{
|
||||
for (const auto& [Key, Value] : EquippedClothing)
|
||||
{
|
||||
if (ClothingSlot.ClothingItemInstance) // TODO: Add covered body part resolution
|
||||
{
|
||||
if (Value->GetClothingItem()->HiddenBodyParts.Contains(BodyPart))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool UClothingManager::GetClothingSlotData(const EClothingSlotType ClothingSlotType, FClothingSlotData& OutClothingSlotData)
|
||||
{
|
||||
for (const auto& ClothingSlot : ClothingSlots)
|
||||
{
|
||||
if (ClothingSlot.ClothingSlotType == ClothingSlotType)
|
||||
{
|
||||
OutClothingSlotData = ClothingSlot;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
void UClothingManager::SetClothingSlotItem(const EClothingSlotType ClothingSlotType, UClothingItemInstance* ClothingItemInstance)
|
||||
{
|
||||
for (FClothingSlotData& ClothingSlot : ClothingSlots)
|
||||
{
|
||||
if (ClothingSlot.ClothingSlotType == ClothingSlotType)
|
||||
{
|
||||
ClothingSlot.ClothingItemInstance = ClothingItemInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TArray<UClothingItemInstance*> UClothingManager::GetEquippedClothing()
|
||||
{
|
||||
TArray<UClothingItemInstance*> EquippedClothingItems;
|
||||
|
||||
for (FClothingSlotData ClothingSlot : ClothingSlots)
|
||||
{
|
||||
if (ClothingSlot.ClothingItemInstance)
|
||||
{
|
||||
EquippedClothingItems.Add(ClothingSlot.ClothingItemInstance);
|
||||
}
|
||||
}
|
||||
|
||||
return EquippedClothingItems;
|
||||
}
|
||||
|
||||
void UClothingManager::HydrateClothing()
|
||||
{
|
||||
USaveSubsystem* SaveSubsystem = UGameplayStatics::GetGameInstance(GetWorld())->GetSubsystem<USaveSubsystem>();
|
||||
@@ -87,15 +69,12 @@ void UClothingManager::HydrateClothing()
|
||||
|
||||
float UClothingManager::GetHeelHeight()
|
||||
{
|
||||
if (FClothingSlotData ClothingSlotData; GetClothingSlotData(EClothingSlotType::Footwear, ClothingSlotData))
|
||||
{
|
||||
if (ClothingSlotData.ClothingItemInstance)
|
||||
{
|
||||
return ClothingSlotData.ClothingItemInstance->GetClothingItem()->ShoesOffset;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
if (!EquippedClothing.Contains(EClothingSlotType::Footwear))
|
||||
return 0;
|
||||
|
||||
const UClothingItemInstance* Footwear = EquippedClothing[EClothingSlotType::Footwear];
|
||||
|
||||
return Footwear->GetClothingItem()->ShoesOffset;
|
||||
}
|
||||
|
||||
USkeletalMeshComponent* UClothingManager::GetMeshComponent(const EClothingSlotType SlotType) const
|
||||
@@ -135,9 +114,6 @@ void UClothingManager::PutOnClothing(UClothingItemInstance* ClothingItemInstance
|
||||
return;
|
||||
|
||||
const EClothingSlotType ClothingSlotType = ClothingItemInstance->GetClothingItem()->SlotType;
|
||||
|
||||
FClothingSlotData ClothingSlotData;
|
||||
GetClothingSlotData(ClothingSlotType, ClothingSlotData);
|
||||
|
||||
USkeletalMeshComponent* MeshComponent = GetMeshComponent(ClothingSlotType);
|
||||
MeshComponent->SetSkeletalMesh(ClothingItemInstance->GetClothingItem()->SkeletalMesh);
|
||||
@@ -154,8 +130,8 @@ void UClothingManager::PutOnClothing(UClothingItemInstance* ClothingItemInstance
|
||||
{
|
||||
MeshComponent->SetLeaderPoseComponent(Cast<ACharacter>(GetOwner())->GetMesh());
|
||||
}
|
||||
|
||||
UClothingItem* ClothingItem = ClothingItemInstance->GetClothingItem();
|
||||
|
||||
const UClothingItem* ClothingItem = ClothingItemInstance->GetClothingItem();
|
||||
if (ClothingItem->SlotType == EClothingSlotType::Bodysuit)
|
||||
{
|
||||
DropClothing(EClothingSlotType::Top);
|
||||
@@ -176,15 +152,13 @@ void UClothingManager::PutOnClothing(UClothingItemInstance* ClothingItemInstance
|
||||
|
||||
void UClothingManager::TakeClothing(UClothingItemInstance* ClothingItemInstance)
|
||||
{
|
||||
FClothingSlotData ClothingSlotData;
|
||||
GetClothingSlotData(ClothingItemInstance->GetClothingItem()->SlotType, ClothingSlotData);
|
||||
|
||||
if (ClothingSlotData.ClothingItemInstance->GetClothingItem())
|
||||
const EClothingSlotType SlotType = ClothingItemInstance->GetClothingItem()->SlotType;
|
||||
if (const UClothingItemInstance* ExistingClothing = *EquippedClothing.Find(SlotType))
|
||||
{
|
||||
DropClothing(ClothingItemInstance->GetClothingItem()->SlotType);
|
||||
DropClothing(SlotType);
|
||||
}
|
||||
|
||||
ClothingSlotData.ClothingItemInstance = ClothingItemInstance;
|
||||
|
||||
SetClothingSlotItem(SlotType, ClothingItemInstance);
|
||||
|
||||
USaveSubsystem* SaveSubsystem = UGameplayStatics::GetGameInstance(GetWorld())->GetSubsystem<USaveSubsystem>();
|
||||
FItemSaveRecord ItemSaveRecord;
|
||||
@@ -201,33 +175,32 @@ void UClothingManager::TakeClothing(UClothingItemInstance* ClothingItemInstance)
|
||||
|
||||
UClothingItemInstance* UClothingManager::RemoveClothing(const EClothingSlotType ClothingSlotType)
|
||||
{
|
||||
FClothingSlotData ClothingSlotData;
|
||||
if (!GetClothingSlotData(ClothingSlotType, ClothingSlotData) || !ClothingSlotData.ClothingItemInstance)
|
||||
UClothingItemInstance* ExistingItem = *EquippedClothing.Find(ClothingSlotType);
|
||||
if (!ExistingItem)
|
||||
{
|
||||
UE_LOG(LogTemp, Error, TEXT("Couldn't find clothing slot"));
|
||||
UE_LOG(LogTemp, Warning, TEXT("UClothingManager::RemoveClothing No clothing found"));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
UClothingItemInstance* ClothingItemInstance = ClothingSlotData.ClothingItemInstance;
|
||||
SetClothingSlotItem(ClothingSlotType, nullptr);
|
||||
|
||||
USkeletalMeshComponent* MeshComponent = GetMeshComponent(ClothingSlotType);
|
||||
MeshComponent->SetSkeletalMesh(nullptr);
|
||||
|
||||
if (ClothingItemInstance->GetClothingItem()->UseLeaderPose)
|
||||
if (ExistingItem->GetClothingItem()->UseLeaderPose)
|
||||
{
|
||||
MeshComponent->SetLeaderPoseComponent(nullptr);
|
||||
}
|
||||
|
||||
OnClothingUnequip.Broadcast(ClothingItemInstance);
|
||||
|
||||
OnClothingUnequip.Broadcast(ExistingItem);
|
||||
|
||||
USaveSubsystem* SaveSubsystem = UGameplayStatics::GetGameInstance(GetWorld())->GetSubsystem<USaveSubsystem>();
|
||||
SaveSubsystem->GetCurrentSave()->EquippedItems.RemoveAll([ClothingItemInstance](const FItemSaveRecord& Item)
|
||||
SaveSubsystem->GetCurrentSave()->EquippedItems.RemoveAll([ExistingItem](const FItemSaveRecord& Item)
|
||||
{
|
||||
return Item.InstanceId == ClothingItemInstance->GetInstanceId();
|
||||
return Item.InstanceId == ExistingItem->GetInstanceId();
|
||||
});
|
||||
|
||||
return ClothingItemInstance;
|
||||
|
||||
return ExistingItem;
|
||||
}
|
||||
|
||||
void UClothingManager::DropClothing(const EClothingSlotType ClothingType)
|
||||
@@ -246,14 +219,5 @@ void UClothingManager::DropClothing(const EClothingSlotType ClothingType)
|
||||
|
||||
bool UClothingManager::IsClothingTypeOn(const EClothingSlotType ClothingType)
|
||||
{
|
||||
FClothingSlotData ClothingSlotData;
|
||||
GetClothingSlotData(ClothingType, ClothingSlotData);
|
||||
|
||||
const bool IsTypeOn = ClothingSlotData.ClothingItemInstance != nullptr;
|
||||
return IsTypeOn;
|
||||
}
|
||||
|
||||
bool UClothingManager::IsPartiallyNaked()
|
||||
{
|
||||
return IsBodyTypeExposed(EBodyPart::Ass) || IsBodyTypeExposed(EBodyPart::Genitals) || IsBodyTypeExposed(EBodyPart::Boobs);
|
||||
return EquippedClothing.Contains(ClothingType);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user