Skip to content

Preview where nukes will hit #1813

@Dimitrije-V

Description

@Dimitrije-V

Purpose

When launching a nuke, it is unclear where it might land, leading to situations where the player may lose due to accidentally broken alliances. This is irritating.

I will add interactive nuke previews (Atom, Hydrogen, MIRV) to the build & radial menus, and dim the UI while previewing so players can aim with confidence.

Objectives

Implement a NukePreview render layer that visualizes:

  • Circle/band preview for Atom & Hydrogen bombs.
    • Inner band for area guaranteed to be hit
    • Outer band for the area that might be hit
  • Distributed mini-warhead previews for MIRV across the target nation.
  • Hook previews to both build menu and radial menu:
    • Start preview on hover of enabled nuke items; stop on hover leave/close.
    • Dim the active menu while previewing; restore afterward.
    • Keep previews anchored to a world tile so they remain correct during zoom/pan.
    • Only preview when the nuke type in question can be launched
  • Add unit tests covering preview paths and radial-menu item behavior.

Description

What’s included

  • New render layer: NukePreview (src/client/graphics/layers/NukePreview.ts)
    • Reads from uiState.nukePreview (active + nuke type) and uiState.nukeAnchor (world tile).
    • Atom/Hydrogen:
    • Draws inner-radius ring + soft fill, probabilistic band to outer radius, and two animated dashed rings outside the band.
    • Uses UnitType.AtomBomb / Unit.Type.HydrogenBomb magnitudes (from the config) for ring sizes.
    • MIRV: draws mini targets spread across the target nation:
      • Uniform sampling within 1500-tile radius (matches MirvExecution.mirvRange).
      • Owner-gated (same owner as the anchor) and land-only tiles.
      • Min spacing of 25 tiles Manhattan (mirrors proximityCheck).
      • Uses UnitType.MIRVWarhead magnitudes (from the config) for ring sizes.
      • Deterministic per (type, anchor, owner) with cached results until signature changes.
  • UIState
    • UIState extended to contain:
nukePreview?: { active: boolean; nukeType: string }; 
nukeAnchor?: { x: number; y: number };
  • Wiring & UX:
    • GameRenderer: registers NukePreview layer and provides uiState.
    • BuildMenu:
      • Sets uiState.nukeAnchor to the clicked world tile when the menu opens.
      • On hover over enabled Atom/Hydrogen/MIRV items: sets uiState.nukePreview and adds a subtle “dim” state to the menu; clears on leave/close.
    • RadialMenu:
      • Receives uiState in MenuElementParams.
      • createMenuElements: marks nukes (isNuke) and provides onHoverEnter/onHoverLeave to set/clear uiState.nukePreview.
      • Adds a small helper to dim the radial container while previewing.
      • Stores uiState.nukeAnchor when opening on a tile.
    • PlayerActionHandler: small helpers to start/stop preview (used internally where helpful).

You can see what this looks like here:
Atom
Hydro
MIRV
From the build menu

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Triage

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions