feat(pathfinding): 添加寻路系统模块 (#333)

* feat(pathfinding): 添加寻路系统模块

实现完整的寻路系统,支持 A* 算法、网格地图、导航网格和路径平滑:

A* 寻路算法:
- 高效的二叉堆优先队列
- 可配置的启发式权重
- 最大搜索节点限制
- 支持对角移动和穿角避免

网格地图 (GridMap):
- 基于二维数组的网格地图
- 支持 4 方向和 8 方向移动
- 可变移动代价
- 从数组或字符串加载地图

导航网格 (NavMesh):
- 凸多边形导航网格
- 自动检测相邻多边形
- 漏斗算法路径优化
- 适合复杂地形

路径平滑:
- Bresenham 视线检测
- 射线投射视线检测
- 视线简化器 (移除不必要的拐点)
- Catmull-Rom 曲线平滑
- 组合平滑器

启发式函数:
- 曼哈顿距离 (4方向)
- 欧几里得距离 (任意方向)
- 切比雪夫距离 (8方向)
- 八角距离 (8方向,对角线√2)

蓝图节点 (8个):
- FindPath: 基础寻路
- FindPathSmooth: 平滑寻路
- IsWalkable: 检查可通行性
- GetPathLength: 获取路径点数
- GetPathDistance: 获取路径距离
- GetPathPoint: 获取路径点
- MoveAlongPath: 沿路径移动
- HasLineOfSight: 视线检测

* chore: update pnpm-lock.yaml for pathfinding package
This commit is contained in:
YHH
2025-12-25 17:24:24 +08:00
committed by GitHub
parent 4d501ba448
commit e5e647f1a4
19 changed files with 2633 additions and 0 deletions

19
pnpm-lock.yaml generated
View File

@@ -1440,6 +1440,25 @@ importers:
specifier: ^5.0.8
version: 5.0.8(@types/react@18.3.27)(react@18.3.1)(use-sync-external-store@1.6.0(react@18.3.1))
packages/pathfinding:
dependencies:
'@esengine/blueprint':
specifier: workspace:*
version: link:../blueprint
'@esengine/ecs-framework':
specifier: workspace:*
version: link:../core
'@esengine/ecs-framework-math':
specifier: workspace:*
version: link:../math
devDependencies:
tsup:
specifier: ^8.0.0
version: 8.5.1(@microsoft/api-extractor@7.55.1(@types/node@20.19.25))(@swc/core@1.15.3)(jiti@2.6.1)(postcss@8.5.6)(tsx@4.21.0)(typescript@5.9.3)(yaml@2.8.1)
typescript:
specifier: ^5.8.0
version: 5.9.3
packages/physics-rapier2d:
dependencies:
'@esengine/platform-common':