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
world
WorldThe 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
entity
EntityThe entity to add to.
componentID
ComponentIDThe ID of the component type to add as.
component
objectThe 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
entity
EntityThe entity to add to.
componentType
TypeThe type to add the component as.
component
objectThe 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
entity
EntityThe entity to add to.
component
TThe component to add.
Type Parameters
T
The 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
entity
EntityThe 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
entity
EntityThe entity to detach from.
tagID
TagIDThe 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
entity
EntityThe entity to detach from.
Type Parameters
T
The 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
entity
EntityThe entity to remove a component from.
component
ComponentIDThe 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
entity
EntityThe entity to remove a component from.
Type Parameters
T
The 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
entity
EntityThe entity to tag.
Type Parameters
T
The 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
componentID
ComponentIDcomponent
object
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
component
object
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
component
T
Returns
- CommandBuffer
this instance, for method chaining.
Type Parameters
T
Exceptions
- InvalidOperationException
Entity() has not been called."/>