Logo FSBarV1_Archived

UnitGlyph Module

Renders units and buildings using the information-dense visual language specified in feature 028-unit-viz-language. Consumers supply per-frame `UnitDisplay` values (MVP: `FSBar.SyntheticData`), and this module produces a `SkiaViewer.Scene` subtree suitable for composition into the main `SceneBuilder.buildScene` output. Classification, tier derivation, faction derivation, and label lookup happen inside this module and are cached per `DefId` — callers do not need to know about `BarData` at all.

Functions and values

Function or value Description

advanceEffects previousFrame currentFrame nowMs

Full Usage: advanceEffects previousFrame currentFrame nowMs

Parameters:
Returns: EventEffect list

Observes per-frame state deltas and advances the internal event-effect queue. Must be called once per rendered frame before `buildUnitsGlyph`. Pure in terms of its inputs/outputs except for the module-private effect queue, which is scoped per session and cleared by `resetSession`.

previousFrame : Map<int, UnitDisplay>
currentFrame : Map<int, UnitDisplay>
nowMs : int
Returns: EventEffect list

buildOverlayLayer units style activeOverlays

Full Usage: buildOverlayLayer units style activeOverlays

Parameters:
Returns: Element list

Builds the overlay layer (weapon ranges, sight, command queue, full names) for a set of units given the currently-active overlays.

units : UnitDisplay seq
style : UnitGlyphStyle
activeOverlays : Set<OverlayKind>
Returns: Element list

buildUnit unit' style activeEffects

Full Usage: buildUnit unit' style activeEffects

Parameters:
Returns: Element list

Builds the Scene subtree for a single `UnitDisplay` under the given style. Includes the permanent layer (shape, stroke, pip, HP arc, label, construction overlay, automatic event effects). Does NOT include overlay layers (weapon ranges, sight, command queue, full names) — those are added by `buildOverlayLayer` when the corresponding `OverlayKind` is active in the viz config.

unit' : UnitDisplay
style : UnitGlyphStyle
activeEffects : EventEffect list
Returns: Element list

buildUnitsGlyph units style activeOverlays

Full Usage: buildUnitsGlyph units style activeOverlays

Parameters:
Returns: Element list

Builds the complete glyph-based unit layer (permanent + overlay). Intended to be called by `SceneBuilder.buildScene` when `VizConfig.UseGlyphRenderer = true`.

units : UnitDisplay seq
style : UnitGlyphStyle
activeOverlays : Set<OverlayKind>
Returns: Element list

classifyFaction subfolder internalName logMiss

Full Usage: classifyFaction subfolder internalName logMiss

Parameters:
    subfolder : string
    internalName : string
    logMiss : string -> unit

Returns: FactionId

Derives faction from BarData subfolder + internal name per spec FR-004.

subfolder : string
internalName : string
logMiss : string -> unit
Returns: FactionId

classifyShape canMove canFly movementClass logMiss

Full Usage: classifyShape canMove canFly movementClass logMiss

Parameters:
    canMove : bool
    canFly : bool
    movementClass : string option
    logMiss : string -> unit

Returns: MovementShape

Classifies a `BarData.UnitDef` into one of the six movement shapes. Pure and total; `MovementShape.Unknown` is returned for unrecognized classes, and a one-shot structured warning is emitted through the supplied `logMiss` callback (allows tests to observe misses).

canMove : bool
canFly : bool
movementClass : string option
logMiss : string -> unit
Returns: MovementShape

classifyTier customParams category logMiss

Full Usage: classifyTier customParams category logMiss

Parameters:
    customParams : Map<string, string>
    category : string option
    logMiss : string -> unit

Returns: Tier

Derives tech tier from BarData fields per spec FR-005.

customParams : Map<string, string>
category : string option
logMiss : string -> unit
Returns: Tier

resetSession ()

Full Usage: resetSession ()

Parameters:
    () : unit

Clears the module-private event-effect queue and per-`DefId` static classification cache. Called by `GameViz.start` / `GameViz.stop`.

() : unit

statusLine activeOverlays

Full Usage: statusLine activeOverlays

Parameters:
Returns: string

Projects the currently-active overlay set onto the single-letter status-line string per FR-015. Stable ordering: W, L, C, N. Deferred overlays (R E B T V I X) are ignored until they are added to OverlayKind. Pure function — no side effects, no session state.

activeOverlays : Set<OverlayKind>
Returns: string

Type something to start searching.