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 LateTickParallel
UMETA(DisplayName =
"LateTickParallel"),
51 std::function<
void(
float)> Tick;
58 : Owner(InOwner), Tick(InTickFunction), TickType(InType) {}
102 static FTickEntry AddTick(UObject* Object, std::function<
void(
float)> Function,
ETickType Type);
117 virtual void BeginPlay()
override;
118 virtual void EndPlay(
const EEndPlayReason::Type EndPlayReason)
override;
121 void PreTick(UWorld* World, ELevelTick TickType,
float DeltaSeconds);
124 void PostTick(UWorld* World, ELevelTick TickType,
float DeltaSeconds);
128 inline void TickFunctionsParallel(std::vector<FTickEntry>& functions,
const float DeltaTime);
139 bool found = std::find_if(to.begin(), to.end(), [&](
const FTickEntry& entry) {
140 return (entry.Owner == newTickEntry.Owner && entry.TickType == newTickEntry.TickType);
145 to.emplace_back(newTickEntry);
150 UE_LOG(LogTemp, Warning, TEXT(
"TickManager.h: This entry already exists. Returning."));
157 from.erase(std::remove(from.begin(), from.end(), tickEntry), from.end());
161template <
typename ObjectType,
typename FunctionType>
162static auto BindTick(ObjectType* Object, FunctionType Function)
164 return [Object, Function](
float DeltaTime)
166 (Object->*Function)(DeltaTime);
static auto BindTick(ObjectType *Object, FunctionType Function)
FDelegateHandle OnPreTickDelegate
static std::vector< FTickEntry > LateTickFunctions
static std::vector< FTickEntry > TicksToRemove
static void AddTickInternal(std::vector< FTickEntry > &to, const FTickEntry &newTickEntry)
FGraphEventRef FullFrameTask
FDelegateHandle OnPostTickDelegate
static ATickManager * Instance
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)