8#include "CoreMinimal.h"
9#include "GameFramework/Actor.h"
10#include "UObject/Object.h"
11#include "Delegates/IDelegateInstance.h"
12#include "Async/TaskGraphInterfaces.h"
13#include "GenericPlatform/GenericPlatformMisc.h"
14#include "Engine/World.h"
20#include "TickManager.generated.h"
29 FullFrameTaskParallel
UMETA(DisplayName =
"FullFrameTaskParallel"),
35 FullFrameTaskBeforeLateTickParallel
UMETA(DisplayName =
"FullFrameTaskBeforeLateTickParallel"),
40 EarlyTickParallel
UMETA(DisplayName =
"EarlyTickParallel"),
46 LateTickParallel
UMETA(DisplayName =
"LateTickParallel"),
62 std::function<
void(
float)> Tick;
69 : Owner(InOwner), Tick(InTickFunction), TickType(InType) {}
117 static FTickEntry AddTick(UObject* Object, std::function<
void(
float)> Function,
ETickType Type);
134 virtual void BeginPlay()
override;
135 virtual void EndPlay(
const EEndPlayReason::Type EndPlayReason)
override;
138 void PreTick(UWorld* World, ELevelTick TickType,
float DeltaSeconds);
141 void PostTick(UWorld* World, ELevelTick TickType,
float DeltaSeconds);
145 inline void TickFunctionsParallel(std::vector<FTickEntry>& functions,
const float DeltaTime);
159 bool found = std::find_if(to.begin(), to.end(), [&](
const FTickEntry& entry) {
160 return (entry.Owner == newTickEntry.Owner && entry.TickType == newTickEntry.TickType);
165 to.emplace_back(newTickEntry);
170 UE_LOG(LogTemp, Warning, TEXT(
"TickManager.h: This entry already exists. Returning."));
177 from.erase(std::remove(from.begin(), from.end(), tickEntry), from.end());
181template <
typename ObjectType,
typename FunctionType>
182static auto BindTick(ObjectType* Object, FunctionType Function)
184 return [Object, Function](
float DeltaTime)
186 (Object->*Function)(DeltaTime);
static auto BindTick(ObjectType *Object, FunctionType Function)
FDelegateHandle OnPreTickDelegate
static std::vector< FTickEntry > LateTickFunctions
static std::vector< FTickEntry > TicksToRemove
static std::vector< FTickEntry > FullFrameTaskBeforeLateTickFunctions
static std::vector< FTickEntry > EarlyTickFunctions
static void AddTickInternal(std::vector< FTickEntry > &to, const FTickEntry &newTickEntry)
FGraphEventRef FullFrameTask
FDelegateHandle OnPostTickDelegate
static ATickManager * Instance
FGraphEventRef FullFrameTaskBeforeLateTick
static std::vector< FTickEntry > FullFrameTaskFunctions
static void RemoveTickInternal(std::vector< FTickEntry > &from, FTickEntry tickEntry)
bool operator==(const FTickEntry &Other) const
FTickEntry(UObject *InOwner, std::function< void(float)> InTickFunction, ETickType InType)