Hoist pure render helpers out of TileLayer into a shared module (Pixi cutover prerequisite) #1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
The PixiJS spike (
40ab476, route/game/pixi) validated the renderer verdict indocs/ENGINE_FRONTEND.md: 60fps at whole-map zoom-out where the DOM renderer stalls. To stay decoupled from the then-in-fluxcomponents/map/TileLayer.tsx, the spike had to reimplement the pure tile-visual logic inlib/render/pixi/tileVisual.ts. That duplication is now the single biggest risk to the cutover: any change to fog/fence/road/tile rules must currently be made twice, and the two renderers will silently drift apart.The organic-village rewiring of
TileLayer.tsx(25571c4) has settled, so this refactor is unblocked.Task
Extract every pure, renderer-agnostic decision out of
components/map/TileLayer.tsx/components/map/constants.tsinto a sharedlib/module (suggestion:lib/game/tileVisuals.ts— pure, no React, no Pixi, no DB) and make both renderers import it:isChoppedStumpTile).isExploredand the 4-level brightness dim (computeFogDim), including the claimed-village reveal (+1 halo) semantics.fencePerimeterinlib/game/villageArea.ts; the offsets currently live in the render layer).roadSpriteFor(mask)and the per-chunk neighbour pass (computeRoadSprites) that builds the masks.Constraints
(tile, neighbours, villageArea, …) → {spriteKey, tint/brightness, offsets}-shaped outputs. No JSX, no Pixi types.components/map/TileLayer.tsxandlib/render/pixi/tileVisual.tsbecome thin consumers; delete the spike's duplicated logic./gameand/game/pixi(screenshots), and on/dev/fit(the fence/path/stump test-fitting cases live there).tests/unit/game/(sprite selection per terrain/overlay combination, fog level boundaries, fence mask → sprite, road mask table). Boundary tests for every threshold, per the testing contract in CLAUDE.md.Acceptance criteria
lib/render/pixi/./game,/game/pixi, and/dev/fitare pixel-equivalent to before (screenshot comparison at 3 zooms).Blocks #2.
Closed after the Rust/Bevy cutover. The DOM/Pixi extraction described here is superseded by the native Bevy renderer.