Skip to content

GenericEntityBuilder

Defined in: src/test-utils.ts:40

Fluent builder for assembling entities in tests against an arbitrary EcsWorld. Domain-neutral — callers pass the ComponentDef / TagDef they’ve registered. Mirrors game-specific builders (e.g. Roguelike’s EntityBuilder) but without baking in any components or tags.

const world = createTestWorld();
const Pos = world.registerComponent(PositionDef);
const Blocker = world.registerTag({ name: 'blocker' });
const id = new GenericEntityBuilder(world)
.with(PositionDef, { x: 3, y: 4 })
.tag({ name: 'blocker' })
.build();

W extends EcsWorld = EcsWorld

new GenericEntityBuilder<W>(world, id?): GenericEntityBuilder<W>

Defined in: src/test-utils.ts:44

W

EntityId

GenericEntityBuilder<W>

readonly id: EntityId

Defined in: src/test-utils.ts:41

build(): EntityId

Defined in: src/test-utils.ts:50

Finalise and return the entity id.

EntityId


tag(def): this

Defined in: src/test-utils.ts:55

Add a tag to this entity. Returns this for chaining.

TagDef

this


with<T>(def, value): this

Defined in: src/test-utils.ts:61

Set a component on this entity. Returns this for chaining.

T

ComponentDef<T>

T

this