UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
MassProcessingContext.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
6#include "MassCommandBuffer.h"
7#include "MassEntityManager.h"
9
10
11namespace UE::Mass
12{
14 {
15 UE_DEPRECATED_FORGAME(5.6, "This constructor is deprecated. Use one of the other ones.")
16 FProcessingContext() = default;
17 UE_DEPRECATED_FORGAME(5.6, "This constructor is deprecated. Use one of the other ones.")
19
21
27
30 bool GetWillFlushCommands() const;
31 float GetDeltaSeconds() const;
32
35
37
40
41 UE_DEPRECATED_FORGAME(5.6, "Direct access to FProcessingContex.DeltaSeconds has been deprecated. Set it via the constructor instead, read via the getter.")
42 float DeltaSeconds = 0.f;
43
45
52
55
59 };
60
61 //----------------------------------------------------------------------//
62 // INLINES
63 //----------------------------------------------------------------------//
64 // @todo remove the depracation disabling once CommandBuffer and EntityManager are moved to `protected` and un-deprecated (around UE5.8)
71
79
81 : EntityManager(MoveTemp(InEntityManager))
82 , DeltaSeconds(InDeltaSeconds)
83 , bFlushCommandBuffer(bInFlushCommandBuffer)
84 {
85
86 }
87
93
95 {
96 if (ExecutionContextPtr == nullptr)
97 {
98 ExecutionContextPtr = new(&ExecutionContextBuffer) FMassExecutionContext(*EntityManager, DeltaSeconds);
99
100 if (CommandBuffer.IsValid() == false)
101 {
102 CommandBuffer = MakeShareable(new FMassCommandBuffer());
103 }
104
105 ExecutionContextPtr->SetDeferredCommandBuffer(CommandBuffer);
106
107 ExecutionContextPtr->SetFlushDeferredCommands(false);
108 ExecutionContextPtr->SetAuxData(AuxData);
109 ExecutionContextPtr->SetExecutionType(EMassExecutionContextType::Processor);
110 }
111 return *ExecutionContextPtr;
112 }
113
115 {
116 // Note: it's fine to store a reference to created execution context
117 // while nulling-out the pointer, since the FMassExecutionContext data
118 // lives in the ExecutionContextBuffer buffer. Nulling out ExecutionContextPtr
119 // only signals that the execution context has been moved out.
120
121 FMassExecutionContext& LocalExecutionContext = GetExecutionContext();
122 ExecutionContextPtr = nullptr;
123 CommandBuffer.Reset();
124
126 }
127
129 {
130 checkf(ExecutionContextPtr == nullptr, TEXT("Setting command buffer after ExecutionContext creation is not supported"));
131 if (ExecutionContextPtr == nullptr)
132 {
134 }
135 }
136
138 {
139 checkf(ExecutionContextPtr == nullptr, TEXT("Setting command buffer after ExecutionContext creation is not supported"));
140 if (ExecutionContextPtr == nullptr)
141 {
143 }
144 }
145
150
152 {
153 return bFlushCommandBuffer;
154 }
155
157 {
158 return DeltaSeconds;
159 }
160
162} // namespace UE::Mass
#define checkf(expr, format,...)
Definition AssertionMacros.h:315
#define UE_DEPRECATED_FORGAME
Definition CoreMiscDefines.h:377
#define TEXT(x)
Definition Platform.h:1272
SharedPointerInternals::TRawPtrProxy< ObjectType > MakeShareable(ObjectType *InObject)
Definition SharedPointer.h:1947
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
return true
Definition ExternalRpcRegistry.cpp:601
#define PRAGMA_ENABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:12
#define PRAGMA_DISABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:8
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
uint8_t uint8
Definition binka_ue_file_header.h:8
Definition UnrealType.h:3087
Definition SharedPointer.h:692
Definition SharedPointer.h:153
Definition MassArchetypeData.h:21
Definition InstancedStruct.h:32
Definition MassCommandBuffer.h:99
Definition MassEntityManager.h:96
Definition MassExecutionContext.h:29
Definition MassProcessingContext.h:14
const TSharedRef< FMassEntityManager > & GetEntityManager() const
Definition MassProcessingContext.h:146
FMassExecutionContext * ExecutionContextPtr
Definition MassProcessingContext.h:58
float DeltaSeconds
Definition MassProcessingContext.h:42
float GetDeltaSeconds() const
Definition MassProcessingContext.h:156
bool GetWillFlushCommands() const
Definition MassProcessingContext.h:151
uint8 ExecutionContextBuffer[sizeof(FMassExecutionContext)]
Definition MassProcessingContext.h:57
bool bFlushCommandBuffer
Definition MassProcessingContext.h:51
FInstancedStruct AuxData
Definition MassProcessingContext.h:44
TSharedRef< FMassEntityManager > EntityManager
Definition MassProcessingContext.h:39
TSharedPtr< FMassCommandBuffer > CommandBuffer
Definition MassProcessingContext.h:54
void SetCommandBuffer(TSharedPtr< FMassCommandBuffer > &&InCommandBuffer)
Definition MassProcessingContext.h:128
FMassExecutionContext & GetExecutionContext() &
Definition MassProcessingContext.h:94