Skip to content

HudPreview beta ​

Class of @v12-engine/editor

ts
export declare class HudPreview

A unit's HUD drawn by the client's own layer for a stand-in of a type, its state set by knobs: what a panel shows over a stage (draw), or reads (collect)

Members ​

constructor ​

ts
constructor(registry: Registry, options?: {
        canvas?: HTMLCanvasElement;
        icons?: IconSet;
        camera?: () => {
            x: number;
            y: number;
            z: number;
        } | undefined;
        height?: () => number;
        look?: UnitHudLook;
        now?: () => number;
        measure?: (font: string, text: string) => number;
    });

Constructs a new instance of the HudPreview class

collect ​

ts
collect(project: ProjectTo): FrameList<DrawOp>;

What the layer draws this frame, where project puts the world on the screen

dispose ​

ts
dispose(): void;

Lets go of the layer and what it drew with

draw ​

ts
draw(project: ProjectTo, width: number, height: number): FrameList<DrawOp>;

Draws it on the canvas, width by height CSS pixels (resized as they change, at the page's pixel ratio)

layer ​

ts
readonly layer: UnitHudLayer;

The client's own plate layer that lays out and draws the HUD

plate ​

ts
plate(): UnitHudPlate | null;

The plate the stand-in shows now: picked for who looks, its state and the camera's distance

resolved ​

ts
resolved(): UnitHudDef | UnitHudPlate | null;

The HUD the stand-in has, as said (a function's worked out for it now), before a plate is picked: null for none

show ​

ts
show(type: string, hud: UnitHudSource | null | undefined, knobs?: HudPreviewKnobs): void;

Shows a unit type with a HUD, in a state: the HUD as being edited (undefined: the client's own plate, null: none), the stand-in's state as the knobs say

state ​

ts
readonly state: GameState;

The stand-in's game: one unit of the type shown, its state from the knobs