feat: wire spawn hotkey and command panel visibility in GameScene

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
root
2026-03-07 13:40:16 +00:00
parent 526bb83d0b
commit c8a86eec3f
+21 -3
View File
@@ -3,6 +3,7 @@ import type { SocketClient } from '../network/SocketClient.js';
import { CharacterCompositor } from '../sprites/CharacterCompositor.js';
import { PortraitCompositor } from '../sprites/PortraitCompositor.js';
import { NpcInfoPanel } from '../ui/NpcInfoPanel.js';
import { CommandPanel } from '../ui/CommandPanel.js';
import { InteractionEmojiManager } from '../ui/InteractionEmoji.js';
import type { WorldState, StateUpdate, EntityState, Appearance } from '@dflike/shared';
import { TILE_SIZE, SPRITE_FRAME_WIDTH, SPRITE_FRAME_HEIGHT, SPRITE_COLS, Direction } from '@dflike/shared';
@@ -28,6 +29,7 @@ export class GameScene extends Phaser.Scene {
private portraitCompositor!: PortraitCompositor;
private npcInfoPanel!: NpcInfoPanel;
private emojiManager!: InteractionEmojiManager;
private commandPanel!: CommandPanel;
constructor() {
super({ key: 'GameScene' });
@@ -43,6 +45,8 @@ export class GameScene extends Phaser.Scene {
this.portraitCompositor = new PortraitCompositor();
this.npcInfoPanel = new NpcInfoPanel();
this.emojiManager = new InteractionEmojiManager();
this.commandPanel = new CommandPanel();
this.commandPanel.show(); // Start in camera mode, so show immediately
// Draw tile grid
this.drawWorld();
@@ -65,21 +69,35 @@ export class GameScene extends Phaser.Scene {
this.input.keyboard!.addKey('TAB').on('down', () => {
const prevMode = this.mode;
if (this.mode === 'camera') {
this.mode = 'avatar';
} else if (this.mode === 'avatar') {
this.mode = 'follow';
} else {
this.mode = 'camera';
}
this.client.sendInput({ type: 'toggle-mode' });
this.updateModeText();
// Panel visibility
if (this.mode === 'follow') {
this.showFollowPanel();
this.commandPanel.hide();
} else if (prevMode === 'follow') {
this.npcInfoPanel.hide();
}
// Command panel visibility
if (this.mode === 'camera') {
this.commandPanel.show();
} else {
this.commandPanel.hide();
}
});
// Spawn NPC command (camera mode only)
this.input.keyboard!.addKey('ONE').on('down', () => {
if (this.mode !== 'camera') return;
const cam = this.cameras.main;
const centerTileX = Math.floor((cam.scrollX + cam.width / 2) / TILE_SIZE);
const centerTileY = Math.floor((cam.scrollY + cam.height / 2) / TILE_SIZE);
this.client.spawnNpc(centerTileX, centerTileY);
});
// UI text