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

/**
 * Records office — payoff room after the valve puzzle.
 *
 * Dr. Hale waits here with the brass key to the break-room wing.
 */
export const STUDY: RoomDef = {
  id: "manor-study",
  displayName: "Ashgrove Precinct — Records",
  fog: { color: 0x0c1014, near: 3.5, far: 18 },
  ambientLight: { color: 0x3a4050, intensity: 1 },
  lights: [
    {
      kind: "point",
      color: 0xffc98a,
      intensity: 30,
      position: { x: -1, y: 2.5, z: -1 },
      distance: 14,
    },
    {
      kind: "point",
      color: 0x8090b0,
      intensity: 12,
      position: { x: 2, y: 2.2, z: 2 },
      distance: 10,
    },
  ],
  geometry: [
    floor("floor", { x: 0, y: 0, z: 0 }, 4.5, 4),
    wall("wall-s-left", { x: -2.7, y: WALL_HALF, z: 4.15 }, { x: 1.5, y: WALL_HALF, z: WALL_THICKNESS }),
    wall("wall-s-right", { x: 2.7, y: WALL_HALF, z: 4.15 }, { x: 1.5, y: WALL_HALF, z: WALL_THICKNESS }),
    wall("wall-n", { x: 0, y: WALL_HALF, z: -4.15 }, { x: 4.65, y: WALL_HALF, z: WALL_THICKNESS }, STONE),
    wall("wall-w", { x: -4.65, y: WALL_HALF, z: 0 }, { x: WALL_THICKNESS, y: WALL_HALF, z: 4 }, STONE),
    wall("wall-e", { x: 4.65, y: WALL_HALF, z: 0 }, { x: WALL_THICKNESS, y: WALL_HALF, z: 4 }, STONE),
    prop("desk", { x: -2.5, y: 0.4, z: 0 }, { x: 1.6, y: 0.8, z: 0.9 }, TIMBER),
    prop("bookshelf", { x: 3.5, y: 1.1, z: -2 }, { x: 0.5, y: 2.2, z: 2.4 }, 0x3a3228),
    prop("chair", { x: -2.5, y: 0.35, z: 1.2 }, { x: 0.5, y: 0.7, z: 0.5 }, 0x4a4034),
  ],
  cameraZones: [
    {
      id: "study",
      trigger: { center: { x: 0, y: 1.5, z: 0 }, halfExtents: { x: 4.5, y: 2, z: 4 } },
      camera: {
        position: { x: 3.6, y: 3.4, z: 3.2 },
        lookAt: { x: -1.5, y: 1, z: -1 },
        fov: 55,
        trackPlayer: true,
        trackRadius: 2.2,
      },
      blend: { mode: "blend", duration: 0.45 },
      priority: 0,
    },
  ],
  interactables: [
    {
      id: "photograph-pickup",
      label: "Torn Photograph",
      position: { x: -2.5, y: 0.95, z: 0 },
      halfExtents: { x: 1.3, y: 1.1, z: 1.1 },
      action: { kind: "pickup", itemId: "torn-photograph" },
      visual: { kind: "box", size: { x: 0.3, y: 0.02, z: 0.24 }, color: 0xd8cdb8 },
    },
    {
      id: "herb-pickup",
      label: "Green Herb",
      position: { x: 2.5, y: 0.3, z: -2.8 },
      halfExtents: { x: 1, y: 1.1, z: 1 },
      action: { kind: "pickup", itemId: "green-herb", quantity: 2 },
      visual: { kind: "box", size: { x: 0.25, y: 0.3, z: 0.25 }, color: 0x4a7f42 },
    },
    {
      id: "brass-key-pickup",
      label: "Brass Key",
      position: { x: 3.2, y: 0.5, z: -2 },
      halfExtents: { x: 1, y: 1.1, z: 1 },
      action: { kind: "pickup", itemId: "brass-key" },
      visual: { kind: "box", size: { x: 0.15, y: 0.05, z: 0.35 }, color: 0xc9a227 },
    },
    {
      id: "study-notes",
      label: "Research Notes",
      position: { x: -2.5, y: 0.95, z: -0.4 },
      halfExtents: { x: 1.1, y: 1, z: 1 },
      action: {
        kind: "examine",
        text: '"Subject still responds to the vault air. Do not open evidence alone. Kane\'s clay sample matches the stair risers." The handwriting trails into a smear.',
      },
      repeatable: true,
      visual: { kind: "box", size: { x: 0.35, y: 0.02, z: 0.28 }, color: 0xe8dcc8 },
    },
    {
      id: "talk-hale",
      label: "Dr. Hale",
      position: { x: -3.0, y: 0.7, z: -2.2 },
      halfExtents: { x: 1.2, y: 1.1, z: 1.2 },
      action: {
        kind: "examine",
        text:
          'Dr. Hale keeps one glove on. "The sample from the vault reacts to the manor\'s lower air — not poison, not mould. Something that writes itself into the floorplan. The brass key on my desk opens the break-room wing. Don\'t go alone."',
      },
      repeatable: true,
      visual: { kind: "none" },
    },
    door({
      id: "door-study-to-corridor",
      label: "Corridor",
      position: { x: 0, y: 1.1, z: 4 },
      targetRoomId: "manor-corridor",
      spawnPointId: "from-study",
    }),
  ],
  spawnPoints: [
    { id: "from-corridor", position: { x: 0, y: 0, z: 2.5 }, yaw: Math.PI },
  ],
};
