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,22 +3,12 @@
*/
import { createStateMachine } from '@esengine/fsm';
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';
type PlayerState = 'idle' | 'walk' | 'run' | 'jump';
export async function runFSMDemo(): Promise<void> {
console.log('═══════════════════════════════════════');
console.log(' FSM Module Demo');
console.log('═══════════════════════════════════════');
demoHeader('FSM Module Demo');
// 1. Basic Creation
section('1. createStateMachine()');
@@ -167,9 +157,7 @@ export async function runFSMDemo(): Promise<void> {
const history = fsmHist.getHistory();
assert(history.length >= 2, 'History recorded');
console.log('\n═══════════════════════════════════════');
console.log(' FSM Demo: ALL TESTS PASSED ✓');
console.log('═══════════════════════════════════════\n');
demoFooter('FSM Demo');
}
runFSMDemo().catch(console.error);