Payback 0.0.1
CK Graduation Project
로딩중...
검색중...
일치하는것 없음
TargetableQueryContext 구조체 참조

#include <TargetableQuery.h>

TargetableQueryContext에 대한 협력 다이어그램:
Collaboration graph

Public 멤버 함수

 TargetableQueryContext (UWorld *InWorld, const TArray< ITargetableInterface * > &Targetables)
 
TargetableQueryContext & ResetCachedResult ()
 
TargetableQueryContext & CacheResult ()
 
TargetableQueryContext & FilterByLineOfSight ()
 
TargetableQueryContext & PickClosestFromCenter ()
 
TargetableQueryContext & FilterByClassType (UClass *ClassType)
 
TargetableQueryContext & GatherCandidates (float MaxLockOnDistance)
 
TargetableQueryContext & FilterByArrayRange (TArray< ITargetableInterface * > Array, int32 StartIdx, int32 EndIdx)
 
TargetableQueryContext & FindDistanceNearestEnemy (const FVector &Origin, float MaxRange)
 
TargetableQueryContext & FindDirectionNearestEnemy (const FVector &Origin, const FVector &Direction, float MaxRange)
 
TArray< ITargetableInterface * > GetTargets (const int32 StartIdx, const int32 EndIdx)
 
TArray< ITargetableInterface * > GetTargets (const int32 Count)
 
TArray< ITargetableInterface * > GetTargets () const
 
ITargetableInterface * GetTarget (const int32 Index=0)
 
TArray< ITargetableInterface * > GetInitialTargets () const
 
TArray< ITargetableInterface * > GetCachedTargets (const int32 StartIdx, const int32 EndIdx)
 
TArray< ITargetableInterface * > GetCachedTargets ()
 
ITargetableInterface * GetCachedTarget (const int32 Index=0)
 
bool IsCached () const
 
template<typename TActorClass >
TargetableQueryContext & FilterByClassType (TSubclassOf< TActorClass > ClassType)
 

Private 멤버 함수

bool CheckLineOfSight (ITargetableInterface *Target, TArray< FHitResult > HitResults) const
 

Private 속성

TArray< ITargetableInterface * > InitialTargets
 
TArray< ITargetableInterface * > CachedTargets
 
TArray< ITargetableInterface * > Targets
 
TObjectPtr< UWorld > World
 

생성자 & 소멸자 문서화

◆ TargetableQueryContext()

TargetableQueryContext::TargetableQueryContext ( UWorld *  InWorld,
const TArray< ITargetableInterface * > &  Targetables 
)
inline
10 {
11 InitialTargets = Targetables;
12 Targets = Targetables;
13 World = InWorld;
14 }
TArray< ITargetableInterface * > Targets
Definition TargetableQuery.h:87
TArray< ITargetableInterface * > InitialTargets
Definition TargetableQuery.h:85
TObjectPtr< UWorld > World
Definition TargetableQuery.h:88

다음을 참조함 : InitialTargets, Targets, World.

멤버 함수 문서화

◆ CacheResult()

TargetableQueryContext & TargetableQueryContext::CacheResult ( )
228{
230 return *this;
231}
TArray< ITargetableInterface * > CachedTargets
Definition TargetableQuery.h:86
TArray< ITargetableInterface * > GetTargets() const
Definition TargetableQuery.h:39

다음을 참조함 : CachedTargets, GetTargets().

다음에 의해서 참조됨 : UTargetingComponent::FindNearestTargetByDirection().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ CheckLineOfSight()

bool TargetableQueryContext::CheckLineOfSight ( ITargetableInterface *  Target,
TArray< FHitResult >  HitResults 
) const
private
316{
317 bool bIsBlocking = false;
318 const AActor* DamageTarget = ADamageProxy::ResolveDamageTarget(ITargetableInterface::AsActor(Target));
319
320 for (const FHitResult& Hit : HitResults)
321 {
322 if (Hit.Component.IsValid() && Hit.Component->GetCollisionProfileName() == CPROFILE_CKPLAYERCAPSULE)
323 {
324 continue;
325 }
326
327 // 프록시와 같은 본체에 속한 충돌은 타겟을 가리는 장애물이 아닙니다.
328 if (ADamageProxy::ResolveDamageTarget(Hit.GetActor()) != DamageTarget)
329 {
330 bIsBlocking = true;
331 break;
332 }
333 }
334
335 if (bIsBlocking)
336 {
337 return true;
338 }
339 else
340 {
341 return false;
342 }
343}
#define CPROFILE_CKPLAYERCAPSULE
Definition CK_Collision.h:16
static AActor * ResolveDamageTarget(AActor *HitActor)
Definition DamageProxy.cpp:138
static AActor * AsActor(ITargetableInterface *Interface)
Definition TargetableInterface.cpp:24

