Skip to content

Home > @esengine/ecs-framework-monorepo > Matcher

Matcher class

实体匹配条件描述符

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

Signature:

typescript
export declare class Matcher

Example

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

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

Methods

Method

Modifiers

Description

all(types)

必须包含所有指定组件

all(types)

static

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

any(types)

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

any(types)

static

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

byComponent(componentType)

static

创建单组件查询的匙配器

byName(name)

static

创建按名称查询的匙配器

byTag(tag)

static

创建按标签查询的匙配器

clone()

克隆匹配器

complex()

static

创建复杂查询构建器

empty()

static

创建空匙配器(向后兼容)

exclude(types)

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

getCondition()

获取查询条件(只读)

isEmpty()

检查是否为空条件

none(types)

不能包含任何指定组件

none(types)

static

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

one(types)

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

reset()

重置所有条件

toString()

字符串表示

withComponent(componentType)

单组件查询

withName(name)

按名称查询

withoutComponent()

移除单组件条件

withoutName()

移除名称条件

withoutTag()

移除标签条件

withTag(tag)

按标签查询

基于 MIT 许可证发布