@esengine/pathfinding 13.2.0 → 13.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ecs.d.ts CHANGED
@@ -1,196 +1,237 @@
1
1
  import { Component, EntitySystem, Entity } from '@esengine/ecs-framework';
2
- import { P as PathfindingState, e as IPoint, a as IPathfindingMap, f as IIncrementalPathfinder, m as IPathSmoother } from './IIncrementalPathfinding-3qs7e_pO.js';
3
- import { O as ORCASolver, K as KDTree, b as IObstacle, c as IORCASolverConfig } from './KDTree-2rs2EXvm.js';
2
+ import { S as IVector2, V as IPathPlanner, a7 as IFlowController, a0 as ILocalAvoidance, a2 as ICollisionResolver, _ as IObstacleData } from './FlowController-BztOzQsW.js';
3
+ export { ap as CollisionResolverAdapter, ab as DEFAULT_FLOW_CONTROLLER_CONFIG, ao as DEFAULT_ORCA_PARAMS, ar as FlowController, ag as GridPathfinderAdapter, a3 as ICongestionZone, a4 as IFlowAgentData, a5 as IFlowControlResult, a6 as IFlowControllerConfig, au as IGridPathfinderAdapterConfig, av as IIncrementalGridPathPlannerConfig, at as IORCAParams, ak as IncrementalGridPathPlannerAdapter, ae as NavMeshPathPlannerAdapter, am as ORCALocalAvoidanceAdapter, aa as PassPermission, ah as createAStarPlanner, aq as createDefaultCollisionResolver, as as createFlowController, aj as createHPAPlanner, al as createIncrementalAStarPlanner, ai as createJPSPlanner, af as createNavMeshPathPlanner, an as createORCAAvoidance } from './FlowController-BztOzQsW.js';
4
+ import './CollisionResolver-CSgWsegP.js';
4
5
  import '@esengine/ecs-framework-math';
5
6
 
6
7
  /**
7
- * @zh 寻路代理组件
8
- * @en Pathfinding Agent Component
8
+ * @zh 统一导航代理组件
9
+ * @en Unified Navigation Agent Component
10
+ *
11
+ * @zh 算法无关的通用导航属性,配合 NavigationSystem 使用
12
+ * @en Algorithm-agnostic common navigation properties, works with NavigationSystem
9
13
  */
10
14
 
11
15
  /**
12
- * @zh 寻路代理组件
13
- * @en Pathfinding Agent Component
16
+ * @zh 导航状态
17
+ * @en Navigation state
18
+ */
19
+ declare enum NavigationState {
20
+ /**
21
+ * @zh 空闲
22
+ * @en Idle
23
+ */
24
+ Idle = "idle",
25
+ /**
26
+ * @zh 正在导航
27
+ * @en Navigating
28
+ */
29
+ Navigating = "navigating",
30
+ /**
31
+ * @zh 已到达
32
+ * @en Arrived
33
+ */
34
+ Arrived = "arrived",
35
+ /**
36
+ * @zh 路径被阻挡
37
+ * @en Path blocked
38
+ */
39
+ Blocked = "blocked",
40
+ /**
41
+ * @zh 无法到达
42
+ * @en Unreachable
43
+ */
44
+ Unreachable = "unreachable"
45
+ }
46
+ /**
47
+ * @zh 统一导航代理组件
48
+ * @en Unified navigation agent component
14
49
  *
15
- * @zh 附加到需要寻路的实体上,管理寻路请求和结果
16
- * @en Attach to entities that need pathfinding, manages path requests and results
50
+ * @zh 包含算法无关的通用导航属性,不包含算法特定参数
51
+ * @en Contains algorithm-agnostic common navigation properties, no algorithm-specific parameters
17
52
  *
18
53
  * @example
19
54
  * ```typescript
20
55
  * const entity = scene.createEntity('Agent');
21
- * const agent = entity.addComponent(new PathfindingAgentComponent());
22
56
  *
23
- * // Set initial position
24
- * agent.x = 10;
25
- * agent.y = 10;
57
+ * // 添加导航代理组件
58
+ * const nav = entity.addComponent(new NavigationAgentComponent());
59
+ * nav.radius = 0.5;
60
+ * nav.maxSpeed = 5.0;
26
61
  *
27
- * // Request path to target
28
- * agent.requestPathTo(50, 50);
62
+ * // 设置目标
63
+ * nav.setDestination(100, 200);
29
64
  *
30
- * // In movement system, follow the path
31
- * const waypoint = agent.getNextWaypoint();
32
- * if (waypoint) {
33
- * // Move towards waypoint
34
- * // When reached, call agent.advanceWaypoint()
35
- * }
65
+ * // NavigationSystem 会自动处理:
66
+ * // 1. 使用 IPathPlanner 计算全局路径
67
+ * // 2. 使用 ILocalAvoidance 进行局部避让
68
+ * // 3. 使用 ICollisionResolver 防止穿透
36
69
  * ```
37
70
  */
