Class CommandBuffer
Stores a set of structual changes that can be applied to a World.
public class CommandBuffer
- Inheritance
-
CommandBuffer
- Inherited Members
Constructors
CommandBuffer(World)
Creates a command buffer, which stores changes to a world without directly applying them.
public CommandBuffer(World world)
Parameters
worldWorldThe world to apply things to.
Properties
HasBufferItems
Whether or not the buffer currently has items to be played back.
public bool HasBufferItems { get; }
Property Value
Methods
AddComponent(Entity, ComponentID, object)
Adds a component to an entity when Playback() is called.
public void AddComponent(Entity entity, ComponentID componentID, object component)
Parameters
entityEntityThe entity to add to.
componentIDComponentIDThe ID of the component type to add as.
componentobjectThe component to add.
Remarks
component must be assignable to Type.
AddComponent(Entity, object)
Adds a component to an entity when Playback() is called.
public void AddComponent(Entity entity, object component)
Parameters
AddComponent(Entity, Type, object)
Adds a component to an entity when Playback() is called.
public void AddComponent(Entity entity, Type componentType, object component)
Parameters
entityEntityThe entity to add to.
componentTypeTypeThe type to add the component as.
componentobjectThe component to add.
Remarks
component must be assignable to componentType.
AddComponent<T>(Entity, in T)
Adds a component to an entity when Playback() is called.
public void AddComponent<T>(Entity entity, in T component)
Parameters
entityEntityThe entity to add to.
componentTThe component to add.
Type Parameters
TThe component type to add.
Clear()
Removes all commands without playing them back.
public void Clear()
Remarks
This command also removes all empty entities (without events) that have been created by this command buffer.
DeleteEntity(Entity)
Deletes a component from when Playback() is called.
public void DeleteEntity(Entity entity)
Parameters
entityEntityThe entity that will be deleted on playback.
Detach(Entity, TagID)
Detaches a tag from an entity when Playback() is called.
public void Detach(Entity entity, TagID tagID)
Parameters
entityEntityThe entity to detach from.
tagIDTagIDThe ID of the tag type to detach from the entity.
Detach<T>(Entity)
Detaches a tag from an entity when Playback() is called.
public void Detach<T>(Entity entity)
Parameters
entityEntityThe entity to detach from.
Type Parameters
TThe type of tag to detach.
End()
Finishes recording entity creation and returns an entity with zero components. Recorded components will be added on playback.
public Entity End()
Returns
- Entity
The created entity ID
Entity()
Begins to create an entity, which will be resolved when Playback() is called.
public CommandBuffer Entity()
Returns
- CommandBuffer
this instance, for method chaining.
Exceptions
- InvalidOperationException
An entity is already being created.
Playback()
Plays all the queued commands, applying them to a world.
public bool Playback()
Returns
- bool
true when at least one change was made; false when this command buffer is empty and not active.
RemoveComponent(Entity, ComponentID)
Removes a component from when Playback() is called.
public void RemoveComponent(Entity entity, ComponentID component)
Parameters
entityEntityThe entity to remove a component from.
componentComponentIDThe component to remove.
RemoveComponent(Entity, Type)
Removes a component from when Playback() is called.
public void RemoveComponent(Entity entity, Type type)
Parameters
RemoveComponent<T>(Entity)
Removes a component from when Playback() is called.
public void RemoveComponent<T>(Entity entity)
Parameters
entityEntityThe entity to remove a component from.
Type Parameters
TThe component type to remove.
Tag(Entity, TagID)
Tags an entity with a tag when Playback() is called.
public void Tag(Entity entity, TagID tagID)
Parameters
Tag<T>(Entity)
Tags an entity with a tag when Playback() is called.
public void Tag<T>(Entity entity)
Parameters
entityEntityThe entity to tag.
Type Parameters
TThe type to tag the entity with.
WithBoxed(ComponentID, object)
Records component to be part of the entity created when resolved as a component type represented by componentID.
public CommandBuffer WithBoxed(ComponentID componentID, object component)
Parameters
componentIDComponentIDcomponentobject
Returns
- CommandBuffer
this instance, for method chaining.
Exceptions
- InvalidOperationException
Entity() has not been called."/>
WithBoxed(object)
Records component to be part of the entity created when resolved.
public CommandBuffer WithBoxed(object component)
Parameters
componentobject
Returns
- CommandBuffer
this instance, for method chaining.
Exceptions
- InvalidOperationException
Entity() has not been called."/>
WithBoxed(Type, object)
Records component to be part of the entity created when resolved as a component type of type.
public CommandBuffer WithBoxed(Type type, object component)
Parameters
Returns
- CommandBuffer
this instance, for method chaining.
Exceptions
- InvalidOperationException
Entity() has not been called."/>
With<T>(T)
Records component to be part of the entity created when resolved.
public CommandBuffer With<T>(T component)
Parameters
componentT
Returns
- CommandBuffer
this instance, for method chaining.
Type Parameters
T
Exceptions
- InvalidOperationException
Entity() has not been called."/>