支持可以任意参数

This commit is contained in:
YHH
2025-08-12 11:47:18 +08:00
parent 56dd18b983
commit baeb047e27
5 changed files with 8 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@esengine/ecs-framework",
"version": "2.1.34",
"version": "2.1.35",
"description": "用于Laya、Cocos Creator等JavaScript游戏引擎的高性能ECS框架",
"type": "module",
"main": "bin/index.js",

View File

@@ -8,8 +8,9 @@ export { EnableSoA, HighPrecision, Float64, Int32, SerializeMap, SerializeSet, S
/**
* 组件类型定义
* 支持任意构造函数签名,提供更好的类型安全性
*/
export type ComponentType<T extends Component = Component> = new (...args: unknown[]) => T;
export type ComponentType<T extends Component = Component> = new (...args: any[]) => T;
/**
* 组件注册表

View File

@@ -335,7 +335,7 @@ export class Entity {
*/
public createComponent<T extends Component>(
componentType: ComponentType<T>,
...args: unknown[]
...args: any[]
): T {
const component = new componentType(...args);
return this.addComponent(component);
@@ -508,7 +508,7 @@ export class Entity {
*/
public getOrCreateComponent<T extends Component>(
type: ComponentType<T>,
...args: unknown[]
...args: any[]
): T {
let component = this.getComponent(type);
if (!component) {

View File

@@ -54,8 +54,9 @@ export interface ISystemBase {
* 组件类型定义
*
* 用于类型安全的组件操作
* 支持任意构造函数签名,提供更好的类型安全性
*/
export type ComponentType<T extends IComponent = IComponent> = new (...args: unknown[]) => T;
export type ComponentType<T extends IComponent = IComponent> = new (...args: any[]) => T;
/**
* 事件总线接口