7#include "Engine/GameInstance.h"
8#include "Engine/World.h"
9#include "Subsystems/GameInstanceSubsystem.h"
10#include "Templates/UnrealTypeTraits.h"
11#include "SnapshotSubsystem.generated.h"
22 virtual void Deinitialize()
override;
27 void MarkRollbackPoint(FName RollbackPointID);
28 bool RollbackTo(FName RollbackPointID);
32 void PrintCommandStack();
36 template <
typename TCommandType,
typename TInitializeCommand>
37 TCommandType* ProcessNewCommand(TInitializeCommand InitializeCommand);
39 template <
typename TCommandType,
typename TInitializeCommand>
40 static TCommandType* ProcessNewCommand(UObject* WorldContextObject, TInitializeCommand InitializeCommand);
45 return RollbackDepth > 0;
53 TMap<FName, int32> RollbackPointByID;
54 int32 RollbackDepth = 0;
58template <typename TCommandType, typename TInitializeCommand>
61 static_assert(TIsDerivedFrom<TCommandType, UCommandBase>::Value,
"TCommandType must derive from UCommandBase.");
68 TCommandType* Command = NewObject<TCommandType>(
this);
70 if (Command ==
nullptr)
75 InitializeCommand(Command);
77 if (ProcessCommand(Command) ==
false)
88template <
typename TCommandType,
typename TInitializeCommand>
91 static_assert(TIsDerivedFrom<TCommandType, UCommandBase>::Value,
"TCommandType must derive from UCommandBase.");
93 if (WorldContextObject ==
nullptr)
98 UGameInstance* GameInstance = Cast<UGameInstance>(WorldContextObject);
100 if (GameInstance ==
nullptr)
102 UWorld* World = WorldContextObject->GetWorld();
103 GameInstance = World ? World->GetGameInstance() :
nullptr;
109 if (SnapshotSubsystem ==
nullptr)
#define LOG_ERROR(Category, Format,...)
Definition CK_UE.h:40
#define NAMEOF(Type)
Definition CK_UE.h:30
Definition CommandBase.h:11
Definition SnapshotSubsystem.h:16
TCommandType * ProcessNewCommand(TInitializeCommand InitializeCommand)
Definition SnapshotSubsystem.h:59
FORCEINLINE bool IsRollingBack() const
Definition SnapshotSubsystem.h:43