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

@@ -3,20 +3,10 @@
*/
import { createTimerService } from '@esengine/timer';
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 runTimerDemo(): Promise<void> {
console.log('═══════════════════════════════════════');
console.log(' Timer Module Demo');
console.log('═══════════════════════════════════════');
demoHeader('Timer Module Demo');
// 1. Basic Creation
section('1. createTimerService()');
@@ -111,9 +101,7 @@ export async function runTimerDemo(): Promise<void> {
const limited = createTimerService({ maxTimers: 2, maxCooldowns: 1 });
assert(limited !== null, 'Created with config');
console.log('\n═══════════════════════════════════════');
console.log(' Timer Demo: ALL TESTS PASSED ✓');
console.log('═══════════════════════════════════════\n');
demoFooter('Timer Demo');
}
runTimerDemo().catch(console.error);