---
phase: 06.3
plan: "07"
subsystem: legacy-spec
tags: [client, nameplate, depth, extraction]
requires:
  - phase: "06.1"
    provides: "Player and tile depth translation"
provides:
  - "D-45 Plan C legacy depth_set analysis"
  - "NAMEPLATE_DEPTH = 10000 rationale for plan 06.3-12"
affects: [phase-06.3, D-45, Nameplate, PlayerRenderer, RoomRenderer]
tech-stack:
  added: []
  patterns: ["Canonical source citation for depth constants"]
key-files:
  created:
    - .planning/phases/06.3-cycle-4-gap-closure-d-40-d-45-d-51-d-53-d-54-d-55-d-56-d-57-/06.3-07-SUMMARY.md
  modified: []
key-decisions:
  - "Use a fixed Phaser nameplate depth above all MVP player and tile depths."
patterns-established:
  - "Document GameMaker-vs-Phaser depth polarity whenever deriving z-order constants."
requirements-completed:
  - REQ-CLI-04
  - REQ-CLI-08
duration: 10 min
completed: 2026-05-14
---

# Phase 06.3 Plan 07: D-45 Plan C Nameplate Depth Spec Summary

[doc->REQ-CLI-04] [doc->REQ-CLI-08]

**D-45 Plan C now has a canonical depth source and a concrete Phaser constant: `NAMEPLATE_DEPTH = 10000`.**

## Legacy Findings

- `extracted/client-5-8/objects/0042-player/events/Draw.dnd.json` draws remote player text with `draw_text(x+(sprite_width/2)-(string_width(global.p_name[pid])/2),y-16,global.p_name[pid]);`.
- `extracted/client-5-8/objects/0000-server/events/Draw.dnd.json` draws local player text with the same formula, using `global.playername`.
- Neither Draw event assigns a separate text depth; the text renders inside the object's Draw event at the current object depth.
- `extracted/client-5-8/objects/0042-player/events/Step.gml` and `extracted/client-5-8/objects/0000-server/events/Step.gml` call `depth_set(0,43)` for normal player sprites.
- The current port cites that same source in `apps/client/src/render/PlayerRenderer.ts` and implements `computeDepth(layer, yOffset, y)` as:
  - GameMaker depth: `round(1000 * layer - (y + yOffset))`.
  - Phaser depth: sign-flipped, so higher Phaser depth draws on top.

## Phaser Translation

- For normal players, `computeDepth(0, 43, y)` produces Phaser depth `y + 43`.
- At spawn y=400, player sprite depth is 443.
- At the MVP room bottom, `room_bottom_y + 43 = 800 + 43 = 843`.
- Tile sprites use `tile.y - 2000` through the RoomRenderer layer-2 translation, so they remain far behind player sprites.
- Nameplate text currently has default Phaser depth 0, which is behind player sprites with depth around 443.
- Phaser polarity differs from GameMaker: Phaser higher depth draws later/on top; GameMaker lower depth draws later/on top. The port already handles this by sign-flipping object depths.

## Constant for 06.3-12

Use this constant in `Nameplate.ts`:

```typescript
// SOURCE: extracted/client-5-8/objects/0042-player/events/Draw.dnd.json
// In legacy BNO, nameplate draw_text() fires in the player's Draw event at player object depth.
// Phaser translation: NAMEPLATE_DEPTH must exceed max player sprite phaserDepth.
// Max phaserDepth = room_height + 43 = 800 + 43 = 843 (mvp-room, tile_h=40, 20 rows).
// Constant 10000 chosen to safely exceed all player+tile depths.
const NAMEPLATE_DEPTH = 10000;
```

Canonical source ref string for assertions:

`extracted/client-5-8/objects/0042-player/events/Draw.dnd.json - player Draw event text; extracted/client-5-8/objects/0042-player/events/Step.gml - depth_set(0,43); phaserDepth = y + 43; max ~= 843 at room bottom; NAMEPLATE_DEPTH=10000 chosen to exceed`

## Intentional Divergence

Exact GameMaker Draw-event z-order is object-depth driven and can interleave nameplate text with sprites according to each object's depth. For the MVP, `NAMEPLATE_DEPTH = 10000` makes all nameplates render above all player sprites. That is an intentional D-45 readability fix; exact text/sprite interleaving can be revisited in Phase 7 if a consolidated depth registry is needed.

## Task Commits

1. **Task 1/2: Read-only D-45 depth spec extraction** - this summary commit

## Files Created/Modified

- Created `.planning/phases/06.3-cycle-4-gap-closure-d-40-d-45-d-51-d-53-d-54-d-55-d-56-d-57-/06.3-07-SUMMARY.md`.
- No source files modified.

## Deviations from Plan

None.

## Verification

- Verified remote and local Draw event nameplate text calls.
- Verified normal player `depth_set(0,43)` in extracted Step events.
- Verified `PlayerRenderer.computeDepth()` sign-flip formula and `RoomRenderer` tile depth formula.
- Confirmed this was read-only: no source files modified.

## Next Phase Readiness

Ready for `06.3-12`. The executor can set `Nameplate` text depth to `NAMEPLATE_DEPTH = 10000` and cite the canonical source string above in the Playwright assertion.

---
*Phase: 06.3*
*Completed: 2026-05-14*
