fix: filter player entities from follow mode, remove redundant updateNeeds, show NPC name in mode text

- getNpcIds() now excludes player-controlled entities
- Remove double updateNeeds call in handleStateUpdate (updateInfo already calls it)
- Mode text shows NPC name instead of just ID

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
root
2026-03-07 04:43:40 +00:00
parent 03849c9505
commit 4374914b29
+6 -5
View File
@@ -243,9 +243,6 @@ export class GameScene extends Phaser.Scene {
const followed = this.entitySprites.get(followedId);
if (followed) {
this.npcInfoPanel.updateInfo(followed.lastState);
if (followed.lastState.needs) {
this.npcInfoPanel.updateNeeds(followed.lastState.needs);
}
}
}
}
@@ -354,14 +351,18 @@ export class GameScene extends Phaser.Scene {
}
private getNpcIds(): number[] {
return [...this.entitySprites.keys()].sort((a, b) => a - b);
return [...this.entitySprites.entries()]
.filter(([, es]) => !es.lastState.playerControlled)
.map(([id]) => id)
.sort((a, b) => a - b);
}
private updateModeText(): void {
if (this.mode === 'follow') {
const npcIds = this.getNpcIds();
const targetId = npcIds[this.followTargetIndex];
const label = targetId != null ? `NPC #${targetId}` : 'none';
const es = targetId != null ? this.entitySprites.get(targetId) : undefined;
const label = es?.lastState.name ?? (targetId != null ? `NPC #${targetId}` : 'none');
this.modeText.setText(`Mode: FOLLOW: ${label} [TAB to toggle]`);
} else {
this.modeText.setText(`Mode: ${this.mode.toUpperCase()} [TAB to toggle]`);