Cleanup
This commit is contained in:
@@ -1,41 +0,0 @@
|
|||||||
// © 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<IInteractionTarget>& Target)
|
|
||||||
{
|
|
||||||
InteractionTargets.Add(Target);
|
|
||||||
}
|
|
||||||
|
|
||||||
void UInteractionManager::OnTargetExit(const TScriptInterface<IInteractionTarget>& Target)
|
|
||||||
{
|
|
||||||
InteractionTargets.Remove(Target);
|
|
||||||
}
|
|
||||||
|
|
||||||
TScriptInterface<IInteractionTarget> UInteractionManager::GetNearestInteractionTarget()
|
|
||||||
{
|
|
||||||
const ANakedDesireCharacter* Player = Cast<ANakedDesireCharacter>(UGameplayStatics::GetPlayerCharacter(GetWorld(), 0));
|
|
||||||
TScriptInterface<IInteractionTarget> Target;
|
|
||||||
for (const auto& Elem : InteractionTargets)
|
|
||||||
{
|
|
||||||
const AActor* Actor = Cast<AActor>(Elem.GetObject());
|
|
||||||
const AActor* TargetActor = Target ? Cast<AActor>(Target.GetObject()) : nullptr;
|
|
||||||
if (!Target || FVector::Distance(Player->GetActorLocation(), Actor->GetActorLocation()) < FVector::Distance(Player->GetActorLocation(), TargetActor->GetActorLocation()))
|
|
||||||
{
|
|
||||||
Target = Elem;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return Target;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
// © 2025 Naked People Team. All Rights Reserved.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
|
||||||
#include "InteractionTarget.h"
|
|
||||||
#include "Components/ActorComponent.h"
|
|
||||||
#include "InteractionManager.generated.h"
|
|
||||||
|
|
||||||
|
|
||||||
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
|
|
||||||
class NAKEDDESIRE_API UInteractionManager : public UActorComponent
|
|
||||||
{
|
|
||||||
GENERATED_BODY()
|
|
||||||
|
|
||||||
UPROPERTY()
|
|
||||||
TArray<TScriptInterface<IInteractionTarget>> InteractionTargets;
|
|
||||||
|
|
||||||
public:
|
|
||||||
UInteractionManager();
|
|
||||||
|
|
||||||
void OnTargetEnter(const TScriptInterface<IInteractionTarget>& Target);
|
|
||||||
void OnTargetExit(const TScriptInterface<IInteractionTarget>& Target);
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable)
|
|
||||||
TScriptInterface<IInteractionTarget> GetNearestInteractionTarget();
|
|
||||||
};
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
// © 2025 Naked People Team. All Rights Reserved.
|
|
||||||
|
|
||||||
|
|
||||||
#include "InteractionTarget.h"
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
// © 2025 Naked People Team. All Rights Reserved.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
|
||||||
#include "UObject/Interface.h"
|
|
||||||
#include "InteractionTarget.generated.h"
|
|
||||||
|
|
||||||
// This class does not need to be modified.
|
|
||||||
UINTERFACE(MinimalAPI)
|
|
||||||
class UInteractionTarget : public UInterface
|
|
||||||
{
|
|
||||||
GENERATED_BODY()
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class NAKEDDESIRE_API IInteractionTarget
|
|
||||||
{
|
|
||||||
GENERATED_BODY()
|
|
||||||
|
|
||||||
// Add interface functions to this class. This is the class that will be inherited to implement this interface.
|
|
||||||
public:
|
|
||||||
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Interaction Target")
|
|
||||||
void Interact();
|
|
||||||
};
|
|
||||||
Reference in New Issue
Block a user