Table of Contents

Class EntityCommands

Namespace
KeenEyes
Assembly
KeenEyes.Abstractions.dll

Fluent builder for configuring a spawned entity in a command buffer.

public sealed class EntityCommands : IEntityBuilder<EntityCommands>, IEntityBuilder
Inheritance
EntityCommands
Implements
Inherited Members

Examples

var buffer = new CommandBuffer();
buffer.Spawn()
    .With(new Position { X = 0, Y = 0 })
    .With(new Velocity { X = 1, Y = 0 })
    .WithTag<ActiveTag>();
buffer.Flush(world);

Remarks

EntityCommands is returned by Spawn() and allows chaining component additions before the entity is actually created.

The entity is not created until Flush(IWorld) is called. This enables safe entity creation during system iteration.

Properties

Name

Gets the optional name for this entity.

public string? Name { get; }

Property Value

string

PlaceholderId

Gets the placeholder ID for this entity. This can be used to reference the entity in subsequent commands before it is created.

public int PlaceholderId { get; }

Property Value

int

Remarks

The placeholder ID is a negative value that will be mapped to the real entity after command buffer flush is called.

Methods

Build()

Not supported on EntityCommands. Use CommandBuffer.Flush() instead.

public Entity Build()

Returns

Entity

Exceptions

NotSupportedException

Always thrown - entities are created during Flush().

WithParent(Entity)

Sets the parent entity for the entity being built.

public EntityCommands WithParent(Entity parent)

Parameters

parent Entity

The parent entity. Must be alive when CommandBuffer.Flush() is called.

Returns

EntityCommands

This builder for chaining.

Remarks

The parent-child relationship will be established when the command buffer is flushed. The parent entity must exist and be alive at that time.

WithTag<T>()

Adds a tag component to the entity being built.

public EntityCommands WithTag<T>() where T : struct, ITagComponent

Returns

EntityCommands

This builder for chaining.

Type Parameters

T

The tag component type.

With<T>(T)

Adds a component to the entity being built.

public EntityCommands With<T>(T component) where T : struct, IComponent

Parameters

component T

The component data.

Returns

EntityCommands

This builder for chaining.

Type Parameters

T

The component type.