fix(spatial): 修复 GridAOI 可见性更新问题

- 修复 addObserver 时现有观察者无法检测到新实体的问题
- 修复实体远距离移动时观察者可见性未正确更新的问题
- 重构 demos 抽取公共测试工具
This commit is contained in:
yhh
2025-12-26 22:23:03 +08:00
parent 881ffad3bc
commit d66c18041e
9 changed files with 103 additions and 118 deletions

View File

@@ -10,20 +10,10 @@ import {
manhattanDistance,
octileDistance
} from '@esengine/pathfinding';
function assert(condition: boolean, message: string): void {
if (!condition) throw new Error(`FAILED: ${message}`);
console.log(`${message}`);
}
function section(name: string): void {
console.log(`\n▶ ${name}`);
}
import { assert, section, demoHeader, demoFooter } from './utils.js';
export async function runPathfindingDemo(): Promise<void> {
console.log('═══════════════════════════════════════');
console.log(' Pathfinding Module Demo');
console.log('═══════════════════════════════════════');
demoHeader('Pathfinding Module Demo');
// 1. Create Grid Map
section('1. createGridMap()');
@@ -156,9 +146,7 @@ export async function runPathfindingDemo(): Promise<void> {
grid.reset();
assert(grid.isWalkable(5, 5), 'Grid reset - all walkable');
console.log('\n═══════════════════════════════════════');
console.log(' Pathfinding Demo: ALL TESTS PASSED ✓');
console.log('═══════════════════════════════════════\n');
demoFooter('Pathfinding Demo');
}
runPathfindingDemo().catch(console.error);