KLingo Project Documentation 1.0.0
Unreal Engine 5.6 C++ Project Documentation
로딩중...
검색중...
일치하는것 없음
USequenceManager.cpp
이 파일의 문서화 페이지로 가기
1// Copyright (c) 2025 Doppleddiggong. All rights reserved. Unauthorized copying, modification, or distribution of this file, via any medium is strictly prohibited. Proprietary and confidential.
2
8#include "USequenceManager.h"
10#include "TimerManager.h"
11#include "Engine/World.h"
12
13void USequenceManager::RequestSequential(const TArray<AActor*>& Targets,
14 bool bActivate,
15 float InitialDelay,
16 float Interval,
17 float Duration)
18{
19 CancelAll();
20
21 Queue.Reset();
22 Queue.Reserve(Targets.Num());
23
24 for (AActor* A : Targets)
25 {
26 if (!IsValid(A))
27 continue;
28
30 Cmd.Target = A;
31 Cmd.bActivate = bActivate;
32 Cmd.Duration = Duration;
33 Queue.Add(MoveTemp(Cmd));
34 }
35
36 Index = 0;
37 StepInterval = FMath::Max(0.f, Interval);
38
39 if (!GetWorld() || Queue.Num() == 0)
40 return;
41
42 GetWorld()->GetTimerManager().SetTimer(
44 this,
46 (StepInterval <= KINDA_SMALL_NUMBER) ? 0.0f : StepInterval, // 0이면 프레임마다 처리
47 (StepInterval > KINDA_SMALL_NUMBER), // 반복 타이머 여부
48 FMath::Max(0.f, InitialDelay) // 초기 지연
49 );
50
51 if (StepInterval <= KINDA_SMALL_NUMBER)
52 TickStep();
53}
54
56{
57 if (Queue.Num() == 0)
58 {
59 CancelAll();
60 return;
61 }
62
63 const int32 MaxPerTick = (StepInterval > KINDA_SMALL_NUMBER) ? 1 : 8;
64
65 int32 Processed = 0;
66 while (Index < Queue.Num() && Processed < MaxPerTick)
67 {
68 const FSequenceCommand& Cmd = Queue[Index];
69
70 AActor* Target = Cmd.Target.Get();
71 if (IsValid(Target) && Target->GetClass()->ImplementsInterface(USequenceActivatable::StaticClass()))
72 {
73 if (Cmd.bActivate)
74 {
75 ISequenceActivatable::Execute_Activate(Target, Index, Queue.Num(), Cmd.Duration);
76 }
77 else
78 {
79 ISequenceActivatable::Execute_Deactivate(Target, Index, Queue.Num(), Cmd.Duration);
80 }
81 }
82
83 ++Index;
84 ++Processed;
85 }
86
87 if (Index >= Queue.Num())
88 {
89 CancelAll();
90 }
91}
92
94{
95 if (UWorld* World = GetWorld())
96 {
97 World->GetTimerManager().ClearTimer(MainHandle);
98 }
99 Queue.Reset();
100 Index = 0;
101}
USequenceActivatable 클래스를 선언합니다.
USequenceManager 클래스를 선언합니다.
TArray< FSequenceCommand > Queue
void RequestSequential(const TArray< AActor * > &Targets, bool bActivate, float InitialDelay=0.f, float Interval=0.1f, float Duration=0.5f)
0.1초 간격으로 Targets를 순차 Activate/Deactivate InitialDelay: 첫 실행 지연 Interval : 대상 간 간격(예: 0....
FTimerHandle MainHandle
USequenceManager에서 처리할 개별 시퀀스 명령을 정의하는 구조체입니다.
TWeakObjectPtr< AActor > Target