---
name: theme_state.aicomponent
description: 主题状态管理器。管理路径颜色、箭头风格、UI 文本标签、画布背景色等视觉主题配置，供渲染器和 UI 组件读取当前主题值。
triggers: 需要管理游戏视觉主题、路径颜色方案或主题切换逻辑时触发。
---

# 主题状态管理器（Theme State Manager）

## 说明

`ThemeManager` 从当前激活的 `ThemeVariantConfig`（`src/theme/index.ts`）中读取主题配置：

- `getPathColor(pathIndex)`：返回指定路径的颜色（十六进制数字）
- `getArrowStyle()`：返回箭头头部风格
- `canvasBgColor`：画布背景色

## Scaffold

| 目标路径 | 来源 |
|---------|-----|
| `src/game/scenes/GameUI/ThemeManager.ts` | `ref/ThemeManager.ts` |

## Skill Definition

```yaml
tools:
  - read_file
  - write_file
inputs:
  - source: src/game/scenes/GameUI/ThemeManager.ts
outputs:
  - themeManager: ThemeManager class
```

## Recipe

| 决策 | 原因 |
|------|------|
| **集中主题查询** | 路径颜色、箭头风格等视觉值分散在多个渲染组件中会导致主题切换时遗漏；ThemeManager 作为单一查询入口，确保视觉一致性 |
| **无状态适配器设计** | ThemeManager 每次调用时从激活的 ThemeVariantConfig 读取，不缓存；切换主题只需替换配置对象，无需通知所有订阅者 |
| **颜色 API 返回数字而非字符串** | Phaser Graphics API 接受十六进制数字（`0xff0000`），转换在 ThemeManager 内完成，渲染层不感知颜色格式 |

## Adapter

- **Role**: `themeState` — 视觉主题状态适配器（路径颜色、箭头风格、背景色）
- **Provides**: `ThemeManager` 类（`getPathColor(pathIndex)`、`getArrowStyle()`、`canvasBgColor` 属性）
- **Requires**: `phaser.aicomponent`、`theme_variant.aiconfig`（ThemeVariantConfig 数据源）
- **Consumed by**: `path_renderer.aicomponent`（路径颜色）、`game_scene.aicomponent`（画布背景色）、`top_ui_bar.aicomponent` 等 UI 组件（主题配色）
- **Integration point**: `src/game/scenes/GameUI/ThemeManager.ts` —— `game_scene` 在初始化时实例化，并传入渲染子系统

## Imports

- `phaser.aicomponent`（硬依赖）
