public sealed class CommandBufferStructural changes recorded during iteration and applied at a sync point.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Adding or removing a component moves an entity's row between chunks, which invalidates the very span the loop that asked for it is walking. The engine's answer is not to detect that — it is to make the mutation happen somewhere it cannot: recorded here, played back when nothing is iterating. Jobs may only mutate through one of these.
The buffer is lenient where World is strict. Add``1 overwrites rather than refusing, Remove``1 and Destroy do nothing if there is nothing to do, and a command naming an entity that an earlier command in the same playback destroyed is skipped. That is not laxity for its own sake: a recorder runs during iteration and cannot look at the world to find out whether its change is redundant, and two systems both deciding to remove the same tag or destroy the same entity is ordinary rather than exceptional. A caller that can look uses World and gets told when it is wrong.
Fields and properties (2)
public World WorldThe world the commands will be played back into.
public int CountHow many commands are recorded, across every channel.
Methods (11)
public CommandBuffer(World world)Creates a buffer for a world.
public Entity Create()Records the creation of an entity.
public void Destroy(Entity entity)Records the destruction of an entity.
public void Add<T>(Entity entity, in T value)Records adding a component, overwriting it if the entity already has one.
public void Add<T>(Entity entity)Records adding a component with its default value — the usual way to add a tag.
public void Set<T>(Entity entity, in T value)Records overwriting a component the entity has.
public void Remove<T>(Entity entity)Records removing a component, if the entity has one.
public CommandBuffer.ParallelWriter AsParallelWriter()A view that jobs record through, one channel per thread.
public void Playback()Applies every recorded command in sort-key order and empties the buffer.
public void Clear()Throws away everything recorded without applying it.
public Entity Resolve(Entity placeholder)What a placeholder from Create became.
Used by (10)
- CommandBufferTestsVixen.Ecs.Tests
- DeterminismTestsVixen.Ecs.Tests
- HierarchyVixen.Engine
- HierarchyTestsVixen.Engine.Tests
- ParallelWriterVixen.Ecs
- PossessionSystemVixen.Engine
- SpawnSystemVixen.Ecs.Tests
- SystemContextVixen.Ecs
- SystemRunnerVixen.Ecs
- VirtualCameraSystemVixen.Engine