class

FEntityCommandBuffer

Structural changes recorded now and applied later, on the main thread, in one go — the Mass command buffer. A worker or a ForEach that needs to add, remove or destroy records here instead of submitting one std::function per change (a heap allocation and an indirect call each): consecutive records of the same kind and component type share one typed batch.

Module
ECS
Header
#include "ECS/EntityCommandBuffer.h"
Namespace
Mowo

Playback runs the batches in recording order, with World::AddComponent / RemoveComponent semantics per record — adding a component the entity already carries leaves the existing value alone. A run of destroys goes through World::DestroyEntities, which takes the lock once and orders the run with SortForStructuralBatch, so the surviving layout depends on which entities died, not on the order a worker happened to record them in.

A buffer is not thread-safe: one per recording thread.

Constructors

SignatureNameDescription
FEntityCommandBuffer() = defaultFEntityCommandBuffer
FEntityCommandBuffer(FEntityCommandBuffer&&) = defaultFEntityCommandBuffer
FEntityCommandBuffer(const FEntityCommandBuffer&) = deleteFEntityCommandBuffer

Public functions

ReturnsNameDescription
FEntityCommandBuffer&operator=
FEntityCommandBuffer&operator=
voidAddComponent
voidRemoveComponent
voidDestroyEntity
size_tNum
boolIsEmpty
size_tNumBatchesNumber of typed batches the records collapsed into.
voidPlaybackMain thread, outside any ForEach — the same rule as the World calls it makes.
voidSubmitToQueues the whole buffer on the World's deferred queue, which plays it back at the end of World::Update.

Function details

FEntityCommandBuffer

C++
FEntityCommandBuffer() = default

FEntityCommandBuffer

C++
FEntityCommandBuffer(FEntityCommandBuffer&&) = default

FEntityCommandBuffer

C++
FEntityCommandBuffer(const FEntityCommandBuffer&) = delete

operator=

C++
FEntityCommandBuffer& operator=(FEntityCommandBuffer&&) = default

operator=

C++
FEntityCommandBuffer& operator=(const FEntityCommandBuffer&) = delete

AddComponent

C++
template<typename T> void AddComponent(EntityID entity, T value = T())

RemoveComponent

C++
template<typename T> void RemoveComponent(EntityID entity)

DestroyEntity

C++
void DestroyEntity(EntityID entity)

Num

C++
size_t Num() const

IsEmpty

C++
bool IsEmpty() const

NumBatches

C++
size_t NumBatches() const

Number of typed batches the records collapsed into.

Playback

C++
void Playback(World& world)

Main thread, outside any ForEach — the same rule as the World calls it makes. The buffer is empty afterwards and can be recorded into again.

SubmitTo

C++
void SubmitTo(World& world)

Queues the whole buffer on the World's deferred queue, which plays it back at the end of World::Update. Safe from any thread, like World::SubmitDeferred; this buffer is left empty.

Generated from ECS/EntityCommandBuffer.h via ecs.json · Nov 4, 2026Version 1.0.0