refactor: reorganize package structure and decouple framework packages (#338)
* refactor: reorganize package structure and decouple framework packages ## Package Structure Reorganization - Reorganized 55 packages into categorized subdirectories: - packages/framework/ - Generic framework (Laya/Cocos compatible) - packages/engine/ - ESEngine core modules - packages/rendering/ - Rendering modules (WASM dependent) - packages/physics/ - Physics modules - packages/streaming/ - World streaming - packages/network-ext/ - Network extensions - packages/editor/ - Editor framework and plugins - packages/rust/ - Rust WASM engine - packages/tools/ - Build tools and SDK ## Framework Package Decoupling - Decoupled behavior-tree and blueprint packages from ESEngine dependencies - Created abstracted interfaces (IBTAssetManager, IBehaviorTreeAssetContent) - ESEngine-specific code moved to esengine/ subpath exports - Framework packages now usable with Cocos/Laya without ESEngine ## CI Configuration - Updated CI to only type-check and lint framework packages - Added type-check:framework and lint:framework scripts ## Breaking Changes - Package import paths changed due to directory reorganization - ESEngine integrations now use subpath imports (e.g., '@esengine/behavior-tree/esengine') * fix: update es-engine file path after directory reorganization * docs: update README to focus on framework over engine * ci: only build framework packages, remove Rust/WASM dependencies * fix: remove esengine subpath from behavior-tree and blueprint builds ESEngine integration code will only be available in full engine builds. Framework packages are now purely engine-agnostic. * fix: move network-protocols to framework, build both in CI * fix: update workflow paths from packages/core to packages/framework/core * fix: exclude esengine folder from type-check in behavior-tree and blueprint * fix: update network tsconfig references to new paths * fix: add test:ci:framework to only test framework packages in CI * fix: only build core and math npm packages in CI * fix: exclude test files from CodeQL and fix string escaping security issue
This commit is contained in:
89
packages/framework/core/tests/reactive-query-timing.test.ts
Normal file
89
packages/framework/core/tests/reactive-query-timing.test.ts
Normal file
@@ -0,0 +1,89 @@
|
||||
import { describe, it, expect } from '@jest/globals';
|
||||
import { Scene, Entity, Component, EntitySystem, Matcher, ECSComponent } from '../src';
|
||||
|
||||
@ECSComponent('TestTransform')
|
||||
class TestTransform extends Component {
|
||||
constructor(public x: number = 0, public y: number = 0) {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
@ECSComponent('TestRenderable')
|
||||
class TestRenderable extends Component {
|
||||
constructor(public sprite: string = 'default') {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
class TestRenderSystem extends EntitySystem {
|
||||
public entitiesFound: Entity[] = [];
|
||||
|
||||
constructor() {
|
||||
super(Matcher.all(TestTransform, TestRenderable));
|
||||
}
|
||||
|
||||
protected override process(entities: readonly Entity[]): void {
|
||||
this.entitiesFound = Array.from(entities);
|
||||
console.log(`TestRenderSystem.process: 找到 ${entities.length} 个实体`);
|
||||
}
|
||||
|
||||
protected override onAdded(entity: Entity): void {
|
||||
console.log(`TestRenderSystem.onAdded: 实体 ${entity.name}(${entity.id}) 被添加`);
|
||||
}
|
||||
}
|
||||
|
||||
class TestGameScene extends Scene {
|
||||
private renderSystem: TestRenderSystem | null = null;
|
||||
|
||||
public override initialize(): void {
|
||||
super.initialize();
|
||||
|
||||
console.log('\n=== Scene.initialize() 开始 ===');
|
||||
|
||||
// 1. 先添加System(这是GameScene的做法)
|
||||
console.log('步骤1: 添加RenderSystem');
|
||||
this.renderSystem = new TestRenderSystem();
|
||||
this.addEntityProcessor(this.renderSystem);
|
||||
|
||||
// 2. 然后创建实体(这是GameScene的做法)
|
||||
console.log('\n步骤2: 创建实体');
|
||||
const entity = this.createEntity('Player');
|
||||
console.log(`实体已创建: ${entity.name}(${entity.id})`);
|
||||
|
||||
console.log('\n步骤3: 添加组件');
|
||||
entity.addComponent(new TestTransform(100, 200));
|
||||
entity.addComponent(new TestRenderable('player-sprite'));
|
||||
console.log(`实体组件数量: ${entity.components.length}`);
|
||||
|
||||
console.log('=== Scene.initialize() 结束 ===\n');
|
||||
}
|
||||
|
||||
public getRenderSystem(): TestRenderSystem | null {
|
||||
return this.renderSystem;
|
||||
}
|
||||
}
|
||||
|
||||
describe('响应式查询时序测试(模拟GameScene)', () => {
|
||||
it('应该在Scene.initialize()中先添加System再创建实体时正常工作', () => {
|
||||
console.log('\n\n========== 测试开始 ==========');
|
||||
|
||||
const scene = new TestGameScene();
|
||||
|
||||
console.log('\n调用scene.initialize()');
|
||||
scene.initialize();
|
||||
|
||||
console.log('\n调用Scene.begin()');
|
||||
scene.begin();
|
||||
|
||||
console.log('\n第一次Scene.update()');
|
||||
scene.update();
|
||||
|
||||
const renderSystem = scene.getRenderSystem();
|
||||
expect(renderSystem).not.toBeNull();
|
||||
|
||||
console.log(`\nRenderSystem找到的实体数量: ${renderSystem!.entitiesFound.length}`);
|
||||
expect(renderSystem!.entitiesFound.length).toBe(1);
|
||||
|
||||
console.log('========== 测试结束 ==========\n\n');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user