51 lines
1.0 KiB
C++
51 lines
1.0 KiB
C++
// © 2025 Naked People Team. All Rights Reserved.
|
|
|
|
|
|
#include "DroppedClothingSubsystem.h"
|
|
|
|
#include "NakedDesire/Interactables/ItemPickup.h"
|
|
|
|
void UDroppedClothingSubsystem::RegisterPickup(AItemPickup* Pickup)
|
|
{
|
|
if (Pickup)
|
|
Pickups.AddUnique(Pickup);
|
|
}
|
|
|
|
void UDroppedClothingSubsystem::UnregisterPickup(AItemPickup* Pickup)
|
|
{
|
|
Pickups.RemoveSingleSwap(Pickup);
|
|
}
|
|
|
|
bool UDroppedClothingSubsystem::HasDroppedClothing() const
|
|
{
|
|
for (const TObjectPtr<AItemPickup>& Pickup : Pickups)
|
|
{
|
|
if (Pickup)
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool UDroppedClothingSubsystem::GetDistanceToNearestDroppedClothing(const FVector& From, float& OutDistance) const
|
|
{
|
|
float NearestSq = TNumericLimits<float>::Max();
|
|
bool bFound = false;
|
|
|
|
for (const TObjectPtr<AItemPickup>& Pickup : Pickups)
|
|
{
|
|
if (!Pickup)
|
|
continue;
|
|
|
|
const float DistSq = FVector::DistSquared(From, Pickup->GetActorLocation());
|
|
if (DistSq < NearestSq)
|
|
{
|
|
NearestSq = DistSq;
|
|
bFound = true;
|
|
}
|
|
}
|
|
|
|
if (bFound)
|
|
OutDistance = FMath::Sqrt(NearestSq);
|
|
|
|
return bFound;
|
|
} |