다음을 참조함 : ITargetableInterface::AsActor(), CPROFILE_CKPLAYERCAPSULE, ADamageProxy::ResolveDamageTarget().

다음에 의해서 참조됨 : FilterByLineOfSight().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ FilterByArrayRange()

TargetableQueryContext & TargetableQueryContext::FilterByArrayRange ( TArray< ITargetableInterface * >  Array,
int32  StartIdx,
int32  EndIdx 
)
199{
200 TArray<ITargetableInterface*> Result;
201
202 if (StartIdx > EndIdx || StartIdx < 0 || EndIdx < 0 || StartIdx >= Array.Num() || Array.Num() <= EndIdx)
203 {
204 return *this;
205 }
206
207 Result.Reserve(EndIdx - StartIdx + 1);
208
209 for (int32 Idx = StartIdx; Idx <= EndIdx; ++Idx)
210 {
211 Result.Add(Array[Idx]);
212 }
213
214 Targets = Result;
215 return *this;
216}

다음을 참조함 : Targets.

다음에 의해서 참조됨 : GetCachedTargets(), GetTargets().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ FilterByClassType() [1/2]

template<typename TActorClass >
TargetableQueryContext & TargetableQueryContext::FilterByClassType ( TSubclassOf< TActorClass >  ClassType)
inline
77 {
78 return FilterByClassType(ClassType.Get());
79 }
TargetableQueryContext & FilterByClassType(UClass *ClassType)
Definition TargetableQuery.cpp:291

다음을 참조함 : FilterByClassType().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

◆ FilterByClassType() [2/2]

TargetableQueryContext & TargetableQueryContext::FilterByClassType ( UClass *  ClassType)

프록시는 본체 클래스에도 포함하되, 위치와 마커를 담당하는 원래 후보를 유지합니다.

292{
293 checkf(ClassType, TEXT("%s는 nullptr 일 수 없습니다. "), NAMEOF(UClass));
294
295 TArray<ITargetableInterface*> ResultArray;
296
297 for (ITargetableInterface* Target : Targets)
298 {
299 AActor* TargetActor = ITargetableInterface::AsActor(Target);
300 const AActor* DamageTarget = ADamageProxy::ResolveDamageTarget(TargetActor);
301
302 if (TargetActor == nullptr || (TargetActor->IsA(ClassType) == false && (DamageTarget == nullptr || DamageTarget->IsA(ClassType) == false)))
303 {
304 continue;
305 }
306
307 ResultArray.Add(Target);
308 }
309
310 Targets = ResultArray;
311 return *this;
312}
#define NAMEOF(Type)
Definition CK_UE.h:31
Definition TargetableInterface.h:20

다음을 참조함 : ITargetableInterface::AsActor(), NAMEOF, ADamageProxy::ResolveDamageTarget(), Targets.

다음에 의해서 참조됨 : FilterByClassType(), UGA_Skill_Strike::FindStrikeTarget().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ FilterByLineOfSight()

