Skip to content

an open-source alternative to the dots, bots and muses of the world, run an office of claude code/codex like agents on your laptop, sandboxes or anywhere, uses your existing subscriptions

feat(office): extract ThemeConfig theme abstraction (TV-show offices Phase 0)

Chaitanya Girie8228e9e099f
diff --git a/src/renderer/src/scene/office/DeskScreen.ts b/src/renderer/src/scene/office/DeskScreen.ts
index d6b4b150..d017719f 100644
--- a/src/renderer/src/scene/office/DeskScreen.ts
+++ b/src/renderer/src/scene/office/DeskScreen.ts
@@ -1,5 +1,6 @@
import { Container, Graphics, Sprite } from 'pixi.js';
import type { TiledMapRenderer } from './TiledMapRenderer';
+import type { MonitorConfig } from './themeRegistry';
// The office tileset ships every desk PC twice: a dark, switched-off monitor
// (gids 365/366 + 381/382 — what the map paints) and the SAME monitor with a
@@ -8,10 +9,12 @@ import type { TiledMapRenderer } from './TiledMapRenderer';
// animation (scrolling lines + a blinking cursor) so the PC visibly works when
// its owner does. Hidden, the map's off art shows through — no state to undo.
-/** gid of the OFF monitor block's top-left tile, as painted in the map. */
+/** gid of the OFF monitor block's top-left tile, as painted in the office map.
+ * Default for the office theme; a theme supplies its own via MonitorConfig. */
export const MONITOR_OFF_TOPLEFT_GID = 365;
-/** Matching ON tiles, laid out 2×2 directly right of the off block. */
-const ON_GIDS: ReadonlyArray<readonly [number, number, number]> = [
+/** Matching ON tiles for the office theme, laid out 2×2 directly right of the
+ * off block — used when no per-theme MonitorConfig is passed. */
+const DEFAULT_ON_GIDS: ReadonlyArray<readonly [number, number, number]> = [
// [gid, dx, dy] in tiles relative to the block's top-left
[367, 0, 0], [368, 1, 0],
[383, 0, 1], [384, 1, 1]
@@ -27,9 +30,10 @@ export class DeskScreen {
private on = false;
private t = 0;
- constructor(mapRenderer: TiledMapRenderer, topLeft: { x: number; y: number }) {
+ constructor(mapRenderer: TiledMapRenderer, topLeft: { x: number; y: number }, monitor?: MonitorConfig) {
const ts = mapRenderer.tileSize;
- for (const [gid, dx, dy] of ON_GIDS) {
+ const onGids = monitor?.onGids ?? DEFAULT_ON_GIDS;
+ for (const [gid, dx, dy] of onGids) {
const tex = mapRenderer.textureForGid(gid);
if (!tex) continue;
const s = new Sprite(tex);
diff --git a/src/renderer/src/scene/office/OfficeFloor.tsx b/src/renderer/src/scene/office/OfficeFloor.tsx
index b796482b..acd287d1 100644
--- a/src/renderer/src/scene/office/OfficeFloor.tsx
+++ b/src/renderer/src/scene/office/OfficeFloor.tsx
@@ -3,37 +3,21 @@ import { Application, Container, Graphics, Ticker, Texture } from 'pixi.js';
// PixiJS uses new Function() internally, blocked by Electron CSP — this patches it.
import 'pixi.js/unsafe-eval';
import { useStore, type Agent } from '@/store/store';
-import { TiledMapRenderer, type TiledMap } from './TiledMapRenderer';
+import { TiledMapRenderer } from './TiledMapRenderer';
import { Camera } from './Camera';
import { Character, paintCup } from './Character';
-import { DeskScreen, MONITOR_OFF_TOPLEFT_GID } from './DeskScreen';
+import { DeskScreen } from './DeskScreen';
import { MessageEnvelope, type MessageAct } from './MessageEnvelope';
-import { getCastFrames, CAST_BY_NAME, hexToNumber, DEFAULT_CHARACTER } from './cast';
+import { hexToNumber, DEFAULT_CHARACTER } from './cast';
import { pickSoloLine, pickExchange, type BreakSpot } from './cafeteriaLines';
import { colors } from '@/design/tokens';
+import { loadTheme, resolveThemeMap, themeTilesetUrls } from './themeLoader';
+import type { Tile, Facing, ErrandKind, ErrandSpot } from './themeRegistry';
-import officeTilesetUrl from '@/assets/tilesets/office-tileset.png?url';
-import a5FloorsWallsUrl from '@/assets/tilesets/a5-office-floors-walls.png?url';
-import interiorsUrl from '@/assets/tilesets/interiors.png?url';
-// .tmj is Tiled JSON; import as raw text (typed by vite/client) and parse.
-import officeMapRaw from '@/assets/maps/office.tmj?raw';
-
-const officeMapData = JSON.parse(officeMapRaw) as TiledMap;
-
-// Preferred desks, in claim order. The very first agent always takes the
-// private office on the left (the CEO room), then the open-plan PC desks, then
-// the remaining named desks. Overflow (conference room, then open floor) is
-// computed from map zones at runtime. Matches Tiled spawn-point names.
-const PRIMARY_SEAT_NAMES = [
- 'desk-ceo',
- 'pc-1', 'pc-2', 'pc-3', 'pc-4', 'pc-5', 'pc-6',
- 'desk-chief-architect', 'desk-product-manager', 'desk-team-lead',
- 'desk-backend-engineer', 'desk-ui-ux-expert', 'desk-data-engineer',
- 'desk-project-manager', 'desk-market-researcher', 'desk-agent-organizer',
-];
-
-interface Tile { x: number; y: number; }
-type Facing = 'up' | 'down' | 'left' | 'right';
+// The map, tileset atlases, desk-claim order, errand spots, coffee-economy
+// tiles, prop anchors, monitor gids and palette all come from the active
+// ThemeConfig now (see themeRegistry.ts / themeLoader.ts). Phase 0 ships the
+// existing office unchanged as `theme: 'office'`.
/** A cafeteria break in progress for one agent — set by the coffee-break
* director, cleared when the agent leaves or gets pulled back to work. */
@@ -53,10 +37,6 @@ interface CafeBreak {
chattingWith?: string; // set on the partner: stays put & stays quiet
}
-/** Kinds of small idle errands around the office (incl. plant watering).
- * 'smoke' is the boss special: cigar at the open window, Michael only. */
-type ErrandKind = 'water' | 'window' | 'dispenser' | 'fridge' | 'shelf' | 'bin' | 'smoke';
-
/** An idle errand in progress for one agent. */
interface ErrandRun {
phase: 'walking' | 'doing';
@@ -138,20 +118,6 @@ const CHEER_LINES = [
'crushed it', 'in the books'
] as const;
-/** Patch the map's external (.tsx) tileset refs with the inline metadata the
- * renderer needs — mirrors the reference repo's OfficeScene.init(). */
-function resolveMap(): TiledMap {
- const m = officeMapData;
- return {
- ...m,
- tilesets: [
- m.tilesets[0], // office-tileset.png (embedded, firstgid 1)
- { firstgid: 513, image: 'a5', imagewidth: 256, imageheight: 512, tilewidth: 16, tileheight: 16, columns: 16, tilecount: 512 } as any,
- { firstgid: 1025, image: 'interiors', imagewidth: 256, imageheight: 1424, tilewidth: 16, tileheight: 16, columns: 16, tilecount: 1424 } as any,
- ],
- };
-}
-
/** Load a texture via an <img> element. Unlike Pixi's Assets.load(), this
* handles extension-less data: URLs (Vite inlines small assets like the a5
* tileset as base64), which the Assets resolver fails to type-detect. */
@@ -211,8 +177,10 @@ export function OfficeFloor() {
const MAX_ENVELOPES = 16;
const init = async () => {
+ // Active office theme (Phase 0 ships the existing office as `theme:'office'`).
+ const theme = await loadTheme('office');
await app.init({
- background: hexNum(colors.ink[900]),
+ background: hexNum(theme.palette.background),
antialias: false,
roundPixels: true,
// resolution: 1 let the OS/browser upscale the canvas on scaled and
@@ -230,16 +198,16 @@ export function OfficeFloor() {
while (host.firstChild) host.removeChild(host.firstChild);
host.appendChild(app.canvas);
- // Load tilesets (order must match resolveMap()'s tileset array)
- const [officeTex, a5Tex, interiorsTex] = await Promise.all(
- [officeTilesetUrl, a5FloorsWallsUrl, interiorsUrl].map(loadTexture),
+ // Load tilesets in theme order (texture[i] lines up with map tilesets[i]).
+ const tilesetTextures = await Promise.all(
+ themeTilesetUrls(theme).map(loadTexture),
);
if (mountIdRef.current !== mountId) { safeDestroy(app); return; }
const world = new Container();
app.stage.addChild(world);
- const mapRenderer = new TiledMapRenderer(resolveMap(), [officeTex, a5Tex, interiorsTex]);
+ const mapRenderer = new TiledMapRenderer(resolveThemeMap(theme), tilesetTextures);
world.addChild(mapRenderer.getContainer());
const charLayer = mapRenderer.getCharacterContainer();
const tileCount = mapRenderer.getContainer().children.reduce(
@@ -259,7 +227,7 @@ export function OfficeFloor() {
const calG = new Graphics();
calG.eventMode = 'static';
calG.cursor = 'pointer';
- calG.position.set(4 * calTs + 8, 1 * calTs + 5);
+ calG.position.set(theme.anchors.calendar.x * calTs + 8, theme.anchors.calendar.y * calTs + 5);
calG.zIndex = 3 * calTs;
calG.on('pointertap', (ev) => {
ev.stopPropagation();
@@ -295,7 +263,7 @@ export function OfficeFloor() {
seatSeen.add(k);
seatTiles.push({ x: t.x, y: t.y });
};
- for (const name of PRIMARY_SEAT_NAMES) addSeat(mapRenderer.getSpawnPoint(name));
+ for (const name of theme.primarySeatNames) addSeat(mapRenderer.getSpawnPoint(name));
const addZoneSeats = (zone: string) => {
const z = mapRenderer.getZone(zone);
if (!z) return;
@@ -370,7 +338,7 @@ export function OfficeFloor() {
};
// Seats first (so partner indices are stable), then the standing spots.
- for (const name of ['cafe-seat-1', 'cafe-seat-2', 'cafe-seat-3', 'cafe-seat-4']) {
+ for (const name of theme.cafeSeatNames) {
const p = mapRenderer.getSpawnPoint(name);
if (p) cafeSpots.push({ tile: p, facing: facingForSeat(p), spot: 'table', seated: true, partner: -1 });
}
@@ -381,7 +349,7 @@ export function OfficeFloor() {
if (a.x === b.x && Math.abs(a.y - b.y) === 2) { cafeSpots[i].partner = j; cafeSpots[j].partner = i; }
}
}
- for (const [name, spot] of [['cafe-stand-coffee', 'coffee'], ['cafe-stand-vending', 'vending']] as const) {
+ for (const [name, spot] of theme.cafeStands) {
const p = mapRenderer.getSpawnPoint(name);
if (p) cafeSpots.push({ tile: p, facing: faceFurniture(p), spot, seated: false, partner: -1 });
}
@@ -396,12 +364,12 @@ export function OfficeFloor() {
// brought back from the desk for a lazy refill); washing at the counter
// sink puts a mug back into the clean stock. If every mug is parked on a
// desk somewhere, the rack runs dry — and the floor feels it.
- const TRAY_TILE: Tile = { x: 29, y: 15 }; // the sideboard (counter piece)
- const TRAY_STAND: Tile = { x: 29, y: 16 };
- const MACHINE_STAND: Tile = { x: 26, y: 20 }; // below the counter machine
- const SINK_TILE: Tile = { x: 28, y: 18 }; // free counter top, right end
- const SINK_STAND: Tile = { x: 28, y: 20 };
- const MAX_CUPS = 4;
+ const TRAY_TILE: Tile = theme.coffee.trayTile; // the sideboard (counter piece)
+ const TRAY_STAND: Tile = theme.coffee.trayStand;
+ const MACHINE_STAND: Tile = theme.coffee.machineStand; // below the counter machine
+ const SINK_TILE: Tile = theme.coffee.sinkTile; // free counter top, right end
+ const SINK_STAND: Tile = theme.coffee.sinkStand;
+ const MAX_CUPS = theme.coffee.maxCups;
let cleanCups = MAX_CUPS;
const ts0 = mapRenderer.tileSize;
@@ -751,30 +719,7 @@ export function OfficeFloor() {
// Plants get watered, windows opened for a breeze, the dispenser poured,
// the fridge inspected, the shelf browsed, scrap paper binned. Every spot
// has a stand tile + facing; `fx` anchors a little ambient animation.
- interface ErrandSpot { kind: ErrandKind; stand: Tile; facing: Facing; fx: Tile; duration: number; godOnly?: boolean; }
- const ERRAND_SPOTS: ErrandSpot[] = [
- // plants (droplets ride on the character via startWatering)
- { kind: 'water', stand: { x: 2, y: 20 }, facing: 'left', fx: { x: 1, y: 20 }, duration: 4.5 },
- { kind: 'water', stand: { x: 22, y: 20 }, facing: 'right', fx: { x: 23, y: 20 }, duration: 4.5 },
- { kind: 'water', stand: { x: 30, y: 20 }, facing: 'right', fx: { x: 31, y: 20 }, duration: 4.5 },
- // the CEO office is MICHAEL'S domain: his plant, his window, his cigar.
- // Workers never set foot in there for errands.
- { kind: 'water', stand: { x: 6, y: 4 }, facing: 'up', fx: { x: 6, y: 3 }, duration: 4.5, godOnly: true },
- { kind: 'smoke', stand: { x: 2, y: 3 }, facing: 'up', fx: { x: 2, y: 1 }, duration: 18, godOnly: true },
- { kind: 'water', stand: { x: 17, y: 4 }, facing: 'up', fx: { x: 17, y: 3 }, duration: 4.5 },
- // the two public wall windows — wind streaks drift into the room
- { kind: 'window', stand: { x: 10, y: 3 }, facing: 'up', fx: { x: 10, y: 1 }, duration: 5 },
- { kind: 'window', stand: { x: 15, y: 3 }, facing: 'up', fx: { x: 14, y: 1 }, duration: 5 },
- // water dispensers (hallway + the top-right corner one)
- { kind: 'dispenser', stand: { x: 16, y: 3 }, facing: 'down', fx: { x: 16, y: 4 }, duration: 3.5 },
- { kind: 'dispenser', stand: { x: 32, y: 4 }, facing: 'up', fx: { x: 32, y: 3 }, duration: 3.5 },
- // the café fridge (door light spills out) + the shelf beside it
- { kind: 'fridge', stand: { x: 29, y: 20 }, facing: 'up', fx: { x: 29, y: 19 }, duration: 3.2 },
- { kind: 'shelf', stand: { x: 30, y: 20 }, facing: 'up', fx: { x: 30, y: 18 }, duration: 4 },
- // garbage bins (entrance + café) — a paper ball arcs in
- { kind: 'bin', stand: { x: 18, y: 20 }, facing: 'left', fx: { x: 17, y: 20 }, duration: 2.6 },
- { kind: 'bin', stand: { x: 31, y: 16 }, facing: 'right', fx: { x: 32, y: 16 }, duration: 2.6 }
- ];
+ const ERRAND_SPOTS: ErrandSpot[] = theme.errandSpots;
const errandTaken: (string | null)[] = new Array(ERRAND_SPOTS.length).fill(null);
// Lazily-created ambient fx layer per active errand spot.
const errandFx = new Map<number, Graphics>();
@@ -999,13 +944,11 @@ export function OfficeFloor() {
// sticks to that worker's desk instead. Finished tasks archive as a green
// stack on the little table at the end. Clicking any of it selects
// Michael and opens the Command Center's tasks tab.
- const BOARD_TILE: Tile = { x: 6, y: 10 };
+ const BOARD_TILE: Tile = theme.anchors.boards;
// The ensemble (two boards + archive table) is 82px wide; the wall run
// between the two doorways spans tiles 6..12 (112px) — center it.
const BOARD_CENTER_PAD = 15;
- const NOTE_COLORS: Record<string, number> = {
- todo: 0xf2df8a, doing: 0x9ecbf0, blocked: 0xf0a3a3, done: 0xa8e0b0
- };
+ const NOTE_COLORS: Record<string, number> = theme.palette.noteColors;
interface BoardTask { status: string; assignee?: string }
const tsB = mapRenderer.tileSize;
const boardG = new Graphics();
@@ -1102,7 +1045,7 @@ export function OfficeFloor() {
const clockG = new Graphics();
clockG.eventMode = 'static';
clockG.cursor = 'pointer';
- clockG.position.set(1 * ts0, 1 * ts0);
+ clockG.position.set(theme.anchors.clock.x * ts0, theme.anchors.clock.y * ts0);
clockG.hitArea = { contains: (x: number, y: number) => x >= 0 && x <= 16 && y >= 0 && y <= 32 };
clockG.zIndex = 3 * ts0;
clockG.on('pointertap', (ev) => {
@@ -1358,14 +1301,14 @@ export function OfficeFloor() {
(app as any).__taskBoardPoll = taskBoardPoll;
const addCharacter = async (agent: Agent) => {
- const charName = CAST_BY_NAME[agent.character] ? agent.character : DEFAULT_CHARACTER;
- const member = CAST_BY_NAME[charName];
+ const charName = theme.cast.byName[agent.character] ? agent.character : theme.cast.defaultCharacter;
+ const member = theme.cast.byName[charName];
const seatIndex = claimSeat(agent);
const seatTile: Tile = (seatIndex != null ? seatTiles[seatIndex] : undefined)
?? mapRenderer.getSpawnPoint('entrance')
?? { x: 2, y: 2 };
const waitTile = waitTiles[(seatIndex ?? 0) % waitTiles.length];
- const frames = await getCastFrames(charName);
+ const frames = await theme.cast.getFrames(charName);
// Bail if the agent was removed (or scene torn down) while loading.
if (mountIdRef.current !== mountId) return;
if (!useStore.getState().agents.some((a) => a.id === agent.id)) {
@@ -1389,9 +1332,9 @@ export function OfficeFloor() {
// beside the monitor, exactly where the tileset's baked-in mug used
// to sit before we cleared it (desks start clean now; cups only exist
// where an agent actually carried one).
- if (mapRenderer.gidAt('furniture-above', seatTile.x, seatTile.y - 2) === MONITOR_OFF_TOPLEFT_GID) {
+ if (mapRenderer.gidAt('furniture-above', seatTile.x, seatTile.y - 2) === theme.monitor.offTopLeftGid) {
const top = { x: seatTile.x, y: seatTile.y - 2 };
- rt.screen = new DeskScreen(mapRenderer, top);
+ rt.screen = new DeskScreen(mapRenderer, top, theme.monitor);
charLayer.addChild(rt.screen.container);
const ts2 = mapRenderer.tileSize;
character.setCupSpot({ x: top.x * ts2 + 18, y: top.y * ts2 + 23 });
diff --git a/src/renderer/src/scene/office/themeLoader.ts b/src/renderer/src/scene/office/themeLoader.ts
new file mode 100644
index 00000000..8dfe0ce5
--- /dev/null
+++ b/src/renderer/src/scene/office/themeLoader.ts
@@ -0,0 +1,65 @@
+// Theme loader — resolves a ThemeConfig into a ready-to-render map.
+//
+// Phase 0 keeps this thin: it parses the theme's Tiled JSON and patches the
+// appended tileset atlases with their inline metadata (the same patch the
+// office scene did inline as resolveMap()). The async `loadTheme` signature is
+// deliberate headroom for later phases, where a show bundle may be fetched and
+// validated before it's handed to the scene; on any failure it falls back to
+// the office theme so a bad/absent bundle never breaks the floor (report §E).
+
+import type { TiledMap } from './TiledMapRenderer';
+import {
+ getTheme,
+ OFFICE_THEME,
+ type ThemeConfig,
+ type ThemeId,
+} from './themeRegistry';
+
+/** Parse a theme's raw Tiled JSON and patch its tileset array.
+ * `embedded` atlases keep the map's own inline metadata; the rest are replaced
+ * by the theme's inline metadata (firstgid + image dimensions). The result's
+ * tileset order matches the texture-load order (texture[i] ↔ tilesets[i]). */
+export function resolveThemeMap(theme: ThemeConfig): TiledMap {
+ const m = JSON.parse(theme.mapRaw) as TiledMap;
+ return {
+ ...m,
+ tilesets: theme.tilesets.map((t, i) => {
+ if (t.embedded) return m.tilesets[i];
+ // Strip the renderer-only fields (url/embedded); the rest is Tiled metadata.
+ const { url: _url, embedded: _embedded, ...meta } = t;
+ return meta as TiledMap['tilesets'][number];
+ }),
+ };
+}
+
+/** The ordered tileset image URLs to load as textures, matching the map's
+ * tileset order (so texture[i] lines up with tilesets[i]). */
+export function themeTilesetUrls(theme: ThemeConfig): string[] {
+ return theme.tilesets.map((t) => t.url);
+}
+
+/** Light validation: the theme's map must parse and carry sane dimensions. */
+function isThemeRenderable(theme: ThemeConfig): boolean {
+ try {
+ const m = JSON.parse(theme.mapRaw) as TiledMap;
+ return (
+ typeof m.width === 'number' && m.width > 0 &&
+ typeof m.height === 'number' && m.height > 0 &&
+ Array.isArray(m.layers) && Array.isArray(m.tilesets)
+ );
+ } catch {
+ return false;
+ }
+}
+
+/** Resolve a theme id to a renderable ThemeConfig. Async by design (later
+ * phases may fetch a show bundle here); falls back to the office theme if the
+ * requested theme is missing or its map won't parse. */
+export async function loadTheme(id: ThemeId): Promise<ThemeConfig> {
+ const theme = getTheme(id);
+ if (!isThemeRenderable(theme)) {
+ console.warn(`[themeLoader] theme '${id}' is not renderable — falling back to 'office'`);
+ return OFFICE_THEME;
+ }
+ return theme;
+}
diff --git a/src/renderer/src/scene/office/themeRegistry.ts b/src/renderer/src/scene/office/themeRegistry.ts
new file mode 100644
index 00000000..f13b9316
--- /dev/null
+++ b/src/renderer/src/scene/office/themeRegistry.ts
@@ -0,0 +1,228 @@
+// Theme registry — the pluggable "office theme" contract.
+//
+// Phase 0 of the TV-show-offices feature (card tvshow-phase0-abstraction):
+// extract the ~40% of constants that were hard-coded inside OfficeFloor.tsx
+// (errand spots, coffee-economy tile coords, prop anchors, seat names, tileset
+// URLs, palette, monitor gids) into a ThemeConfig so the scene becomes
+// swappable per show. This phase ships the EXISTING office unchanged as
+// `theme: 'office'`: every value below is copied byte-for-byte from the old
+// in-file literals, so the office renders and behaves identically.
+//
+// The engine (TiledMapRenderer / BFS pathfinding / Camera / sprite animation)
+// is already fully generic and needs no change. cast.ts is read-only here
+// (uncommitted human WIP) — the office theme references its existing exports.
+
+import type { Texture } from 'pixi.js';
+import { colors } from '@/design/tokens';
+import {
+ CAST_BY_NAME,
+ getCastFrames,
+ DEFAULT_CHARACTER,
+ type CastMember,
+ type OfficeCharacterName,
+} from './cast';
+
+import officeTilesetUrl from '@/assets/tilesets/office-tileset.png?url';
+import a5FloorsWallsUrl from '@/assets/tilesets/a5-office-floors-walls.png?url';
+import interiorsUrl from '@/assets/tilesets/interiors.png?url';
+// .tmj is Tiled JSON; imported as raw text and parsed by the loader.
+import officeMapRaw from '@/assets/maps/office.tmj?raw';
+
+/** Theme identifiers. Only `office` exists in Phase 0; the five TV-show themes
+ * (friends, brooklyn99, siliconvalley, got, hogwarts) land in later phases. */
+export type ThemeId =
+ | 'office'
+ | 'friends'
+ | 'brooklyn99'
+ | 'siliconvalley'
+ | 'got'
+ | 'hogwarts';
+
+export interface Tile { x: number; y: number; }
+export type Facing = 'up' | 'down' | 'left' | 'right';
+
+/** Kinds of small idle errands around the office (incl. plant watering).
+ * 'smoke' is the boss special: cigar at the open window, god only. */
+export type ErrandKind =
+ | 'water' | 'window' | 'dispenser' | 'fridge' | 'shelf' | 'bin' | 'smoke';
+
+/** One idle-errand anchor: a stand tile + facing, an `fx` tile for the ambient
+ * animation, a duration, and an optional god-only restriction. */
+export interface ErrandSpot {
+ kind: ErrandKind;
+ stand: Tile;
+ facing: Facing;
+ fx: Tile;
+ duration: number;
+ godOnly?: boolean;
+}
+
+/** One tileset atlas + its placement in the global gid space. `embedded` marks
+ * the atlas whose metadata already lives inline in the map's own `tilesets[0]`
+ * (the loader keeps the map's copy and only patches the appended atlases). */
+export interface TilesetEntry {
+ url: string;
+ embedded?: boolean;
+ firstgid?: number;
+ image?: string;
+ imagewidth?: number;
+ imageheight?: number;
+ tilewidth?: number;
+ tileheight?: number;
+ columns?: number;
+ tilecount?: number;
+}
+
+/** Desk-monitor overlay gids. The map paints an OFF monitor block; DeskScreen
+ * overlays the matching ON tiles while the desk's agent is seated. */
+export interface MonitorConfig {
+ /** gid of the OFF monitor block's top-left tile, as painted in the map. */
+ offTopLeftGid: number;
+ /** Matching ON tiles as [gid, dx, dy] relative to the block's top-left. */
+ onGids: ReadonlyArray<readonly [number, number, number]>;
+}
+
+/** The coffee economy's fixed tiles: sideboard (mug rack) → counter machine →
+ * sink → back to the sideboard. `maxCups` caps the clean-mug stock. */
+export interface CoffeeConfig {
+ trayTile: Tile;
+ trayStand: Tile;
+ machineStand: Tile;
+ sinkTile: Tile;
+ sinkStand: Tile;
+ maxCups: number;
+}
+
+/** Clickable prop anchors (tile coords). calendar → SCHEDULES, boards → TASKS,
+ * clock → CLOSING TIME. */
+export interface AnchorConfig {
+ calendar: Tile;
+ boards: Tile;
+ clock: Tile;
+}
+
+/** Theme palette. `background` is the canvas clear color; `noteColors` are the
+ * kanban note colors keyed by task status. */
+export interface PaletteConfig {
+ background: number;
+ noteColors: Record<string, number>;
+}
+
+/** Per-theme cast loader — the indirection point so a future show can swap its
+ * own roster + sprite frames. The office theme points at cast.ts's exports. */
+export interface ThemeCast {
+ byName: Record<string, CastMember>;
+ getFrames: (name: string) => Promise<Texture[][]>;
+ defaultCharacter: string;
+}
+
+/** The full contract a theme must supply. See report §A (theme contract). */
+export interface ThemeConfig {
+ id: ThemeId;
+ /** Raw Tiled JSON text; parsed + tileset-patched by themeLoader. */
+ mapRaw: string;
+ /** Ordered atlases — order matches both the texture load order and the map's
+ * tileset array (texture[i] ↔ tilesets[i]). */
+ tilesets: TilesetEntry[];
+ /** Desk-claim order, by spawn-point name (seat 0 = god / desk-ceo). */
+ primarySeatNames: string[];
+ /** Paired café table seats, in order. */
+ cafeSeatNames: string[];
+ /** Café standing spots: [spawn-point name, kind]. */
+ cafeStands: ReadonlyArray<readonly [string, 'coffee' | 'vending']>;
+ coffee: CoffeeConfig;
+ anchors: AnchorConfig;
+ errandSpots: ErrandSpot[];
+ monitor: MonitorConfig;
+ palette: PaletteConfig;
+ cast: ThemeCast;
+}
+
+/** The existing office, expressed as a theme. Values are copied verbatim from
+ * the former in-file constants in OfficeFloor.tsx / DeskScreen.ts. */
+export const OFFICE_THEME: ThemeConfig = {
+ id: 'office',
+ mapRaw: officeMapRaw,
+ tilesets: [
+ // office-tileset.png — embedded in the map (firstgid 1); keep the map's copy.
+ { url: officeTilesetUrl, embedded: true },
+ { url: a5FloorsWallsUrl, firstgid: 513, image: 'a5', imagewidth: 256, imageheight: 512, tilewidth: 16, tileheight: 16, columns: 16, tilecount: 512 },
+ { url: interiorsUrl, firstgid: 1025, image: 'interiors', imagewidth: 256, imageheight: 1424, tilewidth: 16, tileheight: 16, columns: 16, tilecount: 1424 },
+ ],
+ primarySeatNames: [
+ 'desk-ceo',
+ 'pc-1', 'pc-2', 'pc-3', 'pc-4', 'pc-5', 'pc-6',
+ 'desk-chief-architect', 'desk-product-manager', 'desk-team-lead',
+ 'desk-backend-engineer', 'desk-ui-ux-expert', 'desk-data-engineer',
+ 'desk-project-manager', 'desk-market-researcher', 'desk-agent-organizer',
+ ],
+ cafeSeatNames: ['cafe-seat-1', 'cafe-seat-2', 'cafe-seat-3', 'cafe-seat-4'],
+ cafeStands: [
+ ['cafe-stand-coffee', 'coffee'],
+ ['cafe-stand-vending', 'vending'],
+ ],
+ coffee: {
+ trayTile: { x: 29, y: 15 }, // the sideboard (counter piece)
+ trayStand: { x: 29, y: 16 },
+ machineStand: { x: 26, y: 20 }, // below the counter machine
+ sinkTile: { x: 28, y: 18 }, // free counter top, right end
+ sinkStand: { x: 28, y: 20 },
+ maxCups: 4,
+ },
+ anchors: {
+ calendar: { x: 4, y: 1 },
+ boards: { x: 6, y: 10 },
+ clock: { x: 1, y: 1 },
+ },
+ errandSpots: [
+ // plants (droplets ride on the character via startWatering)
+ { kind: 'water', stand: { x: 2, y: 20 }, facing: 'left', fx: { x: 1, y: 20 }, duration: 4.5 },
+ { kind: 'water', stand: { x: 22, y: 20 }, facing: 'right', fx: { x: 23, y: 20 }, duration: 4.5 },
+ { kind: 'water', stand: { x: 30, y: 20 }, facing: 'right', fx: { x: 31, y: 20 }, duration: 4.5 },
+ // the CEO office is the god's domain: its plant, window, cigar. Workers
+ // never set foot in there for errands.
+ { kind: 'water', stand: { x: 6, y: 4 }, facing: 'up', fx: { x: 6, y: 3 }, duration: 4.5, godOnly: true },
+ { kind: 'smoke', stand: { x: 2, y: 3 }, facing: 'up', fx: { x: 2, y: 1 }, duration: 18, godOnly: true },
+ { kind: 'water', stand: { x: 17, y: 4 }, facing: 'up', fx: { x: 17, y: 3 }, duration: 4.5 },
+ // the two public wall windows — wind streaks drift into the room
+ { kind: 'window', stand: { x: 10, y: 3 }, facing: 'up', fx: { x: 10, y: 1 }, duration: 5 },
+ { kind: 'window', stand: { x: 15, y: 3 }, facing: 'up', fx: { x: 14, y: 1 }, duration: 5 },
+ // water dispensers (hallway + the top-right corner one)
+ { kind: 'dispenser', stand: { x: 16, y: 3 }, facing: 'down', fx: { x: 16, y: 4 }, duration: 3.5 },
+ { kind: 'dispenser', stand: { x: 32, y: 4 }, facing: 'up', fx: { x: 32, y: 3 }, duration: 3.5 },
+ // the café fridge (door light spills out) + the shelf beside it
+ { kind: 'fridge', stand: { x: 29, y: 20 }, facing: 'up', fx: { x: 29, y: 19 }, duration: 3.2 },
+ { kind: 'shelf', stand: { x: 30, y: 20 }, facing: 'up', fx: { x: 30, y: 18 }, duration: 4 },
+ // garbage bins (entrance + café) — a paper ball arcs in
+ { kind: 'bin', stand: { x: 18, y: 20 }, facing: 'left', fx: { x: 17, y: 20 }, duration: 2.6 },
+ { kind: 'bin', stand: { x: 31, y: 16 }, facing: 'right', fx: { x: 32, y: 16 }, duration: 2.6 },
+ ],
+ monitor: {
+ offTopLeftGid: 365,
+ onGids: [
+ [367, 0, 0], [368, 1, 0],
+ [383, 0, 1], [384, 1, 1],
+ ],
+ },
+ palette: {
+ background: colors.ink[900],
+ noteColors: { todo: 0xf2df8a, doing: 0x9ecbf0, blocked: 0xf0a3a3, done: 0xa8e0b0 },
+ },
+ cast: {
+ byName: CAST_BY_NAME as Record<string, CastMember>,
+ getFrames: (name: string) => getCastFrames(name as OfficeCharacterName),
+ defaultCharacter: DEFAULT_CHARACTER,
+ },
+};
+
+/** All registered themes. Phase 0 ships only the office; show themes register
+ * here as their content lands (Phase 2). */
+export const THEMES: Partial<Record<ThemeId, ThemeConfig>> = {
+ office: OFFICE_THEME,
+};
+
+/** Look up a theme by id, falling back to the office theme if unknown/missing
+ * (a bad/absent show bundle must never break the floor — see report §E). */
+export function getTheme(id: ThemeId): ThemeConfig {
+ return THEMES[id] ?? OFFICE_THEME;
+}