feat: 集成Rust WASM渲染引擎与TypeScript ECS框架 (#228)

* feat: 集成Rust WASM渲染引擎与TypeScript ECS框架

* feat: 增强编辑器UI功能与跨平台支持

* fix: 修复CI测试和类型检查问题

* fix: 修复CI问题并提高测试覆盖率

* fix: 修复CI问题并提高测试覆盖率
This commit is contained in:
YHH
2025-11-21 10:03:18 +08:00
committed by GitHub
parent 8b9616837d
commit a768b890fd
107 changed files with 10221 additions and 477 deletions

View File

@@ -0,0 +1,54 @@
import { Entity, Component } from '@esengine/ecs-framework';
import { MessageHub } from '@esengine/editor-core';
import { BaseCommand } from '../BaseCommand';
/**
* 添加组件命令
*/
export class AddComponentCommand extends BaseCommand {
private component: Component | null = null;
constructor(
private messageHub: MessageHub,
private entity: Entity,
private ComponentClass: new () => Component,
private initialData?: Record<string, unknown>
) {
super();
}
execute(): void {
this.component = new this.ComponentClass();
// 应用初始数据
if (this.initialData) {
for (const [key, value] of Object.entries(this.initialData)) {
(this.component as any)[key] = value;
}
}
this.entity.addComponent(this.component);
this.messageHub.publish('component:added', {
entity: this.entity,
component: this.component
});
}
undo(): void {
if (!this.component) return;
this.entity.removeComponent(this.component);
this.messageHub.publish('component:removed', {
entity: this.entity,
componentType: this.ComponentClass.name
});
this.component = null;
}
getDescription(): string {
return `添加组件: ${this.ComponentClass.name}`;
}
}