TargetableQueryContext & TargetableQueryContext::FilterByLineOfSight ( )
235{
236 if (World == nullptr || Targets.IsEmpty())
237 {
238 return *this;
239 }
240
241 const APlayerController* PC = GEngine->GetFirstLocalPlayerController(World);
242
243 if (PC == nullptr || PC->PlayerCameraManager == nullptr)
244 {
245 return *this;
246 }
247
248 FCollisionQueryParams Params(SCENE_QUERY_STAT(FilterByLineOfSight), false);
249
250 if (IsValid(PC->GetPawn()))
251 {
252 Params.AddIgnoredActor(PC->GetPawn());
253 }
254
255 TArray<ITargetableInterface*> ResultArray;
256 const FVector Offset = FVector(100.f, 0.0f, 0.0f);
257 const FVector TraceStart = PC->PlayerCameraManager->GetCameraLocation();
258
259 for (ITargetableInterface* Target : Targets)
260 {
261 if (Target->IsTargetValid() == false || Target->IsTargetable() == false)
262 {
263 continue;
264 }
265
266 const FVector TargetLocation = Target->GetTargetedActorLocation() + Offset;
267 TArray<FHitResult> HitResults;
268
269 World->LineTraceMultiByChannel
270 (
271 HitResults,
272 TraceStart,
273 TargetLocation,
274 ECC_Visibility,
275 Params
276 );
277
278 if (CheckLineOfSight(Target, HitResults))
279 {
280 continue;
281 }
282
283 ResultArray.Add(Target);
284 }
285
286 Targets = ResultArray;
287 return *this;
288}
TargetableQueryContext & FilterByLineOfSight()
Definition TargetableQuery.cpp:234
bool CheckLineOfSight(ITargetableInterface *Target, TArray< FHitResult > HitResults) const
Definition TargetableQuery.cpp:315

다음을 참조함 : CheckLineOfSight(), FilterByLineOfSight(), Targets, World.

다음에 의해서 참조됨 : FilterByLineOfSight(), UTargetingComponent::FindClosestTarget(), UTargetingComponent::FindTargetsInRange().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ FindDirectionNearestEnemy()

TargetableQueryContext & TargetableQueryContext::FindDirectionNearestEnemy ( const FVector &  Origin,
const FVector &  Direction,
float  MaxRange 
)
114{
115 const float InputDirThreshold = GetDefault<UCharacterCombatSettings>()->GetInputDirThreshold();
116 float NearestDistSq = FMath::Square(MaxRange);
117 ITargetableInterface* Result = nullptr;
118
119 for (ITargetableInterface* Target : Targets)
120 {
121 if (Target->IsTargetValid() == false || Target->IsTargetable() == false)
122 {
123 continue;
124 }
125
126 const FVector ToTarget = Target->GetTargetedActorLocation() - Origin;
127 const float DistSq = ToTarget.SizeSquared();
128
129 if (DistSq > FMath::Square(MaxRange))
130 {
131 continue;
132 }
133
134 FVector ToTargetFlat(ToTarget.X, ToTarget.Y, 0.f);
135 ToTargetFlat.Normalize();
136
137 // 입력 방향과의 각도가 임계값 미만이면 해당 방향에 없는 적으로 판정.
138 if (FVector::DotProduct(Direction, ToTargetFlat) < InputDirThreshold)
139 {
140 continue;
141 }
142
143 // 입력 방향 안에 있는 적 중 가장 가까운 적을 선택.
144 if (DistSq > NearestDistSq)
145 {
146 continue;
147 }
148
149 NearestDistSq = DistSq;
150 Result = Target;
151 }
152
153 Targets.Reset();
154
155 if (Result)
156 {
157 Targets.Add(Result);
158 }
159
160 return *this;
161}
virtual FVector GetTargetedActorLocation()
Definition TargetableInterface.cpp:95

다음을 참조함 : ITargetableInterface::GetTargetedActorLocation(), Targets.

다음에 의해서 참조됨 : UTargetingComponent::FindNearestTargetByDirection(), UGA_Skill_Strike::FindStrikeTarget().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ FindDistanceNearestEnemy()

TargetableQueryContext & TargetableQueryContext::FindDistanceNearestEnemy ( const FVector &  Origin,
float  MaxRange 
)
165{
166 ITargetableInterface* Result = nullptr;
167 float NearestDistSq = FMath::Square(MaxRange);
168
169 for (ITargetableInterface* Target : Targets)
170 {
171 if (Target->IsTargetValid() == false || Target->IsTargetable() == false)
172 {
173 continue;
174 }
175
176 const float DistSq = FVector::DistSquared(Target->GetTargetedActorLocation(), Origin);
177
178 if (DistSq >= NearestDistSq)
179 {
180 continue;
181 }
182
183 NearestDistSq = DistSq;
184 Result = Target;
185 }
186
187 Targets.Reset();
188
189 if (Result)
190 {
191 Targets.Add(Result);
192 }
193
194 return *this;
195}

