// © 2025 Naked People Team. All Rights Reserved. #include "InteractionManager.h" #include "Kismet/GameplayStatics.h" #include "NakedDesire/Player/NakedDesireCharacter.h" UInteractionManager::UInteractionManager() { PrimaryComponentTick.bCanEverTick = false; } void UInteractionManager::OnTargetEnter(const TScriptInterface& Target) { InteractionTargets.Add(Target); } void UInteractionManager::OnTargetExit(const TScriptInterface& Target) { InteractionTargets.Remove(Target); } TScriptInterface UInteractionManager::GetNearestInteractionTarget() { const ANakedDesireCharacter* Player = Cast(UGameplayStatics::GetPlayerCharacter(GetWorld(), 0)); TScriptInterface Target; for (const auto& Elem : InteractionTargets) { const AActor* Actor = Cast(Elem.GetObject()); const AActor* TargetActor = Target ? Cast(Target.GetObject()) : nullptr; if (!Target || FVector::Distance(Player->GetActorLocation(), Actor->GetActorLocation()) < FVector::Distance(Player->GetActorLocation(), TargetActor->GetActorLocation())) { Target = Elem; } } return Target; }