38
- declare class PathfindingAgentComponent extends Component {
71
+ declare class NavigationAgentComponent extends Component {
39
72
  /**
40
- * @zh 当前位置 X 坐标
41
- * @en Current position X coordinate
73
+ * @zh 代理半径
74
+ * @en Agent radius
42
75
  */
43
- x: number;
76
+ radius: number;
44
77
  /**
45
- * @zh 当前位置 Y 坐标
46
- * @en Current position Y coordinate
78
+ * @zh 最大速度
79
+ * @en Maximum speed
47
80
  */
48
- y: number;
81
+ maxSpeed: number;
49
82
  /**
50
- * @zh 目标位置 X 坐标
51
- * @en Target position X coordinate
83
+ * @zh 加速度(用于平滑移动)
84
+ * @en Acceleration (for smooth movement)
52
85
  */
53
- targetX: number;
86
+ acceleration: number;
54
87
  /**
55
- * @zh 目标位置 Y 坐标
56
- * @en Target position Y coordinate
88
+ * @zh 路径点到达阈值
89
+ * @en Waypoint arrival threshold
57
90
  */
58
- targetY: number;
91
+ waypointThreshold: number;
59
92
  /**
60
- * @zh 是否有新的寻路请求待处理
61
- * @en Whether there is a new path request pending
93
+ * @zh 目标到达阈值
94
+ * @en Destination arrival threshold
62
95
  */
63
- hasRequest: boolean;
96
+ arrivalThreshold: number;
64
97
  /**
65
- * @zh 寻路优先级(数值越小优先级越高)
66
- * @en Pathfinding priority (lower number = higher priority)
98
+ * @zh 路径重新计算间隔(秒)
99
+ * @en Path recalculation interval (seconds)
67
100
  */
68
- priority: number;
101
+ repathInterval: number;
69
102
  /**
70
- * @zh 每帧最大迭代次数
71
- * @en Maximum iterations per frame
103
+ * @zh 是否启用导航
104
+ * @en Whether navigation is enabled
72
105
  */
73
- maxIterationsPerFrame: number;
106
+ enabled: boolean;
74
107
  /**
75
- * @zh 是否启用动态重规划
76
- * @en Whether dynamic replanning is enabled
108
+ * @zh 是否自动重新计算被阻挡的路径
109
+ * @en Whether to auto repath when blocked
77
110
  */
78
- enableDynamicReplan: boolean;
111
+ autoRepath: boolean;
79
112
  /**
80
- * @zh 向前探测距离(用于障碍物检测)
81
- * @en Lookahead distance for obstacle detection
113
+ * @zh 是否启用平滑转向
114
+ * @en Whether to enable smooth steering
82
115
  */
83
- lookaheadDistance: number;
116
+ smoothSteering: boolean;
84
117
  /**
85
- * @zh 路径验证间隔(帧数)
86
- * @en Path validation interval (in frames)
118
+ * @zh 当前位置
119
+ * @en Current position
87
120
  */
88
- validationInterval: number;
121
+ position: IVector2;
89
122
  /**
90
- * @zh 当前寻路状态
91
- * @en Current pathfinding state
123
+ * @zh 当前速度
124
+ * @en Current velocity
92
125
  */
93
- state: PathfindingState;
126
+ velocity: IVector2;
94
127
  /**
95
- * @zh 当前请求 ID
96
- * @en Current request ID
128
+ * @zh 目标位置
129
+ * @en Destination position
97
130
  */
98
- currentRequestId: number;
131
+ destination: IVector2 | null;
99
132
  /**
100
- * @zh 当前路径点列表
101
- * @en Current path waypoints
133
+ * @zh 当前导航状态
134
+ * @en Current navigation state
102
135
  */
103
- path: IPoint[];
136
+ state: NavigationState;
104
137
  /**
105
- * @zh 当前路径索引
106
- * @en Current path index
138
+ * @zh 当前路径
139
+ * @en Current path
107
140
  */
108
- pathIndex: number;
141
+ path: IVector2[];
109
142
  /**
110
- * @zh 路径总代价
111
- * @en Total path cost
143
+ * @zh 当前路径点索引
144
+ * @en Current waypoint index
112
145
  */
113
- pathCost: number;
146
+ currentWaypointIndex: number;
147
+ /**
148
+ * @zh 上次重新计算路径的时间
149
+ * @en Last repath time
150
+ */
151
+ lastRepathTime: number;
152
+ /**
153
+ * @zh 当前增量寻路请求 ID
154
+ * @en Current incremental pathfinding request ID
155
+ */
156
+ currentRequestId: number;
114
157
  /**
115
158
  * @zh 寻路进度 (0-1)
116
159
  * @en Pathfinding progress (0-1)
117
160
  */
118
- progress: number;
161
+ pathProgress: number;
119
162
  /**
120
- * @zh 上次验证的帧号
121
- * @en Last validation frame number
163
+ * @zh 优先级(数字越小优先级越高)
164
+ * @en Priority (lower number = higher priority)
122
165
  */
123
- lastValidationFrame: number;
166
+ priority: number;
124
167
  /**
125
- * @zh 寻路完成回调
126
- * @en Pathfinding complete callback
168
+ * @zh 是否正在等待路径计算完成
169
+ * @en Whether waiting for path computation to complete
127
170
  */
128
- onPathComplete?: (found: boolean, path: readonly IPoint[]) => void;
171
+ isComputingPath: boolean;
129
172
  /**
130
- * @zh 寻路进度回调
131
- * @en Pathfinding progress callback
173
+ * @zh 设置位置
174
+ * @en Set position
175
+ *
176
+ * @param x - @zh X 坐标 @en X coordinate
177
+ * @param y - @zh Y 坐标 @en Y coordinate
132
178
  */
133
- onPathProgress?: (progress: number) => void;
179
+ setPosition(x: number, y: number): void;
134
180
  /**
135
- * @zh 请求寻路到目标位置
136
- * @en Request path to target position
181
+ * @zh 设置目标位置
182
+ * @en Set destination
137
183
  *
138
- * @param targetX - @zh 目标 X 坐标 @en Target X coordinate
139
- * @param targetY - @zh 目标 Y 坐标 @en Target Y coordinate
184
+ * @param x - @zh 目标 X 坐标 @en Destination X coordinate
185
+ * @param y - @zh 目标 Y 坐标 @en Destination Y coordinate
140
186
  */
141
- requestPathTo(targetX: number, targetY: number): void;
187
+ setDestination(x: number, y: number): void;
142
188
  /**
143
- * @zh 取消当前寻路
144
- * @en Cancel current pathfinding
189
+ * @zh 停止导航
190
+ * @en Stop navigation
145
191
  */
146
- cancelPath(): void;
192
+ stop(): void;
147
193
  /**
148
- * @zh 获取下一个路径点
149
- * @en Get next waypoint
194
+ * @zh 获取当前路径点
195
+ * @en Get current waypoint
150
196
  *
151
- * @returns @zh 下一个路径点或 null @en Next waypoint or null
152
- */
153
- getNextWaypoint(): IPoint | null;
154
- /**
155
- * @zh 前进到下一个路径点
156
- * @en Advance to next waypoint
197
+ * @returns @zh 当前路径点,如果没有则返回 null @en Current waypoint, or null if none
157
198
  */
158
- advanceWaypoint(): void;
199
+ getCurrentWaypoint(): IVector2 | null;
159
200
  /**
160
- * @zh 检查是否到达路径终点
161
- * @en Check if reached path end
201
+ * @zh 获取到目标的距离
202
+ * @en Get distance to destination
162
203
  *
163
- * @returns @zh 是否到达终点 @en Whether reached end
204
+ * @returns @zh 到目标的距离,如果没有目标则返回 Infinity @en Distance to destination, or Infinity if no destination
164
205
  */
165
- isPathComplete(): boolean;
206
+ getDistanceToDestination(): number;
166
207
  /**
167
- * @zh 检查是否正在寻路
168
- * @en Check if pathfinding is in progress
208
+ * @zh 获取当前速度大小
209
+ * @en Get current speed
169
210
  *
170
- * @returns @zh 是否正在寻路 @en Whether pathfinding is in progress
211
+ * @returns @zh 当前速度大小 @en Current speed magnitude
171
212
  */
172
- isSearching(): boolean;
213
+ getCurrentSpeed(): number;
173
214
  /**
174
- * @zh 检查是否有有效路径
175
- * @en Check if has valid path
215
+ * @zh 检查是否已到达目标
216
+ * @en Check if arrived at destination
176
217
  *
177
- * @returns @zh 是否有有效路径 @en Whether has valid path
218
+ * @returns @zh 是否已到达 @en Whether arrived
178
219
  */
179
- hasValidPath(): boolean;
220
+ hasArrived(): boolean;
180
221
  /**
181
- * @zh 获取剩余路径点数量
182
- * @en Get remaining waypoint count
222
+ * @zh 检查路径是否被阻挡
223
+ * @en Check if path is blocked
183
224
  *
184
- * @returns @zh 剩余路径点数量 @en Remaining waypoint count
225
+ * @returns @zh 是否被阻挡 @en Whether blocked
185
226
  */
186
- getRemainingWaypointCount(): number;
227
+ isBlocked(): boolean;
187
228
  /**
188
- * @zh 获取当前路径的总长度
189
- * @en Get total path length
229
+ * @zh 检查目标是否无法到达
230
+ * @en Check if destination is unreachable
190
231
  *
191
- * @returns @zh 路径总长度 @en Total path length
232
+ * @returns @zh 是否无法到达 @en Whether unreachable
192
233
  */
193
- getPathLength(): number;
234
+ isUnreachable(): boolean;
194
235
  /**
195
236
  * @zh 重置组件状态
196
237
  * @en Reset component state
@@ -204,681 +245,433 @@ declare class PathfindingAgentComponent extends Component {
204
245
  }
205
246
 
206
247
  /**
207
- * @zh 寻路地图组件
208
- * @en Pathfinding Map Component
248
+ * @zh 统一导航系统
249
+ * @en Unified Navigation System
250
+ *
251
+ * @zh 可插拔的导航系统,支持运行时切换寻路、避让、碰撞检测算法
252
+ * @en Pluggable navigation system, supports runtime swapping of pathfinding, avoidance, and collision detection algorithms
209
253
  */
210
254
 
211
255
  /**
212
- * @zh 地图类型
213
- * @en Map type
214
- */
215
- type PathfindingMapType = 'grid' | 'navmesh';
216
- /**
217
- * @zh 寻路地图组件
218
- * @en Pathfinding Map Component
219
- *
220
- * @zh 挂载在场景实体上,持有地图实例和增量寻路器
221
- * @en Attached to scene entity, holds map instance and incremental pathfinder
222
- *
223
- * @example
224
- * ```typescript
225
- * const mapEntity = scene.createEntity('PathfindingMap');
226
- * const mapComp = mapEntity.addComponent(new PathfindingMapComponent());
227
- *
228
- * // Configure map
229
- * mapComp.width = 100;
230
- * mapComp.height = 100;
231
- * mapComp.iterationsBudget = 2000;
232
- *
233
- * // Map and pathfinder will be initialized by PathfindingSystem
234
- * ```
256
+ * @zh 导航系统配置
257
+ * @en Navigation system configuration
235
258
  */
236
- declare class PathfindingMapComponent extends Component {
237
- /**
238
- * @zh 地图类型
239
- * @en Map type
240
- */
241
- mapType: PathfindingMapType;
242
- /**
243
- * @zh 网格宽度(仅 grid 类型)
244
- * @en Grid width (grid type only)
245
- */
246
- width: number;
247
- /**
248
- * @zh 网格高度(仅 grid 类型)
249
- * @en Grid height (grid type only)
250
- */
251
- height: number;
252
- /**
253
- * @zh 是否允许对角移动
254
- * @en Whether diagonal movement is allowed
255
- */
256
- allowDiagonal: boolean;
257
- /**
258
- * @zh 是否避免穿角
259
- * @en Whether to avoid corner cutting
260
- */
261
- avoidCorners: boolean;
262
- /**
263
- * @zh 每帧处理的最大代理数
264
- * @en Maximum agents processed per frame
265
- */
266
- maxAgentsPerFrame: number;
259
+ interface INavigationSystemConfig {
267
260
  /**
268
- * @zh 每帧总迭代次数预算
269
- * @en Total iterations budget per frame
270
- */
271
- iterationsBudget: number;
272
- /**
273
- * @zh 是否启用路径平滑
274
- * @en Whether path smoothing is enabled
275
- */
276
- enableSmoothing: boolean;
277
- /**
278
- * @zh 路径平滑类型
279
- * @en Path smoothing type
280
- */
281
- smoothingType: 'los' | 'catmullrom' | 'combined';
282
- /**
283
- * @zh 是否启用路径缓存
284
- * @en Whether path caching is enabled
285
- */
286
- enableCache: boolean;
287
- /**
288
- * @zh 缓存最大条目数
289
- * @en Maximum cache entries
290
- */
291
- cacheMaxEntries: number;
292
- /**
293
- * @zh 缓存过期时间(毫秒),0 表示不过期
294
- * @en Cache TTL in milliseconds, 0 means no expiration
295
- */
296
- cacheTtlMs: number;
297
- /**
298
- * @zh 是否显示调试信息
299
- * @en Whether to show debug info
300
- */
301
- debugMode: boolean;
302
- /**
303
- * @zh 是否显示网格
304
- * @en Whether to show grid
305
- */
306
- showGrid: boolean;
307
- /**
308
- * @zh 是否显示路径
309
- * @en Whether to show paths
310
- */
311
- showPaths: boolean;
312
- /**
313
- * @zh 地图实例
314
- * @en Map instance
315
- */
316
- map: IPathfindingMap | null;
317
- /**
318
- * @zh 增量寻路器实例
319
- * @en Incremental pathfinder instance
320
- */
321
- pathfinder: IIncrementalPathfinder | null;
322
- /**
323
- * @zh 路径平滑器实例
324
- * @en Path smoother instance
325
- */
326
- smoother: IPathSmoother | null;
327
- /**
328
- * @zh 是否已初始化
329
- * @en Whether initialized
261
+ * @zh 时间步长
262
+ * @en Time step
330
263
  */
331
- initialized: boolean;
264
+ timeStep?: number;
332
265
  /**
333
- * @zh 当前活跃请求数
334
- * @en Current active request count
266
+ * @zh 是否启用路径规划阶段
267
+ * @en Whether to enable path planning stage
335
268
  */
336
- activeRequests: number;
269
+ enablePathPlanning?: boolean;
337
270
  /**
338
- * @zh 本帧使用的迭代次数
339
- * @en Iterations used this frame
271
+ * @zh 是否启用流量控制阶段
272
+ * @en Whether to enable flow control stage
340
273
  */
341
- iterationsUsedThisFrame: number;
274
+ enableFlowControl?: boolean;
342
275
  /**
343
- * @zh 本帧处理的代理数
344
- * @en Agents processed this frame
276
+ * @zh 是否启用局部避让阶段
277
+ * @en Whether to enable local avoidance stage
345
278
  */
346
- agentsProcessedThisFrame: number;
279
+ enableLocalAvoidance?: boolean;
347
280
  /**
348
- * @zh 缓存命中次数
349
- * @en Cache hit count
281
+ * @zh 是否启用碰撞解决阶段
282
+ * @en Whether to enable collision resolution stage
350
283
  */
351
- cacheHits: number;
284
+ enableCollisionResolution?: boolean;
352
285
  /**
353
- * @zh 缓存未命中次数
354
- * @en Cache miss count
286
+ * @zh 是否启用代理间碰撞解决
287
+ * @en Whether to enable agent-agent collision resolution
355
288
  */
356
- cacheMisses: number;
289
+ enableAgentCollisionResolution?: boolean;
357
290
  /**
358
- * @zh 设置网格单元格是否可通行
359
- * @en Set grid cell walkability
291
+ * @zh 是否启用时间切片寻路(需要 IIncrementalPathPlanner)
292
+ * @en Whether to enable time-sliced pathfinding (requires IIncrementalPathPlanner)
360
293
  *
361
- * @param x - @zh X 坐标 @en X coordinate
362
- * @param y - @zh Y 坐标 @en Y coordinate
363
- * @param walkable - @zh 是否可通行 @en Is walkable
294
+ * @zh 启用后,寻路计算会分散到多帧执行,避免卡顿
295
+ * @en When enabled, pathfinding computation is spread across multiple frames to avoid stuttering
364
296
  */
365
- setWalkable(x: number, y: number, walkable: boolean): void;
297
+ enableTimeSlicing?: boolean;
366
298
  /**
367
- * @zh 设置矩形区域是否可通行
368
- * @en Set rectangular area walkability
299
+ * @zh 每帧总迭代预算
300
+ * @en Total iteration budget per frame
369
301
  *
370
- * @param x - @zh 起始 X @en Start X
371
- * @param y - @zh 起始 Y @en Start Y
372
- * @param width - @zh 宽度 @en Width
373
- * @param height - @zh 高度 @en Height
374
- * @param walkable - @zh 是否可通行 @en Is walkable
375
- */
376
- setRectWalkable(x: number, y: number, rectWidth: number, rectHeight: number, walkable: boolean): void;
377
- /**
378
- * @zh 检查位置是否可通行
379
- * @en Check if position is walkable
302
+ * @zh 所有代理共享此预算,根据优先级分配
303
+ * @en All agents share this budget, allocated by priority
380
304
  *
381
- * @param x - @zh X 坐标 @en X coordinate
382
- * @param y - @zh Y 坐标 @en Y coordinate
383
- * @returns @zh 是否可通行 @en Is walkable
384
- */
385
- isWalkable(x: number, y: number): boolean;
386
- /**
387
- * @zh 重置统计信息
388
- * @en Reset statistics
305
+ * @default 1000
389
306
  */
390
- resetStats(): void;
307
+ iterationsBudget?: number;
391
308
  /**
392
- * @zh 获取剩余迭代预算
393
- * @en Get remaining iteration budget
309
+ * @zh 每帧最大处理代理数
310
+ * @en Maximum agents to process per frame
394
311
  *
395
- * @returns @zh 剩余预算 @en Remaining budget
396
- */
397
- getRemainingBudget(): number;
398
- /**
399
- * @zh 获取缓存统计信息
400
- * @en Get cache statistics
312
+ * @zh 限制每帧处理的代理数量,避免过载
313
+ * @en Limits the number of agents processed per frame to avoid overload
401
314
  *
402
- * @returns @zh 缓存统计 @en Cache statistics
315
+ * @default 10
403
316
  */
404
- getCacheStats(): {
405
- enabled: boolean;
406
- hits: number;
407
- misses: number;
408
- hitRate: number;
409
- };
317
+ maxAgentsPerFrame?: number;
410
318
  /**
411
- * @zh 组件从实体移除时调用
412
- * @en Called when component is removed from entity
319
+ * @zh 每个代理每帧最大迭代数
320
+ * @en Maximum iterations per agent per frame
321
+ *
322
+ * @default 200
413
323
  */
414
- onRemovedFromEntity(): void;
324
+ maxIterationsPerAgent?: number;
415
325
  }
416
-
417
326
  /**
418
- * @zh 寻路系统
419
- * @en Pathfinding System
420
- */
421
-
422
- /**
423
- * @zh 寻路系统
424
- * @en Pathfinding System
327
+ * @zh 统一导航系统
328
+ * @en Unified Navigation System
425
329
  *
426
- * @zh 处理所有 PathfindingAgentComponent,支持时间切片和动态重规划
427
- * @en Processes all PathfindingAgentComponents, supports time slicing and dynamic replanning
330
+ * @zh 可插拔的导航系统,处理管线:PathPlanning → LocalAvoidance → CollisionResolution
331
+ * @en Pluggable navigation system, pipeline: PathPlanning LocalAvoidance CollisionResolution
428
332
  *
429
333
  * @example
430
334
  * ```typescript
431
- * // Add system to scene
432
- * scene.addSystem(new PathfindingSystem());
335
+ * import {
336
+ * NavigationSystem,
337
+ * NavigationAgentComponent,
338
+ * createNavMeshPathPlanner,
339
+ * createORCAAvoidance,
340
+ * createDefaultCollisionResolver
341
+ * } from '@esengine/pathfinding/ecs';
342
+ *
343
+ * // 创建系统
344
+ * const navSystem = new NavigationSystem();
345
+ *
346
+ * // 配置算法(可选,每个阶段都可以独立启用/禁用)
347
+ * navSystem.setPathPlanner(createNavMeshPathPlanner(navMesh));
348
+ * navSystem.setLocalAvoidance(createORCAAvoidance());
349
+ * navSystem.setCollisionResolver(createDefaultCollisionResolver());
433
350
  *
434
- * // Create map entity
435
- * const mapEntity = scene.createEntity('Map');
436
- * mapEntity.addComponent(new PathfindingMapComponent());
351
+ * scene.addSystem(navSystem);
437
352
  *
438
- * // Create agents
353
+ * // 添加障碍物
354
+ * navSystem.addObstacle({ vertices: [...] });
355
+ *
356
+ * // 创建代理
439
357
  * const agent = scene.createEntity('Agent');
440
- * const pathAgent = agent.addComponent(new PathfindingAgentComponent());
441
- * pathAgent.requestPathTo(50, 50);
358
+ * const nav = agent.addComponent(new NavigationAgentComponent());
359
+ * nav.setPosition(0, 0);
360
+ * nav.setDestination(100, 100);
442
361
  *
443
- * // System handles pathfinding automatically each frame
362
+ * // 运行时切换算法
363
+ * navSystem.setPathPlanner(createJPSPlanner(gridMap));
364
+ * navSystem.setLocalAvoidance(null); // 禁用避让
444
365
  * ```
445
366
  */
446
- declare class PathfindingSystem extends EntitySystem {
447
- private mapEntity;
448
- private mapComponent;
449
- private pathValidator;
450
- private agentQueue;
451
- private frameCounter;
452
- constructor();
367
+ declare class NavigationSystem extends EntitySystem {
368
+ private config;
369
+ private pathPlanner;
370
+ private flowController;
371
+ private localAvoidance;
372
+ private collisionResolver;
453
373
  /**
454
- * @zh 系统初始化
455
- * @en System initialization
374
+ * @zh 静态障碍物(墙壁、建筑等)- 由 PathPlanner 和 CollisionResolver 处理
375
+ * @en Static obstacles (walls, buildings) - handled by PathPlanner and CollisionResolver
456
376
  */
457
- protected onInitialize(): void;
377
+ private staticObstacles;
458
378
  /**
459
- * @zh 系统激活时调用
460
- * @en Called when system is enabled
379
+ * @zh 动态障碍物(移动物体等)- 由 ORCA 和 CollisionResolver 处理
380
+ * @en Dynamic obstacles (moving objects) - handled by ORCA and CollisionResolver
461
381
  */
462
- protected onEnable(): void;
382
+ private dynamicObstacles;
383
+ private currentTime;
384
+ private agentEnterTimes;
463
385
  /**
464
- * @zh 处理实体
465
- * @en Process entities
386
+ * @zh 是否为增量寻路器
387
+ * @en Whether the path planner is incremental
466
388
  */
467
- protected process(entities: readonly Entity[]): void;
389
+ private isIncrementalPlanner;
468
390
  /**
469
- * @zh 查找地图实体
470
- * @en Find map entity
391
+ * @zh 等待寻路的代理队列(按优先级排序)
392
+ * @en Queue of agents waiting for pathfinding (sorted by priority)
471
393
  */
472
- private findMapEntity;
394
+ private pendingPathRequests;
395
+ constructor(config?: INavigationSystemConfig);
473
396
  /**
474
- * @zh 初始化地图
475
- * @en Initialize map
397
+ * @zh 设置路径规划器
398
+ * @en Set path planner
399
+ *
400
+ * @param planner - @zh 路径规划器,传入 null 禁用路径规划 @en Path planner, pass null to disable
401
+ *
402
+ * @zh 如果传入 IIncrementalPathPlanner 且启用了时间切片,会自动使用增量寻路
403
+ * @en If passing IIncrementalPathPlanner and time slicing is enabled, will automatically use incremental pathfinding
404
+ *
405
+ * @example
406
+ * ```typescript
407
+ * navSystem.setPathPlanner(createNavMeshPathPlanner(navMesh));
408
+ * navSystem.setPathPlanner(createAStarPlanner(gridMap));
409
+ * navSystem.setPathPlanner(createIncrementalAStarPlanner(gridMap)); // 支持时间切片
410
+ * navSystem.setPathPlanner(null); // 禁用
411
+ * ```
476
412
  */
477
- private initializeMap;
413
+ setPathPlanner(planner: IPathPlanner | null): void;
478
414
  /**
479
- * @zh 构建代理优先级队列
480
- * @en Build agent priority queue
415
+ * @zh 获取当前路径规划器
416
+ * @en Get current path planner
481
417
  */
482
- private buildAgentQueue;
418
+ getPathPlanner(): IPathPlanner | null;
483
419
  /**
484
- * @zh 使用预算处理代理
485
- * @en Process agents with budget
420
+ * @zh 设置流量控制器
421
+ * @en Set flow controller
422
+ *
423
+ * @param controller - @zh 流量控制器,传入 null 禁用流量控制 @en Flow controller, pass null to disable
424
+ *
425
+ * @example
426
+ * ```typescript
427
+ * navSystem.setFlowController(createFlowController());
428
+ * navSystem.setFlowController(null); // 禁用
429
+ * ```
486
430
  */
487
- private processAgentsWithBudget;
431
+ setFlowController(controller: IFlowController | null): void;
488
432
  /**
489
- * @zh 启动新的寻路请求
490
- * @en Start new pathfinding request
433
+ * @zh 获取当前流量控制器
434
+ * @en Get current flow controller
491
435
  */
492
- private startNewRequest;
436
+ getFlowController(): IFlowController | null;
493
437
  /**
494
- * @zh 从进度更新代理状态
495
- * @en Update agent state from progress
438
+ * @zh 设置局部避让算法
439
+ * @en Set local avoidance algorithm
440
+ *
441
+ * @param avoidance - @zh 局部避让算法,传入 null 禁用避让 @en Local avoidance, pass null to disable
442
+ *
443
+ * @example
444
+ * ```typescript
445
+ * navSystem.setLocalAvoidance(createORCAAvoidance());
446
+ * navSystem.setLocalAvoidance(null); // 禁用
447
+ * ```
496
448
  */
497
- private updateAgentFromProgress;
449
+ setLocalAvoidance(avoidance: ILocalAvoidance | null): void;
498
450
  /**
499
- * @zh 周期性验证路径有效性
500
- * @en Periodically validate path validity
451
+ * @zh 获取当前局部避让算法
452
+ * @en Get current local avoidance algorithm
501
453
  */
502
- private validatePaths;
503
- }
504
-
505
- /**
506
- * @zh 避让代理组件
507
- * @en Avoidance Agent Component
508
- */
509
-
510
- /**
511
- * @zh 避让代理组件
512
- * @en Avoidance Agent Component
513
- *
514
- * @zh 附加到需要局部避让的实体上,与 ORCA 系统配合使用
515
- * @en Attach to entities that need local avoidance, works with ORCA system
516
- *
517
- * @example
518
- * ```typescript
519
- * const entity = scene.createEntity('Monster');
520
- *
521
- * // 添加避让代理
522
- * const avoidance = entity.addComponent(new AvoidanceAgentComponent());
523
- * avoidance.radius = 0.5;
524
- * avoidance.maxSpeed = 5.0;
525
- *
526
- * // 设置首选速度(朝向目标)
527
- * avoidance.setPreferredVelocityTowards(targetX, targetY, currentX, currentY);
528
- *
529
- * // 系统计算后,使用新速度更新位置
530
- * // After system computes, use new velocity to update position
531
- * x += avoidance.newVelocityX * deltaTime;
532
- * y += avoidance.newVelocityY * deltaTime;
533
- * ```
534
- */
535
- declare class AvoidanceAgentComponent extends Component {
454
+ getLocalAvoidance(): ILocalAvoidance | null;
536
455
  /**
537
- * @zh 代理半径
538
- * @en Agent radius
456
+ * @zh 设置碰撞解决器
457
+ * @en Set collision resolver
539
458
  *
540
- * @zh 用于碰撞检测和避让计算
541
- * @en Used for collision detection and avoidance computation
459
+ * @param resolver - @zh 碰撞解决器,传入 null 禁用碰撞解决 @en Collision resolver, pass null to disable
460
+ *
461
+ * @example
462
+ * ```typescript
463
+ * navSystem.setCollisionResolver(createDefaultCollisionResolver());
464
+ * navSystem.setCollisionResolver(null); // 禁用
465
+ * ```
542
466
  */
543
- radius: number;
467
+ setCollisionResolver(resolver: ICollisionResolver | null): void;
544
468
  /**
545
- * @zh 最大速度
546
- * @en Maximum speed
469
+ * @zh 获取当前碰撞解决器
470
+ * @en Get current collision resolver
547
471
  */
548
- maxSpeed: number;
472
+ getCollisionResolver(): ICollisionResolver | null;
549
473
  /**
550
- * @zh 邻居检测距离
551
- * @en Neighbor detection distance
474
+ * @zh 添加静态障碍物(墙壁、建筑等)
475
+ * @en Add static obstacle (walls, buildings, etc.)
552
476
  *
553
- * @zh 只考虑此范围内的其他代理
554
- * @en Only considers other agents within this range
555
- */
556
- neighborDist: number;
557
- /**
558
- * @zh 最大邻居数量
559
- * @en Maximum number of neighbors to consider
477
+ * @zh 静态障碍物由 PathPlanner 规划路径时考虑,CollisionResolver 防止穿透
478
+ * @zh ORCA 不会处理静态障碍物,因为路径规划已经绑开了它们
479
+ * @en Static obstacles are considered by PathPlanner for routing, CollisionResolver for penetration prevention
480
+ * @en ORCA does NOT process static obstacles since path planning already avoids them
560
481
  *
561
- * @zh 限制计算量,优先考虑最近的邻居
562
- * @en Limits computation, prioritizes closest neighbors
482
+ * @param obstacle - @zh 障碍物数据 @en Obstacle data
563
483
  */
564
- maxNeighbors: number;
484
+ addStaticObstacle(obstacle: IObstacleData): void;
565
485
  /**
566
- * @zh 代理避让时间视野(秒)
567
- * @en Time horizon for agent avoidance (seconds)
486
+ * @zh 添加动态障碍物(移动物体、临时障碍等)
487
+ * @en Add dynamic obstacle (moving objects, temporary obstacles, etc.)
568
488
  *
569
- * @zh 更大的值会让代理更早开始避让,但可能导致过于保守
570
- * @en Larger values make agents start avoiding earlier, but may be too conservative
571
- */
572
- timeHorizon: number;
573
- /**
574
- * @zh 障碍物避让时间视野(秒)
575
- * @en Time horizon for obstacle avoidance (seconds)
576
- */
577
- timeHorizonObst: number;
578
- /**
579
- * @zh 当前位置 X
580
- * @en Current position X
489
+ * @zh 动态障碍物由 ORCA 进行局部避让,CollisionResolver 防止穿透
490
+ * @en Dynamic obstacles are handled by ORCA for local avoidance, CollisionResolver for penetration prevention
581
491
  *
582
- * @zh 如果实体有 Transform 组件,系统会自动同步
583
- * @en If entity has Transform component, system will sync automatically
584
- */
585
- positionX: number;
586
- /**
587
- * @zh 当前位置 Y
588
- * @en Current position Y
492
+ * @param obstacle - @zh 障碍物数据 @en Obstacle data
589
493
  */
590
- positionY: number;
494
+ addDynamicObstacle(obstacle: IObstacleData): void;
591
495
  /**
592
- * @zh 当前速度 X
593
- * @en Current velocity X
496
+ * @zh 移除所有静态障碍物
497
+ * @en Remove all static obstacles
594
498
  */
595
- velocityX: number;
499
+ clearStaticObstacles(): void;
596
500
  /**
597
- * @zh 当前速度 Y
598
- * @en Current velocity Y
501
+ * @zh 移除所有动态障碍物
502
+ * @en Remove all dynamic obstacles
599
503
  */
600
- velocityY: number;
504
+ clearDynamicObstacles(): void;
601
505
  /**
602
- * @zh 首选速度 X(通常指向目标方向)
603
- * @en Preferred velocity X (usually towards target)
506
+ * @zh 移除所有障碍物(静态和动态)
507
+ * @en Remove all obstacles (static and dynamic)
604
508
  */
605
- preferredVelocityX: number;
509
+ clearObstacles(): void;
606
510
  /**
607
- * @zh 首选速度 Y
608
- * @en Preferred velocity Y
511
+ * @zh 获取静态障碍物列表
512
+ * @en Get static obstacles list
609
513
  */
610
- preferredVelocityY: number;
514
+ getStaticObstacles(): readonly IObstacleData[];
611
515
  /**
612
- * @zh ORCA 计算的新速度 X
613
- * @en New velocity X computed by ORCA
516
+ * @zh 获取动态障碍物列表
517
+ * @en Get dynamic obstacles list
614
518
  */
615
- newVelocityX: number;
519
+ getDynamicObstacles(): readonly IObstacleData[];
616
520
  /**
617
- * @zh ORCA 计算的新速度 Y
618
- * @en New velocity Y computed by ORCA
521
+ * @zh 获取所有障碍物列表(静态+动态)
522
+ * @en Get all obstacles list (static + dynamic)
619
523
  */
620
- newVelocityY: number;
524
+ getObstacles(): readonly IObstacleData[];
621
525
  /**
622
- * @zh 是否启用避让
623
- * @en Whether avoidance is enabled
526
+ * @zh 获取所有障碍物用于碰撞检测
527
+ * @en Get all obstacles for collision detection
624
528
  */
625
- enabled: boolean;
529
+ private getAllObstaclesForCollision;
626
530
  /**
627
- * @zh 是否自动应用新速度
628
- * @en Whether to automatically apply new velocity
531
+ * @zh 设置静态障碍物列表
532
+ * @en Set static obstacles list
629
533
  *
630
- * @zh 如果为 true,系统会在计算后自动将 newVelocity 赋值给 velocity
631
- * @en If true, system will automatically assign newVelocity to velocity after computation
534
+ * @param obstacles - @zh 障碍物列表 @en Obstacles list
632
535
  */
633
- autoApplyVelocity: boolean;
536
+ setStaticObstacles(obstacles: IObstacleData[]): void;
634
537
  /**
635
- * @zh 设置位置
636
- * @en Set position
637
- */
638
- setPosition(x: number, y: number): void;
639
- /**
640
- * @zh 设置当前速度
641
- * @en Set current velocity
642
- */
643
- setVelocity(x: number, y: number): void;
644
- /**
645
- * @zh 设置首选速度
646
- * @en Set preferred velocity
647
- */
648
- setPreferredVelocity(x: number, y: number): void;
649
- /**
650
- * @zh 设置首选速度朝向目标
651
- * @en Set preferred velocity towards target
538
+ * @zh 设置动态障碍物列表
539
+ * @en Set dynamic obstacles list
652
540
  *
653
- * @param targetX - @zh 目标 X @en Target X
654
- * @param targetY - @zh 目标 Y @en Target Y
655
- * @param currentX - @zh 当前 X(可选,默认使用 positionX)@en Current X (optional, defaults to positionX)
656
- * @param currentY - @zh 当前 Y(可选,默认使用 positionY)@en Current Y (optional, defaults to positionY)
657
- */
658
- setPreferredVelocityTowards(targetX: number, targetY: number, currentX?: number, currentY?: number): void;
659
- /**
660
- * @zh 应用 ORCA 计算的新速度
661
- * @en Apply new velocity computed by ORCA
662
- */
663
- applyNewVelocity(): void;
664
- /**
665
- * @zh 获取新速度的长度
666
- * @en Get length of new velocity
667
- */
668
- getNewSpeed(): number;
669
- /**
670
- * @zh 获取当前速度的长度
671
- * @en Get length of current velocity
672
- */
673
- getCurrentSpeed(): number;
674
- /**
675
- * @zh 停止代理
676
- * @en Stop the agent
677
- */
678
- stop(): void;
679
- /**
680
- * @zh 重置组件状态
681
- * @en Reset component state
682
- */
683
- reset(): void;
684
- /**
685
- * @zh 组件从实体移除时调用
686
- * @en Called when component is removed from entity
541
+ * @param obstacles - @zh 障碍物列表 @en Obstacles list
687
542
  */
688
- onRemovedFromEntity(): void;
689
- }
690
-
691
- /**
692
- * @zh 避让世界组件
693
- * @en Avoidance World Component
694
- */
695
-
696
- /**
697
- * @zh 避让世界组件
698
- * @en Avoidance World Component
699
- *
700
- * @zh 挂载在场景实体上,持有 ORCA 求解器和静态障碍物
701
- * @en Attached to scene entity, holds ORCA solver and static obstacles
702
- *
703
- * @example
704
- * ```typescript
705
- * const worldEntity = scene.createEntity('AvoidanceWorld');
706
- * const world = worldEntity.addComponent(new AvoidanceWorldComponent());
707
- *
708
- * // 添加静态障碍物(墙壁)
709
- * world.addObstacle({
710
- * vertices: [
711
- * { x: 0, y: 0 },
712
- * { x: 10, y: 0 },
713
- * { x: 10, y: 1 },
714
- * { x: 0, y: 1 }
715
- * ]
716
- * });
717
- *
718
- * // LocalAvoidanceSystem 会自动使用此组件
719
- * ```
720
- */
721
- declare class AvoidanceWorldComponent extends Component {
722
- /**
723
- * @zh 默认时间视野(代理)
724
- * @en Default time horizon for agents
725
- */
726
- defaultTimeHorizon: number;
543
+ setDynamicObstacles(obstacles: IObstacleData[]): void;
727
544
  /**
728
- * @zh 默认时间视野(障碍物)
729
- * @en Default time horizon for obstacles
730
- */
731
- defaultTimeHorizonObst: number;
732
- /**
733
- * @zh 时间步长
734
- * @en Time step
545
+ * @zh 系统销毁时调用
546
+ * @en Called when system is destroyed
735
547
  */
736
- timeStep: number;
548
+ protected onDestroy(): void;
737
549
  /**
738
- * @zh ORCA 求解器实例
739
- * @en ORCA solver instance
550
+ * @zh 处理实体
551
+ * @en Process entities
740
552
  */
741
- solver: ORCASolver | null;
553
+ protected process(entities: readonly Entity[]): void;
742
554
  /**
743
- * @zh KD-Tree 实例
744
- * @en KD-Tree instance
555
+ * @zh 处理等待中的代理
556
+ * @en Handle waiting agent
745
557
  */
746
- kdTree: KDTree | null;
558
+ private handleWaitingAgent;
747
559
  /**
748
- * @zh 静态障碍物列表
749
- * @en List of static obstacles
560
+ * @zh 清理已移除代理的进入时间记录
561
+ * @en Cleanup enter times for removed agents
750
562
  */
751
- obstacles: IObstacle[];
563
+ private cleanupEnterTimes;
752
564
  /**
753
- * @zh 是否已初始化
754
- * @en Whether initialized
565
+ * @zh 处理路径规划(同步模式)
566
+ * @en Process path planning (synchronous mode)
755
567
  */
756
- initialized: boolean;
568
+ private processPathPlanning;
757
569
  /**
758
- * @zh 当前代理数量
759
- * @en Current agent count
570
+ * @zh 处理增量路径规划(时间切片模式)
571
+ * @en Process incremental path planning (time slicing mode)
572
+ *
573
+ * @param agents - @zh 代理列表 @en Agent list
574
+ * @param entityMap - @zh 实体 ID 到代理的映射 @en Entity ID to agent mapping
760
575
  */
761
- agentCount: number;
576
+ private processIncrementalPathPlanning;
762
577
  /**
763
- * @zh 本帧处理的代理数
764
- * @en Agents processed this frame
578
+ * @zh 推进路径点
579
+ * @en Advance waypoint
765
580
  */
766
- agentsProcessedThisFrame: number;
581
+ private advanceWaypoint;
767
582
  /**
768
- * @zh 本帧 ORCA 计算耗时(毫秒)
769
- * @en ORCA computation time this frame (ms)
583
+ * @zh 计算首选速度
584
+ * @en Calculate preferred velocity
770
585
  */
771
- computeTimeMs: number;
586
+ private calculatePreferredVelocity;
772
587
  /**
773
- * @zh 获取 ORCA 配置
774
- * @en Get ORCA configuration
588
+ * @zh 构建代理数据
589
+ * @en Build agent data
775
590
  */
776
- getConfig(): IORCASolverConfig;
591
+ private buildAgentData;
777
592
  /**
778
- * @zh 添加静态障碍物
779
- * @en Add static obstacle
780
- *
781
- * @param obstacle - @zh 障碍物(顶点列表,逆时针顺序)@en Obstacle (vertex list, counter-clockwise)
593
+ * @zh 应用避让结果
594
+ * @en Apply avoidance result
782
595
  */
783
- addObstacle(obstacle: IObstacle): void;
596
+ private applyAvoidanceResult;
784
597
  /**
785
- * @zh 添加矩形障碍物
786
- * @en Add rectangular obstacle
787
- *
788
- * @param x - @zh 左下角 X @en Bottom-left X
789
- * @param y - @zh 左下角 Y @en Bottom-left Y
790
- * @param width - @zh 宽度 @en Width
791
- * @param height - @zh 高度 @en Height
598
+ * @zh 应用平滑转向
599
+ * @en Apply smooth steering
792
600
  */
793
- addRectObstacle(x: number, y: number, width: number, height: number): void;
601
+ private applySmoothSteering;
794
602
  /**
795
- * @zh 移除所有障碍物
796
- * @en Remove all obstacles
603
+ * @zh 检查是否到达目标
604
+ * @en Check if arrived at destination
797
605
  */
798
- clearObstacles(): void;
606
+ private checkArrival;
799
607
  /**
800
- * @zh 重置统计信息
801
- * @en Reset statistics
608
+ * @zh 解决代理间碰撞
609
+ * @en Resolve agent-agent collisions
802
610
  */
803
- resetStats(): void;
804
- /**
805
- * @zh 组件从实体移除时调用
806
- * @en Called when component is removed from entity
807
- */
808
- onRemovedFromEntity(): void;
611
+ private resolveAgentCollisions;
809
612
  }
810
613
 
811
614
  /**
812
- * @zh 局部避让系统
813
- * @en Local Avoidance System
615
+ * @zh ORCA 算法配置组件
616
+ * @en ORCA Algorithm Configuration Component
617
+ *
618
+ * @zh 可选组件,仅当使用 ORCA 避让算法时需要,用于覆盖默认 ORCA 参数
619
+ * @en Optional component, only needed when using ORCA avoidance, to override default ORCA parameters
814
620
  */
815
621
 
816
622
  /**
817
- * @zh 局部避让系统
818
- * @en Local Avoidance System
623
+ * @zh ORCA 算法配置组件
624
+ * @en ORCA algorithm configuration component
819
625
  *
820
- * @zh 使用 ORCA 算法计算代理的避让速度
821
- * @en Uses ORCA algorithm to compute avoidance velocities for agents
626
+ * @zh 可选组件,附加到代理实体上以覆盖默认 ORCA 参数
627
+ * @en Optional component, attach to agent entities to override default ORCA parameters
822
628
  *
823
629
  * @example
824
630
  * ```typescript
825
- * // 添加系统到场景
826
- * scene.addSystem(new LocalAvoidanceSystem());
827
- *
828
- * // 创建避让世界(可选,用于静态障碍物)
829
- * const worldEntity = scene.createEntity('AvoidanceWorld');
830
- * worldEntity.addComponent(new AvoidanceWorldComponent());
831
- *
832
- * // 创建代理
833
- * const agent = scene.createEntity('Agent');
834
- * const avoidance = agent.addComponent(new AvoidanceAgentComponent());
835
- *
836
- * // 可选:同时添加寻路代理,系统会自动同步位置
837
- * agent.addComponent(new PathfindingAgentComponent());
631
+ * const entity = scene.createEntity('Agent');
838
632
  *
839
- * // 每帧设置首选速度(朝向目标)
840
- * avoidance.setPreferredVelocityTowards(targetX, targetY);
633
+ * // 添加导航代理
634
+ * entity.addComponent(new NavigationAgentComponent());
841
635
  *
842
- * // 系统计算后,newVelocity 会被更新
843
- * // 如果 autoApplyVelocity = true,velocity 也会自动更新
636
+ * // 可选:添加 ORCA 配置以自定义参数
637
+ * const orcaConfig = entity.addComponent(new ORCAConfigComponent());
638
+ * orcaConfig.timeHorizon = 3.0; // 更长的预测时间
639
+ * orcaConfig.neighborDist = 20.0; // 更大的邻居检测范围
844
640
  * ```
845
641
  */
846
- declare class LocalAvoidanceSystem extends EntitySystem {
847
- private worldEntity;
848
- private worldComponent;
849
- private solver;
850
- private kdTree;
851
- constructor();
852
- /**
853
- * @zh 系统初始化
854
- * @en System initialization
855
- */
856
- protected onInitialize(): void;
857
- /**
858
- * @zh 系统激活时调用
859
- * @en Called when system is enabled
860
- */
861
- protected onEnable(): void;
642
+ declare class ORCAConfigComponent extends Component {
862
643
  /**
863
- * @zh 处理实体
864
- * @en Process entities
644
+ * @zh 邻居检测距离
645
+ * @en Neighbor detection distance
646
+ *
647
+ * @zh 代理检测邻居的最大距离,更大的值意味着更早开始避让但也更消耗性能
648
+ * @en Maximum distance for detecting neighbors, larger value means earlier avoidance but more performance cost
865
649
  */
866
- protected process(entities: readonly Entity[]): void;
650
+ neighborDist: number;
867
651
  /**
868
- * @zh 查找世界实体
869
- * @en Find world entity
652
+ * @zh 最大邻居数量
653
+ * @en Maximum number of neighbors
654
+ *
655
+ * @zh 计算避让时考虑的最大邻居数量,更多邻居意味着更精确但也更消耗性能
656
+ * @en Maximum neighbors considered for avoidance, more neighbors means more accurate but slower
870
657
  */
871
- private findWorldEntity;
658
+ maxNeighbors: number;
872
659
  /**
873
- * @zh 初始化求解器
874
- * @en Initialize solver
660
+ * @zh 代理避让时间视野
661
+ * @en Time horizon for agent avoidance
662
+ *
663
+ * @zh 预测其他代理未来位置的时间范围,更长意味着更平滑但可能过度避让
664
+ * @en Time range for predicting other agents' future positions, longer means smoother but may over-avoid
875
665
  */
876
- private initializeSolver;
666
+ timeHorizon: number;
877
667
  /**
878
- * @zh 收集代理数据
879
- * @en Collect agent data
668
+ * @zh 障碍物避让时间视野
669
+ * @en Time horizon for obstacle avoidance
670
+ *
671
+ * @zh 预测与障碍物碰撞的时间范围,通常比代理视野短
672
+ * @en Time range for predicting obstacle collisions, usually shorter than agent horizon
880
673
  */
881
- private collectAgentData;
674
+ timeHorizonObst: number;
882
675
  }
883
676
 
884
- export { AvoidanceAgentComponent, AvoidanceWorldComponent, LocalAvoidanceSystem, PathfindingAgentComponent, PathfindingMapComponent, type PathfindingMapType, PathfindingSystem };
677
+ export { IFlowController, type INavigationSystemConfig, NavigationAgentComponent, NavigationState, NavigationSystem, ORCAConfigComponent };