다음을 참조함 : Targets.

다음에 의해서 참조됨 : UTargetingComponent::FindNearestTargetByDirection(), UGA_Skill_Strike::FindStrikeTarget().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ GatherCandidates()

TargetableQueryContext & TargetableQueryContext::GatherCandidates ( float  MaxLockOnDistance)
11{
12 TArray<ITargetableInterface*> ResultArray;
13
14 if (World == nullptr)
15 {
16 return *this;
17 }
18
19 const APlayerController* PC = GEngine->GetFirstLocalPlayerController(World);
20
21 if (PC == nullptr || PC->PlayerCameraManager == nullptr)
22 {
23 return *this;
24 }
25
26 const FVector CameraLocation = PC->PlayerCameraManager->GetCameraLocation();
27 const float MaxDistSq = FMath::Square(MaxLockOnDistance);
28
29 for (ITargetableInterface* Target : Targets)
30 {
31 if (Target->IsTargetValid() == false || Target->IsTargetable() == false)
32 {
33 continue;
34 }
35
36 const FVector ToTarget = Target->GetTargetedActorLocation() - CameraLocation;
37 const float DistSq = ToTarget.SizeSquared();
38
39 if (DistSq > MaxDistSq || DistSq <= KINDA_SMALL_NUMBER)
40 {
41 continue;
42 }
43
44 ResultArray.Add(Target);
45 }
46
47 Targets = ResultArray;
48 return *this;
49}

다음을 참조함 : Targets, World.

다음에 의해서 참조됨 : UTargetingComponent::FindClosestTarget(), UTargetingComponent::FindTargetsInRange().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ GetCachedTarget()

ITargetableInterface * TargetableQueryContext::GetCachedTarget ( const int32  Index = 0)
inline
65 {
66 return CachedTargets.IsEmpty() ? nullptr : CachedTargets.IsValidIndex(Index) ? CachedTargets[Index] : nullptr;
67 }

다음을 참조함 : CachedTargets.

다음에 의해서 참조됨 : UTargetingComponent::FindNearestTargetByDirection().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ GetCachedTargets() [1/2]

TArray< ITargetableInterface * > TargetableQueryContext::GetCachedTargets ( )
inline
60 {
61 return CachedTargets;
62 }

다음을 참조함 : CachedTargets.

◆ GetCachedTargets() [2/2]

TArray< ITargetableInterface * > TargetableQueryContext::GetCachedTargets ( const int32  StartIdx,
const int32  EndIdx 
)
inline
55 {
56 return FilterByArrayRange(CachedTargets, StartIdx, EndIdx).GetTargets();;
57 }
TargetableQueryContext & FilterByArrayRange(TArray< ITargetableInterface * > Array, int32 StartIdx, int32 EndIdx)
Definition TargetableQuery.cpp:198
TArray< ITargetableInterface * > GetTargets(const int32 StartIdx, const int32 EndIdx)
Definition TargetableQuery.h:29

다음을 참조함 : CachedTargets, FilterByArrayRange(), GetTargets().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

◆ GetInitialTargets()

TArray< ITargetableInterface * > TargetableQueryContext::GetInitialTargets ( ) const
inline
50 {
51 return InitialTargets;
52 }

다음을 참조함 : InitialTargets.

◆ GetTarget()

ITargetableInterface * TargetableQueryContext::GetTarget ( const int32  Index = 0)
inline
45 {
46 return Targets.IsEmpty() ? nullptr : Targets.IsValidIndex(Index) ? Targets[Index] : nullptr;
47 }

다음을 참조함 : Targets.

다음에 의해서 참조됨 : UTargetingComponent::FindClosestTarget(), UTargetingComponent::FindNearestTargetByDirection(), UGA_Skill_Strike::FindStrikeTarget().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ GetTargets() [1/3]

TArray< ITargetableInterface * > TargetableQueryContext::GetTargets ( ) const
inline
40 {
41 return Targets;
42 }

