ECS Framework API / TypedEntityBuilder
Class: TypedEntityBuilder
Defined in: packages/core/src/ECS/TypedEntity.ts:209
类型安全的实体构建器
Example
const player = buildEntity(scene.createEntity("Player"))
.with(new Position(100, 100))
.with(new Velocity(0, 0))
.withTag(1)
.build();Constructors
Constructor
new TypedEntityBuilder(
entity):TypedEntityBuilder
Defined in: packages/core/src/ECS/TypedEntity.ts:212
Parameters
entity
Returns
TypedEntityBuilder
Accessors
entity
Get Signature
get entity():
Entity
Defined in: packages/core/src/ECS/TypedEntity.ts:294
获取正在构建的实体
Returns
Methods
with()
with<
T>(component):this
Defined in: packages/core/src/ECS/TypedEntity.ts:219
添加组件
Type Parameters
T
T extends Component
Parameters
component
T
Returns
this
withConfigured()
withConfigured<
T>(component,configure):this
Defined in: packages/core/src/ECS/TypedEntity.ts:227
添加并配置组件
Type Parameters
T
T extends Component
Parameters
component
T
configure
(component) => void
Returns
this
withTag()
withTag(
tag):this
Defined in: packages/core/src/ECS/TypedEntity.ts:239
设置标签
Parameters
tag
number
Returns
this
withName()
withName(
name):this
Defined in: packages/core/src/ECS/TypedEntity.ts:247
设置名称
Parameters
name
string
Returns
this
withActive()
withActive(
active):this
Defined in: packages/core/src/ECS/TypedEntity.ts:255
设置激活状态
Parameters
active
boolean
Returns
this
withEnabled()
withEnabled(
enabled):this
Defined in: packages/core/src/ECS/TypedEntity.ts:263
设置启用状态
Parameters
enabled
boolean
Returns
this
withUpdateOrder()
withUpdateOrder(
order):this
Defined in: packages/core/src/ECS/TypedEntity.ts:271
设置更新顺序
Parameters
order
number
Returns
this
withChild()
withChild(
child):this
Defined in: packages/core/src/ECS/TypedEntity.ts:279
添加子实体
Parameters
child
Returns
this
build()
build():
Entity
Defined in: packages/core/src/ECS/TypedEntity.ts:287
完成构建