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:
YHH
2025-12-26 14:50:35 +08:00
committed by GitHub
parent a84ff902e4
commit 155411e743
1936 changed files with 4147 additions and 11578 deletions

View File

@@ -0,0 +1,130 @@
/**
* Fill Tool - Flood fill tiles on the tilemap
*/
import type { ITilemapTool, ToolContext } from './ITilemapTool';
export class FillTool implements ITilemapTool {
readonly id = 'fill';
readonly name = 'Fill';
readonly icon = 'PaintBucket';
readonly cursor = 'crosshair';
onMouseDown(tileX: number, tileY: number, ctx: ToolContext): void {
if (ctx.layerLocked && !ctx.editingCollision) return;
this.floodFill(tileX, tileY, ctx);
}
onMouseMove(_tileX: number, _tileY: number, _ctx: ToolContext): void {
// No action on move
}
onMouseUp(_tileX: number, _tileY: number, _ctx: ToolContext): void {
// No action on up
}
getPreviewTiles(tileX: number, tileY: number, ctx: ToolContext): { x: number; y: number }[] {
const { tilemap, editingCollision, currentLayer } = ctx;
if (tileX < 0 || tileX >= tilemap.width || tileY < 0 || tileY >= tilemap.height) {
return [];
}
const tiles: { x: number; y: number }[] = [];
const maxPreviewTiles = 500;
if (editingCollision) {
const targetCollision = tilemap.hasCollision(tileX, tileY);
const stack: [number, number][] = [[tileX, tileY]];
const visited = new Set<string>();
while (stack.length > 0 && tiles.length < maxPreviewTiles) {
const [x, y] = stack.pop()!;
const key = `${x},${y}`;
if (visited.has(key)) continue;
if (x < 0 || x >= tilemap.width || y < 0 || y >= tilemap.height) continue;
if (tilemap.hasCollision(x, y) !== targetCollision) continue;
visited.add(key);
tiles.push({ x, y });
stack.push([x + 1, y], [x - 1, y], [x, y + 1], [x, y - 1]);
}
} else {
const targetTile = tilemap.getTile(currentLayer, tileX, tileY);
const stack: [number, number][] = [[tileX, tileY]];
const visited = new Set<string>();
while (stack.length > 0 && tiles.length < maxPreviewTiles) {
const [x, y] = stack.pop()!;
const key = `${x},${y}`;
if (visited.has(key)) continue;
if (x < 0 || x >= tilemap.width || y < 0 || y >= tilemap.height) continue;
if (tilemap.getTile(currentLayer, x, y) !== targetTile) continue;
visited.add(key);
tiles.push({ x, y });
stack.push([x + 1, y], [x - 1, y], [x, y + 1], [x, y - 1]);
}
}
return tiles;
}
private floodFill(startX: number, startY: number, ctx: ToolContext): void {
const { tilemap, selectedTiles, editingCollision, currentLayer } = ctx;
if (startX < 0 || startX >= tilemap.width || startY < 0 || startY >= tilemap.height) {
return;
}
if (editingCollision) {
// Flood fill collision
const targetCollision = tilemap.hasCollision(startX, startY);
const newCollision = targetCollision ? 0 : 1;
const stack: [number, number][] = [[startX, startY]];
const visited = new Set<string>();
while (stack.length > 0) {
const [x, y] = stack.pop()!;
const key = `${x},${y}`;
if (visited.has(key)) continue;
if (x < 0 || x >= tilemap.width || y < 0 || y >= tilemap.height) continue;
if (tilemap.hasCollision(x, y) !== targetCollision) continue;
visited.add(key);
tilemap.setCollision(x, y, newCollision);
stack.push([x + 1, y], [x - 1, y], [x, y + 1], [x, y - 1]);
}
} else {
// Flood fill tiles
const targetTile = tilemap.getTile(currentLayer, startX, startY);
const newTile = selectedTiles ? (selectedTiles.tiles[0] ?? 1) : 1;
if (targetTile === newTile) return;
const stack: [number, number][] = [[startX, startY]];
const visited = new Set<string>();
while (stack.length > 0) {
const [x, y] = stack.pop()!;
const key = `${x},${y}`;
if (visited.has(key)) continue;
if (x < 0 || x >= tilemap.width || y < 0 || y >= tilemap.height) continue;
if (tilemap.getTile(currentLayer, x, y) !== targetTile) continue;
visited.add(key);
tilemap.setTile(currentLayer, x, y, newTile);
stack.push([x + 1, y], [x - 1, y], [x, y + 1], [x, y - 1]);
}
}
}
}