feat: module interaction system with wiring panel

Add a new "module" interaction type where doors/devices define ports
(in/out) and a JS verify function. Players wire their gadget's I/O
to the module's ports via a canvas-rendered wiring panel, then execute
to verify the circuit logic.

- New wiringPanel.js: full wiring UI with keyboard nav, bezier wires,
  mini circuit evaluator, and verify execution
- AND-gate example door in Circuit Lab (tile 9,1)
- Editor support: module type with ports editor and JS verify textarea
- Integrated into gameMode, worldInput, worldRenderer

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jose Luis
2026-03-20 17:59:25 +01:00
parent 6ba3fa457a
commit f9492bff4c
6 changed files with 671 additions and 4 deletions

View File

@@ -3,6 +3,7 @@ import { worldState, advanceDialog, startDialog } from './worldState.js';
import { getMap, getInteraction, getNPC, getExit, isWalkable } from './maps.js';
import { toggleDebug } from './worldRenderer.js';
import { isBackpackOpen, openBackpack, handleBackpackInput, isNamingActive, handleNamingInput } from './inventory.js';
import { isWiringOpen, handleWiringInput } from './wiringPanel.js';
const keysDown = new Set();
let interactionHandler = null;
@@ -33,6 +34,13 @@ function onKeyDown(e) {
return;
}
// Wiring panel — route all input there
if (isWiringOpen()) {
e.preventDefault();
handleWiringInput(key);
return;
}
// Backpack open — route all input there
if (isBackpackOpen()) {
e.preventDefault();
@@ -201,6 +209,9 @@ function performInteraction() {
case 'puzzle_door':
if (interactionHandler) interactionHandler({ type: 'puzzleDoor', data: inter });
break;
case 'module':
if (interactionHandler) interactionHandler({ type: 'module', data: inter });
break;
default:
if (inter.dialog) startDialog(inter.dialog, '');
break;