# User Systems (Settings and Chat)

## Purpose
This document describes user-facing systems that are not match-authority systems: persisted settings and chat/commands.

## Settings system

### Authority map
- Settings data + load/save/apply:
  - `Code/User/Settings/GameSettingsSystem.cs`
- Lightweight UI/tutorial cookie storage:
  - `Code/User/Settings/CookieSystem.cs`
- Settings metadata attributes:
  - `Code/User/Settings/Attributes/*`
- Settings UI:
  - `Code/UI/Features/Settings/SettingsPage.razor`

### Runtime behavior
- Settings are persisted to `gamesettings.json`.
- `Load()` hydrates, then `Apply()` pushes runtime effects (audio mixer, viewmodel wall-tuck toggle, etc).
- AFK setting sync is guarded during hydration and synced through `ConnectedClient` once local context exists.
- Settings page reflects metadata attributes (`Group`, subgroup/dock, widgets, display/surface filtering).

## Cookie shell

### Purpose
- `CookieSystem` is a tiny local key/value store for non-authoritative user state such as:
  - dismissed tooltips,
  - tutorial completion flags,
  - lightweight UI affordance memory.

### Runtime behavior
- Cookies are persisted to `cookies.json`.
- Storage is string-backed with convenience helpers for `bool`, `int`, and `float`.
- `MarkSeen` / `HasSeen` are thin aliases for one-way tutorial/tooltip flags.
- The system lazy-loads on first access and saves immediately on mutation.

## Chat and commands

### Authority map
- Chat routing and entry model:
  - `Code/User/Chat/ChatManager.cs`
- Chat commands:
  - `Code/User/Chat/Commands/ChatCommand.cs`
  - `Code/User/Chat/Commands/ChatManager.Commands.cs`
- Chat UI:
  - `Code/UI/Features/Social/Chat/Chat.razor`
  - `Code/UI/Features/Social/Chat/ChatBox.cs`

### Runtime behavior
- Chat manager owns:
  - session join/disconnect chat state reset,
  - global chat vs team chat routing,
  - dead-chat restrictions during active rounds,
  - server messages and command invocation.
- Team chat is validated by alignment/team before display.
- Commands are discovered by `ChatCommand` attribute and invoked via reflection.

## Related docs
- UI architecture: `Code/Core/Documentation/ui-architecture.md`
- Team alignment behavior: `Code/Core/Documentation/teams-rules-rewards.md`
- Player/view ownership context: `Code/Core/Documentation/player-pawn.md`
