新增组件/系统装饰器避免混淆

更改Set兼容web/小游戏
This commit is contained in:
YHH
2025-08-14 18:35:03 +08:00
parent 62f250b43c
commit 0b7e623748
19 changed files with 434 additions and 90 deletions

View File

@@ -1,5 +1,6 @@
import { Component } from '../Component';
import { Bits } from './Bits';
import { getComponentTypeName } from '../Decorators';
/**
* 组件类型管理器
@@ -34,7 +35,7 @@ export class ComponentTypeManager {
if (typeId === undefined) {
typeId = this._nextTypeId++;
this._componentTypes.set(componentType, typeId);
this._typeNames.set(typeId, componentType.name);
this._typeNames.set(typeId, getComponentTypeName(componentType));
}
return typeId;

View File

@@ -1,5 +1,6 @@
import { EntitySystem } from '../Systems/EntitySystem';
import { createLogger } from '../../Utils/Logger';
import { getSystemInstanceTypeName } from '../Decorators';
/**
* 实体处理器列表管理器
@@ -75,7 +76,7 @@ export class EntityProcessorList {
try {
processor.update();
} catch (error) {
EntityProcessorList._logger.error(`Error in processor ${processor.constructor.name}:`, error);
EntityProcessorList._logger.error(`Error in processor ${getSystemInstanceTypeName(processor)}:`, error);
}
}
}

View File

@@ -1,4 +1,5 @@
import { ComponentType } from '../Core/ComponentStorage';
import { getComponentTypeName } from '../Decorators';
/**
* 查询条件类型
@@ -266,15 +267,15 @@ export class Matcher {
const parts: string[] = [];
if (this.condition.all.length > 0) {
parts.push(`all(${this.condition.all.map(t => t.name).join(', ')})`);
parts.push(`all(${this.condition.all.map(t => getComponentTypeName(t)).join(', ')})`);
}
if (this.condition.any.length > 0) {
parts.push(`any(${this.condition.any.map(t => t.name).join(', ')})`);
parts.push(`any(${this.condition.any.map(t => getComponentTypeName(t)).join(', ')})`);
}
if (this.condition.none.length > 0) {
parts.push(`none(${this.condition.none.map(t => t.name).join(', ')})`);
parts.push(`none(${this.condition.none.map(t => getComponentTypeName(t)).join(', ')})`);
}
if (this.condition.tag !== undefined) {
@@ -286,7 +287,7 @@ export class Matcher {
}
if (this.condition.component !== undefined) {
parts.push(`component(${this.condition.component.name})`);
parts.push(`component(${getComponentTypeName(this.condition.component)})`);
}
return `Matcher[${parts.join(' & ')}]`;