QuickTween 1.4.1
Loading...
Searching...
No Matches
FQuickTweenLatentAction.h
1// Copyright 2025 Juan Pablo Hernandez Mosti. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "LatentActions.h"
7#include "Engine/LatentActionManager.h"
8#include "FQuickTweenLatentAction.generated.h"
9
10struct FLatentResponse;
11
19UENUM()
20enum class EQuickTweenLatentSteps : uint8
21{
23 Default,
25 OnStart,
27 OnUpdate,
29 OnLoop,
31 OnComplete,
33 OnKilled
34};
35
43class FQuickTweenLatentAction : public FPendingLatentAction
44{
45public:
55 template<typename T>
56 FQuickTweenLatentAction(const FLatentActionInfo& latentInfo, T* tweenObj, EQuickTweenLatentSteps& outLatentStep);
57
65 virtual void UpdateOperation(FLatentResponse& Response) override;
66
67private:
69 FName ExecutionFunction;
70
72 int32 OutputLink;
73
75 FWeakObjectPtr CallbackTarget;
76
78 bool bIsFirstUpdate;
79
81 EQuickTweenLatentSteps* StepPtr = nullptr;
82
84 TArray<EQuickTweenLatentSteps> Buffer;
85
94 void HandleStep(EQuickTweenLatentSteps NewStep);
95};
96
97template <typename T>
99 const FLatentActionInfo& latentInfo,
100 T* tweenObj,
101 EQuickTweenLatentSteps& outLatentStep)
102 : ExecutionFunction(latentInfo.ExecutionFunction),
103 OutputLink(latentInfo.Linkage),
104 CallbackTarget(latentInfo.CallbackTarget),
105 bIsFirstUpdate(true),
106 StepPtr(&outLatentStep)
107{
108 Buffer.Reserve(50);
109
110 HandleStep(EQuickTweenLatentSteps::Default);
111
112 tweenObj->OnStart.AddLambda([this](T*)
113 {
114 HandleStep(EQuickTweenLatentSteps::OnStart);
115 });
116
117 tweenObj->OnUpdate.AddLambda([this](T*)
118 {
119 HandleStep(EQuickTweenLatentSteps::OnUpdate);
120 });
121
122 tweenObj->OnComplete.AddLambda([this](T*)
123 {
124 HandleStep(EQuickTweenLatentSteps::OnComplete);
125 });
126
127 tweenObj->OnKilled.AddLambda([this](T*)
128 {
129 HandleStep(EQuickTweenLatentSteps::OnKilled);
130 });
131
132 tweenObj->OnLoop.AddLambda([this](T*)
133 {
134 HandleStep(EQuickTweenLatentSteps::OnLoop);
135 });
136}
137
virtual void UpdateOperation(FLatentResponse &Response) override
Definition FQuickTweenLatentAction.cpp:14
FQuickTweenLatentAction(const FLatentActionInfo &latentInfo, T *tweenObj, EQuickTweenLatentSteps &outLatentStep)
Definition FQuickTweenLatentAction.h:98