Payback 0.0.1
CK Graduation Project
로딩중...
검색중...
일치하는것 없음
TargetingComponent.h
이 파일의 문서화 페이지로 가기
1// Fill out your copyright notice in the Description page of Project Settings.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "Components/ActorComponent.h"
8#include "TargetingComponent.generated.h"
9
11
12
13DECLARE_MULTICAST_DELEGATE_OneParam(FOnHardLockTargetChangedSignature, ITargetableInterface* /*NewTarget*/);
14
15
16UENUM()
17enum class ETargetingMode : uint8
18{
19 SoftTargeting UMETA(DisplayName = "소프트 타겟팅", ToolTip = "상호작용(공격도 포함) 범위 안에 들어있는 대상"),
20 HardTargeting UMETA(DisplayName = "하드 하겟팅", ToolTip = "유저 입력으로 UI와 카메라 방향 고정으로 지목된 대상")
21};
22
23
24UCLASS(ClassGroup=(Combat), meta=(BlueprintSpawnableComponent))
25class CK_UE_API UTargetingComponent : public UActorComponent
26{
27 GENERATED_BODY()
28
29public:
30 UTargetingComponent();
31
32public:
33 void SetHardLockTarget(ITargetableInterface* NewTarget);
34 void ResetHardLockTarget();
35 void ClearHardLockTarget();
36
37 ITargetableInterface* FindClosestTarget(float MaxRange) const;
38 TArray<ITargetableInterface*> FindTargetsInRange(float MaxRange) const;
39 ITargetableInterface* FindNearestTargetByDirection(const FVector& Origin, const FVector& Direction, float MaxRange) const;
40
41 FOnHardLockTargetChangedSignature OnHardLockTargetChanged;
42
43 // --- 암시적 타겟 (Soft Lock) : 사거리 내 자동 판정, 카메라 고정 없음 (모션 워핑용) ---
44 void SetSoftLockTarget(ITargetableInterface* Result);
45 void ResetSoftLockTarget();
46 ITargetableInterface* AcquireLockTarget(const FVector& Direction, float MaxRange);
47
48public:
49 // --- 명시적 타겟 (Hard Lock) : 입력으로 고정, 카메라 방향까지 함께 고정 ---
50 UFUNCTION(BlueprintPure, Category = "Targeting")
51 bool HasHardLockTarget() const;
52
53 UFUNCTION(BlueprintPure, Category = "Targeting")
54 TScriptInterface<ITargetableInterface> GetHardLockTarget() const;
55
56 UFUNCTION(BlueprintPure, Category = "Targeting")
57 TScriptInterface<ITargetableInterface> GetSoftLockTarget() const;
58
59public:
60 FORCEINLINE ITargetableInterface* GetHardLockTargetable() const
61 {
62 return HardLockTarget.GetInterface();
63 }
64
65public:
66 // 현재 락온 대상(하드 락 우선, 없으면 소프트 락)이 몬스터(AEnemyCharacterBase)면 반환, 아니면 nullptr.
67 AEnemyCharacterBase* GetCurrentMonsterTarget() const;
68
69private:
70 UPROPERTY()
71 TScriptInterface<ITargetableInterface> HardLockTarget;
72
73private:
74 TWeakObjectPtr<AActor> SoftLockTargetActor;
75 bool bSoftLockActive = false;
76};
DECLARE_MULTICAST_DELEGATE_OneParam(FOnHardLockTargetChangedSignature, ITargetableInterface *)
ETargetingMode
Definition TargetingComponent.h:18
Definition EnemyCharacterBase.h:49
Definition TargetableInterface.h:20