update 2.1.30

This commit is contained in:
YHH
2025-08-11 09:31:44 +08:00
parent edc60fc3d8
commit 5bce08683a
14 changed files with 111 additions and 99 deletions

View File

@@ -526,12 +526,12 @@ class InefficientSystem extends EntitySystem {
#### 选择合适的创建方式
```typescript
// 推荐:单一条件使用静态方法
// 推荐:单一条件使用静态方法
const movingEntities = Matcher.all(PositionComponent, VelocityComponent);
const playerEntities = Matcher.byTag(PLAYER_TAG);
const specificEntity = Matcher.byName("Boss");
// 推荐:复杂条件使用链式调用
// 推荐:复杂条件使用链式调用
const complexMatcher = Matcher.empty()
.all(PositionComponent, HealthComponent)
.any(WeaponComponent, MagicComponent)
@@ -554,12 +554,12 @@ const combatUnits = Matcher.all(PositionComponent, HealthComponent)
#### 合理的克隆和重用
```typescript
// 推荐:基础匹配器重用
// 推荐:基础匹配器重用
const livingEntityMatcher = Matcher.all(HealthComponent).none(DeadComponent);
const livingPlayerMatcher = livingEntityMatcher.clone().all(PlayerComponent);
const livingEnemyMatcher = livingEntityMatcher.clone().all(EnemyComponent);
// 推荐:重置匹配器重用
// 推荐:重置匹配器重用
const reusableMatcher = Matcher.empty();
// 用于玩家系统