Skip to content

ECS Framework API v2.2.13


ECS Framework API / addAndConfigure

Function: addAndConfigure()

addAndConfigure<T>(entity, component, configure): Entity

Defined in: packages/core/src/ECS/TypedEntity.ts:132

添加组件并立即配置

Type Parameters

T

T extends Component

Parameters

entity

Entity

实体实例

component

T

组件实例

configure

(component) => void

配置回调函数

Returns

Entity

实体实例(支持链式调用)

Example

typescript
addAndConfigure(entity, new Health(), health => {
    health.maxValue = 100;
    health.value = 50;
});

Released under the MIT License.