import type { RoomDef } from "@psx/shared";
import { door, floor, prop, STONE, TIMBER, wall, WALL_HALF, WALL_THICKNESS } from "./helpers.js";

/**
 * Break room — opened with the brass key from Records.
 *
 * Cellar key and ammo live here; door to the evidence vault is locked until
 * that key is held.
 */
export const KITCHEN: RoomDef = {
  id: "manor-kitchen",
  displayName: "Ashgrove Precinct — Break Room",
  fog: { color: 0x0e100c, near: 3, far: 16 },
  ambientLight: { color: 0x404838, intensity: 0.9 },
  lights: [
    {
      kind: "point",
      color: 0xffb070,
      intensity: 26,
      position: { x: 0, y: 2.4, z: 0 },
      distance: 12,
    },
  ],
  geometry: [
    floor("floor", { x: 0, y: 0, z: 0 }, 4, 3.5),
    wall("wall-n", { x: 0, y: WALL_HALF, z: -3.65 }, { x: 4.2, y: WALL_HALF, z: WALL_THICKNESS }, STONE),
    wall("wall-s-left", { x: -2.4, y: WALL_HALF, z: 3.65 }, { x: 1.4, y: WALL_HALF, z: WALL_THICKNESS }),
    wall("wall-s-right", { x: 2.4, y: WALL_HALF, z: 3.65 }, { x: 1.4, y: WALL_HALF, z: WALL_THICKNESS }),
    wall("wall-e", { x: 4.15, y: WALL_HALF, z: 0 }, { x: WALL_THICKNESS, y: WALL_HALF, z: 3.5 }),
    wall("wall-w-left", { x: -4.15, y: WALL_HALF, z: 1.5 }, { x: WALL_THICKNESS, y: WALL_HALF, z: 2 }),
    wall("wall-w-right", { x: -4.15, y: WALL_HALF, z: -1.8 }, { x: WALL_THICKNESS, y: WALL_HALF, z: 1.5 }),
    prop("counter", { x: 2.5, y: 0.45, z: -1.5 }, { x: 2.2, y: 0.9, z: 0.7 }, TIMBER),
    prop("stove", { x: -2.2, y: 0.4, z: -2 }, { x: 1, y: 0.8, z: 0.8 }, 0x3a3a40),
    prop("table", { x: 0, y: 0.4, z: 1 }, { x: 1.4, y: 0.8, z: 0.9 }, 0x5a4a38),
  ],
  cameraZones: [
    {
      id: "kitchen",
      trigger: { center: { x: 0, y: 1.5, z: 0 }, halfExtents: { x: 4, y: 2, z: 3.5 } },
      camera: {
        position: { x: 3.2, y: 3.1, z: 3 },
        lookAt: { x: -0.5, y: 1, z: -1 },
        fov: 58,
        trackPlayer: true,
        trackRadius: 1.6,
      },
      blend: { mode: "cut" },
      priority: 0,
    },
  ],
  interactables: [
    {
      id: "cellar-key-pickup",
      label: "Cellar Key",
      position: { x: 2.5, y: 1, z: -1.5 },
      halfExtents: { x: 1.1, y: 1.1, z: 1 },
      action: { kind: "pickup", itemId: "cellar-key" },
      visual: { kind: "box", size: { x: 0.12, y: 0.04, z: 0.3 }, color: 0x8a8070 },
    },
    {
      id: "ammo-pickup",
      label: "Handgun Rounds",
      position: { x: -2.2, y: 0.95, z: -2 },
      halfExtents: { x: 1, y: 1.1, z: 1 },
      action: { kind: "pickup", itemId: "handgun-rounds", quantity: 12 },
      visual: { kind: "box", size: { x: 0.2, y: 0.12, z: 0.15 }, color: 0xc9a227 },
    },
    {
      id: "kitchen-sink",
      label: "Sink",
      position: { x: 2.5, y: 1, z: -1.2 },
      halfExtents: { x: 1, y: 1, z: 0.8 },
      action: {
        kind: "examine",
        text: "Rust-stained porcelain. The tap still drips, one beat every few seconds. Red clay rings the drain — same clay as the vault stairs.",
      },
      repeatable: true,
      visual: { kind: "none" },
    },
    door({
      id: "door-kitchen-to-gallery",
      label: "Squad Hall",
      position: { x: 0, y: 1.1, z: 3.5 },
      targetRoomId: "manor-gallery",
      spawnPointId: "from-kitchen",
    }),
    door({
      id: "door-kitchen-to-cellar",
      label: "Evidence Vault",
      position: { x: -4, y: 1.1, z: 0 },
      targetRoomId: "manor-cellar",
      spawnPointId: "from-kitchen",
      requiresItemId: "cellar-key",
    }),
  ],
  spawnPoints: [
    { id: "from-gallery", position: { x: 0, y: 0, z: 2 }, yaw: Math.PI },
    { id: "from-cellar", position: { x: -2.5, y: 0, z: 0 }, yaw: Math.PI / 2 },
  ],
};