다음을 참조함 : Targets.

다음에 의해서 참조됨 : CacheResult(), GetTargets().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ GetTargets() [2/3]

TArray< ITargetableInterface * > TargetableQueryContext::GetTargets ( const int32  Count)
inline
35 {
36 return GetTargets(0, Count);
37 }

다음을 참조함 : GetTargets().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

◆ GetTargets() [3/3]

TArray< ITargetableInterface * > TargetableQueryContext::GetTargets ( const int32  StartIdx,
const int32  EndIdx 
)
inline
30 {
31 return FilterByArrayRange(Targets, StartIdx, EndIdx).GetTargets();
32 }

다음을 참조함 : FilterByArrayRange(), GetTargets(), Targets.

다음에 의해서 참조됨 : UGA_Skill_Strike::FindStrikeTarget(), UTargetingComponent::FindTargetsInRange(), GetCachedTargets(), TargetableQuery::GetTargets(), GetTargets().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ IsCached()

bool TargetableQueryContext::IsCached ( ) const
inline
70 {
71 return !CachedTargets.IsEmpty();
72 }

다음을 참조함 : CachedTargets.

◆ PickClosestFromCenter()

TargetableQueryContext & TargetableQueryContext::PickClosestFromCenter ( )
53{
54 if (Targets.IsEmpty() || World == nullptr)
55 {
56 return *this;
57 }
58
59 const APlayerController* PC = GEngine->GetFirstLocalPlayerController(World);
60
61 if (PC == nullptr || PC->PlayerCameraManager == nullptr)
62 {
63 return *this;
64 }
65
66 const FVector CameraLocation = PC->PlayerCameraManager->GetCameraLocation();
67 const FVector CameraForward = PC->PlayerCameraManager->GetCameraRotation().Vector();
68
69 ITargetableInterface* Best = nullptr;
70 float BestDot = -2.0f;
71 float BestDistSq = TNumericLimits<float>::Max();
72
73 for (ITargetableInterface* Target : Targets)
74 {
75 if (Target->IsTargetValid() == false || Target->IsTargetable() == false)
76 {
77 continue;
78 }
79
80 const FVector ToTarget = Target->GetTargetedActorLocation() - CameraLocation;
81 const float DistSq = ToTarget.SizeSquared();
82
83 if (DistSq < KINDA_SMALL_NUMBER)
84 {
85 continue;
86 }
87
88 const FVector ToTargetDir = ToTarget / FMath::Sqrt(DistSq);
89 const float Dot = FVector::DotProduct(CameraForward, ToTargetDir);
90
91 // 1순위: 화면 중앙에 더 가까운 적 (Dot이 큰 쪽)
92 // 2순위: 동률(혹은 매우 근소한 차이)일 때 더 가까운 적
93
94 if (FMath::IsNearlyEqual(Dot, BestDot, KINDA_SMALL_NUMBER) ? (DistSq < BestDistSq) : (Dot > BestDot))
95 {
96 Best = Target;
97 BestDot = Dot;
98 BestDistSq = DistSq;
99 }
100 }
101
102 Targets.Reset();
103
104 if (Best)
105 {
106 Targets.Add(Best);
107 }
108
109 return *this;
110}

다음을 참조함 : Targets, World.

다음에 의해서 참조됨 : UTargetingComponent::FindClosestTarget().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ ResetCachedResult()

TargetableQueryContext & TargetableQueryContext::ResetCachedResult ( )
220{
222 CachedTargets.Reset();
223 return *this;
224}

다음을 참조함 : CachedTargets, InitialTargets, Targets.

다음에 의해서 참조됨 : UTargetingComponent::FindNearestTargetByDirection(), UGA_Skill_Strike::FindStrikeTarget().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

멤버 데이터 문서화

◆ CachedTargets

TArray<ITargetableInterface*> TargetableQueryContext::CachedTargets
private

◆ InitialTargets

TArray<ITargetableInterface*> TargetableQueryContext::InitialTargets
private

◆ Targets

◆ World

TObjectPtr<UWorld> TargetableQueryContext::World
private

이 구조체에 대한 문서화 페이지는 다음의 파일들로부터 생성되었습니다.: