Skip to content

ECS Framework API v2.1.50


ECS Framework API / Matcher

Class: Matcher

Defined in: ECS/Utils/Matcher.ts:31

实体匹配条件描述符

用于描述实体查询条件,不执行实际查询

Example

typescript
const matcher = Matcher.all(Position, Velocity)
  .any(Health, Shield)
  .none(Dead);

// 获取查询条件
const condition = matcher.getCondition();

Methods

all()

static all(...types): Matcher

Defined in: ECS/Utils/Matcher.ts:46

创建匹配器,要求所有指定的组件

Parameters

types

...ComponentType[]

组件类型

Returns

Matcher


any()

static any(...types): Matcher

Defined in: ECS/Utils/Matcher.ts:55

创建匹配器,要求至少一个指定的组件

Parameters

types

...ComponentType[]

组件类型

Returns

Matcher


none()

static none(...types): Matcher

Defined in: ECS/Utils/Matcher.ts:64

创建匹配器,排除指定的组件

Parameters

types

...ComponentType[]

组件类型

Returns

Matcher


byTag()

static byTag(tag): Matcher

Defined in: ECS/Utils/Matcher.ts:73

创建按标签查询的匙配器

Parameters

tag

number

标签值

Returns

Matcher


byName()

static byName(name): Matcher

Defined in: ECS/Utils/Matcher.ts:82

创建按名称查询的匙配器

Parameters

name

string

实体名称

Returns

Matcher


byComponent()

static byComponent(componentType): Matcher

Defined in: ECS/Utils/Matcher.ts:91

创建单组件查询的匙配器

Parameters

componentType

ComponentType

组件类型

Returns

Matcher


complex()

static complex(): Matcher

Defined in: ECS/Utils/Matcher.ts:99

创建复杂查询构建器

Returns

Matcher


empty()

static empty(): Matcher

Defined in: ECS/Utils/Matcher.ts:106

创建空匙配器

Returns

Matcher


all()

all(...types): Matcher

Defined in: ECS/Utils/Matcher.ts:114

必须包含所有指定组件

Parameters

types

...ComponentType[]

组件类型

Returns

Matcher


any()

any(...types): Matcher

Defined in: ECS/Utils/Matcher.ts:123

必须包含至少一个指定组件

Parameters

types

...ComponentType[]

组件类型

Returns

Matcher


none()

none(...types): Matcher

Defined in: ECS/Utils/Matcher.ts:132

不能包含任何指定组件

Parameters

types

...ComponentType[]

组件类型

Returns

Matcher


exclude()

exclude(...types): Matcher

Defined in: ECS/Utils/Matcher.ts:141

排除指定组件(别名方法)

Parameters

types

...ComponentType[]

组件类型

Returns

Matcher


one()

one(...types): Matcher

Defined in: ECS/Utils/Matcher.ts:149

至少包含其中之一(别名方法)

Parameters

types

...ComponentType[]

组件类型

Returns

Matcher


withTag()

withTag(tag): Matcher

Defined in: ECS/Utils/Matcher.ts:157

按标签查询

Parameters

tag

number

标签值

Returns

Matcher


withName()

withName(name): Matcher

Defined in: ECS/Utils/Matcher.ts:166

按名称查询

Parameters

name

string

实体名称

Returns

Matcher


withComponent()

withComponent(componentType): Matcher

Defined in: ECS/Utils/Matcher.ts:175

单组件查询

Parameters

componentType

ComponentType

组件类型

Returns

Matcher


withoutTag()

withoutTag(): Matcher

Defined in: ECS/Utils/Matcher.ts:183

移除标签条件

Returns

Matcher


withoutName()

withoutName(): Matcher

Defined in: ECS/Utils/Matcher.ts:191

移除名称条件

Returns

Matcher


withoutComponent()

withoutComponent(): Matcher

Defined in: ECS/Utils/Matcher.ts:199

移除单组件条件

Returns

Matcher


getCondition()

getCondition(): Readonly<QueryCondition>

Defined in: ECS/Utils/Matcher.ts:207

获取查询条件(只读)

Returns

Readonly<QueryCondition>


isEmpty()

isEmpty(): boolean

Defined in: ECS/Utils/Matcher.ts:221

检查是否为空条件

Returns

boolean


reset()

reset(): Matcher

Defined in: ECS/Utils/Matcher.ts:233

重置所有条件

Returns

Matcher


clone()

clone(): Matcher

Defined in: ECS/Utils/Matcher.ts:246

克隆匹配器

Returns

Matcher


toString()

toString(): string

Defined in: ECS/Utils/Matcher.ts:266

字符串表示

Returns

string

Released under the MIT License.