feat(engine-core): 添加统一输入系统 (#282)
* perf(core): 优化 EntitySystem 迭代性能,添加 CommandBuffer 延迟命令
ReactiveQuery 快照优化:
- 添加快照机制,避免每帧拷贝数组
- 只在实体列表变化时创建新快照
- 静态场景下多个系统共享同一快照
CommandBuffer 延迟命令系统:
- 支持延迟添加/移除组件、销毁实体、设置实体激活状态
- 每个系统拥有独立的 commands 属性
- 命令在帧末统一执行,避免迭代过程中修改实体列表
Scene 更新:
- 在 lateUpdate 后自动刷新所有系统的命令缓冲区
文档:
- 更新系统文档,添加 CommandBuffer 使用说明
* fix(ci): upgrade first-interaction action to v1.3.0
Fix Docker build failure in welcome workflow.
* fix(ci): upgrade pnpm/action-setup to v4 and fix unused import
- Upgrade pnpm/action-setup@v2 to v4 in all workflow files
- Remove unused CommandType import in CommandBuffer.test.ts
* fix(ci): remove duplicate pnpm version specification
* feat(engine-core): 添加统一输入系统
添加完整的输入系统,支持平台抽象:
- IPlatformInputSubsystem: 扩展接口支持键盘/鼠标/滚轮事件
- WebInputSubsystem: 浏览器实现,支持事件绑定/解绑
- InputManager: 全局输入状态管理器(键盘、鼠标、触摸)
- InputSystem: ECS 系统,连接平台事件到 InputManager
- GameRuntime 集成: 自动创建 InputSystem 并绑定平台子系统
使用方式:
```typescript
import { Input, MouseButton } from '@esengine/engine-core';
if (Input.isKeyDown('KeyW')) { /* 移动 */ }
if (Input.isKeyJustPressed('Space')) { /* 跳跃 */ }
if (Input.isMouseButtonDown(MouseButton.Left)) { /* 射击 */ }
```
* fix(runtime-core): 添加缺失的 platform-common 依赖
* fix(runtime-core): 移除 platform-web 依赖避免循环依赖
* fix(runtime-core): 使用工厂函数注入 InputSubsystem 避免循环依赖
- BrowserPlatformAdapter 通过 inputSubsystemFactory 配置接收输入子系统
- 在 IPlatformInputSubsystem 接口添加可选的 dispose 方法
- 移除对 @esengine/platform-web 的直接依赖
This commit is contained in:
22
pnpm-lock.yaml
generated
22
pnpm-lock.yaml
generated
@@ -885,13 +885,17 @@ importers:
|
||||
version: 5.0.10
|
||||
|
||||
packages/engine-core:
|
||||
dependencies:
|
||||
'@esengine/ecs-framework':
|
||||
specifier: workspace:*
|
||||
version: link:../core
|
||||
'@esengine/platform-common':
|
||||
specifier: workspace:*
|
||||
version: link:../platform-common
|
||||
devDependencies:
|
||||
'@esengine/build-config':
|
||||
specifier: workspace:*
|
||||
version: link:../build-config
|
||||
'@esengine/ecs-framework':
|
||||
specifier: workspace:*
|
||||
version: link:../core
|
||||
rimraf:
|
||||
specifier: ^5.0.5
|
||||
version: 5.0.10
|
||||
@@ -1221,13 +1225,10 @@ importers:
|
||||
version: 5.9.3
|
||||
|
||||
packages/runtime-core:
|
||||
devDependencies:
|
||||
dependencies:
|
||||
'@esengine/asset-system':
|
||||
specifier: workspace:*
|
||||
version: link:../asset-system
|
||||
'@esengine/build-config':
|
||||
specifier: workspace:*
|
||||
version: link:../build-config
|
||||
'@esengine/ecs-engine-bindgen':
|
||||
specifier: workspace:*
|
||||
version: link:../ecs-engine-bindgen
|
||||
@@ -1237,6 +1238,13 @@ importers:
|
||||
'@esengine/engine-core':
|
||||
specifier: workspace:*
|
||||
version: link:../engine-core
|
||||
'@esengine/platform-common':
|
||||
specifier: workspace:*
|
||||
version: link:../platform-common
|
||||
devDependencies:
|
||||
'@esengine/build-config':
|
||||
specifier: workspace:*
|
||||
version: link:../build-config
|
||||
rimraf:
|
||||
specifier: ^5.0.5
|
||||
version: 5.0.10
|
||||
|
||||
Reference in New Issue
Block a user