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

/**
 * Evidence vault — Level 1 crime-scene payoff.
 *
 * Darker fog, Sgt. Marrow's body, and a journal that closes the demo loop.
 */
export const CELLAR: RoomDef = {
  id: "manor-cellar",
  displayName: "Ashgrove Precinct — Evidence Vault",
  fog: { color: 0x050608, near: 2, far: 12 },
  ambientLight: { color: 0x202830, intensity: 0.55 },
  lights: [
    {
      kind: "point",
      color: 0xff9040,
      intensity: 18,
      position: { x: 0.5, y: 2, z: 1 },
      distance: 10,
    },
  ],
  geometry: [
    floor("floor", { x: 0, y: 0, z: 0 }, 4, 4),
    wall("wall-n", { x: 0, y: WALL_HALF, z: -4.15 }, { x: 4.2, y: WALL_HALF, z: WALL_THICKNESS }, STONE),
    wall("wall-s", { x: 0, y: WALL_HALF, z: 4.15 }, { x: 4.2, y: WALL_HALF, z: WALL_THICKNESS }, STONE),
    wall("wall-e", { x: 4.15, y: WALL_HALF, z: 0 }, { x: WALL_THICKNESS, y: WALL_HALF, z: 4 }, STONE),
    wall("wall-w-left", { x: -4.15, y: WALL_HALF, z: -2 }, { x: WALL_THICKNESS, y: WALL_HALF, z: 2 }, STONE),
    wall("wall-w-right", { x: -4.15, y: WALL_HALF, z: 2.2 }, { x: WALL_THICKNESS, y: WALL_HALF, z: 1.8 }, STONE),
    prop("barrel-1", { x: 2.5, y: 0.5, z: -2.2 }, { x: 0.7, y: 1, z: 0.7 }, 0x4a3c2e),
    prop("barrel-2", { x: 3.1, y: 0.5, z: -1.4 }, { x: 0.65, y: 1, z: 0.65 }, 0x3e3428),
    prop("crate-stack", { x: -2.5, y: 0.5, z: -2.5 }, { x: 1.2, y: 1, z: 1 }, 0x55504a),
    prop("shelf", { x: 3.2, y: 1, z: 2 }, { x: 0.4, y: 2, z: 2 }, 0x3a3228),
  ],
  cameraZones: [
    {
      id: "cellar",
      trigger: { center: { x: 0, y: 1.5, z: 0 }, halfExtents: { x: 4, y: 2, z: 4 } },
      camera: {
        position: { x: -2.8, y: 2.8, z: 3.4 },
        lookAt: { x: 1, y: 0.8, z: -1 },
        fov: 58,
        trackPlayer: true,
        trackRadius: 1.5,
      },
      blend: { mode: "blend", duration: 0.5 },
      priority: 0,
    },
  ],
  interactables: [
    {
      id: "officer-journal",
      label: "Officer's Journal",
      position: { x: 1.2, y: 0.4, z: -1.5 },
      halfExtents: { x: 1.2, y: 1.1, z: 1.2 },
      action: {
        kind: "examine",
        text:
          '"Day 4. The precinct is eating the map. Squad hall to corridor still holds. Vault does not. Kane was down here — clay on his shoes. If you find this — leave the brass key where it is and burn the rest." The rest of the page is wet.',
      },
      repeatable: true,
      visual: { kind: "box", size: { x: 0.28, y: 0.04, z: 0.35 }, color: 0x5a4030 },
    },
    {
      id: "cellar-herb",
      label: "Green Herb",
      position: { x: -2.5, y: 0.3, z: 2.5 },
      halfExtents: { x: 1, y: 1, z: 1 },
      action: { kind: "pickup", itemId: "green-herb", quantity: 1 },
      visual: { kind: "box", size: { x: 0.22, y: 0.28, z: 0.22 }, color: 0x4a7f42 },
    },
    {
      id: "bloody-badge",
      label: "Badge Case",
      position: { x: 0.5, y: 0.3, z: -2.0 },
      halfExtents: { x: 1.0, y: 1.0, z: 1.0 },
      action: { kind: "pickup", itemId: "badge-case" },
      visual: { kind: "box", size: { x: 0.18, y: 0.04, z: 0.28 }, color: 0x2a2a30 },
    },
    {
      id: "examine-officer",
      label: "Sgt. Marrow",
      position: { x: 2.2, y: 0.7, z: -2.4 },
      halfExtents: { x: 1.2, y: 1.1, z: 1.2 },
      action: {
        kind: "examine",
        text:
          "Uniform. Badge. Journal still in his hand. The only person who made it into evidence vault alone — and the only one who never left. His last note points back at Kane's coffee story.",
      },
      repeatable: true,
      visual: { kind: "none" },
    },
    door({
      id: "door-cellar-to-kitchen",
      label: "Stairs Up",
      position: { x: -4, y: 1.1, z: 0 },
      targetRoomId: "manor-kitchen",
      spawnPointId: "from-cellar",
    }),
  ],
  spawnPoints: [
    { id: "from-kitchen", position: { x: -2.5, y: 0, z: 0 }, yaw: -Math.PI / 2 },
  ],
};
