UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
LatentActions.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
7
8// The response to updating a latent action
10{
11private:
12 struct FExecutionInfo
13 {
14 public:
15 FName ExecutionFunction;
16 int32 LinkID;
17 FWeakObjectPtr CallbackTarget;
18
20 : ExecutionFunction(InExecutionFunction)
21 , LinkID(InLinkID)
22 , CallbackTarget(InCallbackTarget)
23 {
24 }
25
26 private:
27 FExecutionInfo()
28 {
29 }
30
31 };
32
33protected:
36 float DeltaTime;
37
38 friend struct FLatentActionManager;
39public:
45
46 FLatentResponse& DoneIf(bool Condition)
47 {
48 bRemoveAction = Condition;
49 return *this;
50 }
51
53 {
54 LinksToExecute.Add(FExecutionInfo(ExecutionFunction, LinkID, InCallbackTarget));
55 return *this;
56 }
57
58 FLatentResponse& FinishAndTriggerIf(bool Condition, FName ExecutionFunction, int32 LinkID, FWeakObjectPtr InCallbackTarget)
59 {
60 bRemoveAction = Condition;
61 if (bRemoveAction)
62 {
63 LinksToExecute.Add(FExecutionInfo(ExecutionFunction, LinkID, InCallbackTarget));
64 }
65 return *this;
66 }
67
68 float ElapsedTime() const { return DeltaTime; }
69};
70
71// A pending latent action
73{
74public:
78
80 {
81 }
82
83 // Return true when the action is completed
85 {
86 Response.DoneIf(true);
87 }
88
89 // Lets the latent action know that the object which originated it has been garbage collected
90 // and the action is going to be destroyed (no more UpdateOperation calls will occur and
91 // CallbackTarget is already NULL)
92 // This is only called when the object goes away before the action is finished; perform normal
93 // cleanup when responding that the action is completed in UpdateOperation
94 virtual void NotifyObjectDestroyed() {}
95
96 virtual void NotifyActionAborted() {}
97#if WITH_EDITOR
98 // Returns a human readable description of the latent operation's current state
99 ENGINE_API virtual FString GetDescription() const;
100#endif
101};
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
auto Response
Definition ExternalRpcRegistry.cpp:598
Definition NameTypes.h:617
Definition LatentActions.h:73
virtual ~FPendingLatentAction()
Definition LatentActions.h:79
virtual void UpdateOperation(FLatentResponse &Response)
Definition LatentActions.h:84
virtual void NotifyObjectDestroyed()
Definition LatentActions.h:94
FPendingLatentAction()
Definition LatentActions.h:75
virtual void NotifyActionAborted()
Definition LatentActions.h:96
Definition Array.h:670
@ false
Definition radaudio_common.h:23
Definition LatentActions.h:10
FLatentResponse & TriggerLink(FName ExecutionFunction, int32 LinkID, FWeakObjectPtr InCallbackTarget)
Definition LatentActions.h:52
FLatentResponse & DoneIf(bool Condition)
Definition LatentActions.h:46
friend struct FLatentActionManager
Definition LatentActions.h:38
FLatentResponse & FinishAndTriggerIf(bool Condition, FName ExecutionFunction, int32 LinkID, FWeakObjectPtr InCallbackTarget)
Definition LatentActions.h:58
bool bRemoveAction
Definition LatentActions.h:35
float ElapsedTime() const
Definition LatentActions.h:68
TArray< FExecutionInfo, TInlineAllocator< 4 > > LinksToExecute
Definition LatentActions.h:34
float DeltaTime
Definition LatentActions.h:36
FLatentResponse(float InDeltaTime)
Definition LatentActions.h:40
Definition WeakObjectPtr.h:49