Feature/editor optimization (#251)

* refactor: 编辑器/运行时架构拆分与构建系统升级

* feat(core): 层级系统重构与UI变换矩阵修复

* refactor: 移除 ecs-components 聚合包并修复跨包组件查找问题

* fix(physics): 修复跨包组件类引用问题

* feat: 统一运行时架构与浏览器运行支持

* feat(asset): 实现浏览器运行时资产加载系统

* fix: 修复文档、CodeQL安全问题和CI类型检查错误

* fix: 修复文档、CodeQL安全问题和CI类型检查错误

* fix: 修复文档、CodeQL安全问题、CI类型检查和测试错误

* test: 补齐核心模块测试用例,修复CI构建配置

* fix: 修复测试用例中的类型错误和断言问题

* fix: 修复 turbo build:npm 任务的依赖顺序问题

* fix: 修复 CI 构建错误并优化构建性能
This commit is contained in:
YHH
2025-12-01 22:28:51 +08:00
committed by GitHub
parent 189714c727
commit b42a7b4e43
468 changed files with 18301 additions and 9075 deletions

View File

@@ -0,0 +1,86 @@
import { EntitySystem, Matcher, ECSSystem, Time, Entity } from '@esengine/ecs-framework';
import { SpriteAnimatorComponent } from '../SpriteAnimatorComponent';
import { SpriteComponent } from '../SpriteComponent';
/**
* 精灵动画系统 - 更新所有精灵动画
* Sprite animator system - updates all sprite animations
*/
@ECSSystem('SpriteAnimator', { updateOrder: 50 })
export class SpriteAnimatorSystem extends EntitySystem {
constructor() {
super(Matcher.empty().all(SpriteAnimatorComponent));
}
/**
* 系统初始化时调用
* Called when system is initialized
*/
protected override onInitialize(): void {
// System initialized
}
/**
* 每帧开始时调用
* Called at the beginning of each frame
*/
protected override onBegin(): void {
// Frame begin
}
/**
* 处理匹配的实体
* Process matched entities
*/
protected override process(entities: readonly Entity[]): void {
const deltaTime = Time.deltaTime;
for (const entity of entities) {
if (!entity.enabled) continue;
const animator = entity.getComponent(SpriteAnimatorComponent) as SpriteAnimatorComponent | null;
if (!animator) continue;
// Only call update if playing
if (animator.isPlaying()) {
animator.update(deltaTime);
}
// Sync current frame to sprite component (always, even if not playing)
const sprite = entity.getComponent(SpriteComponent) as SpriteComponent | null;
if (sprite) {
const frame = animator.getCurrentFrame();
if (frame) {
sprite.texture = frame.texture;
// Update UV if specified
if (frame.uv) {
sprite.uv = frame.uv;
}
}
}
}
}
/**
* 实体添加到系统时调用
* Called when entity is added to system
*/
protected override onAdded(entity: Entity): void {
const animator = entity.getComponent(SpriteAnimatorComponent) as SpriteAnimatorComponent | null;
if (animator && animator.autoPlay && animator.defaultAnimation) {
animator.play();
}
}
/**
* 实体从系统移除时调用
* Called when entity is removed from system
*/
protected override onRemoved(entity: Entity): void {
const animator = entity.getComponent(SpriteAnimatorComponent) as SpriteAnimatorComponent | null;
if (animator) {
animator.stop();
}
}
}