Interface DrawCommand

All Known Subinterfaces:
DrawCommand.Highlight, DrawCommand.Primitive
All Known Implementing Classes:
DrawCommand.Area, DrawCommand.ComponentTarget, DrawCommand.Ellipse, DrawCommand.Entity, DrawCommand.Line, DrawCommand.Poly, DrawCommand.Rect, DrawCommand.Text, DrawCommand.Tile

public sealed interface DrawCommand permits DrawCommand.Primitive, DrawCommand.Highlight
One fully-specified draw command, ready for the wire.

Sealed, with one variant per geometry shape, so the encoder behind DrawAPI dispatches through an exhaustive switch and a new primitive cannot be added without every encoder being told about it.

Two families, and which one a command belongs to decides which RPC carries it. That is the split DrawCommand.Primitive and DrawCommand.Highlight exist to make structural rather than remembered:

  • A DrawCommand.Primitive names its own kind and space and rides debug_draw_set — or, many at a time, debug_draw_set_batch.
  • A DrawCommand.Highlight names neither. The producer forces both, because the thing being marked is an entity or a footprint rather than a rectangle, and it re-reads that thing's live position every tick. Each one rides its own highlight_* call. A highlight cannot go in a batch, and the type system is what enforces that — see DrawCommand.Highlight.

Commands are keyed, not handled. The key is a caller-chosen string of 1 to DrawLimits.MAX_KEY_BYTES UTF-8 bytes; setting the same key again replaces rather than appends, so redrawing "target-box" every tick is idempotent. There is no handle to leak and nothing to free. Keys are scoped to the connection: two scripts on two clients may both use "target-box" without colliding, and the producer drops everything a connection drew when its pipe closes.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final record 
    A highlight over a widthTiles by heightTiles block of ground, anchored at its minimum corner.
    static final record 
    A highlight that tracks an interface component rather than a rectangle.
    static final record 
    Ellipse inscribed in the given rectangle, stroked or filled.
    static final record 
    A highlight that tracks a live entity — an NPC, another player, or the local player.
    static interface 
    A command only a highlight_* call can carry, because what it marks is a thing rather than a place.
    static final record 
    Straight segment from (x1, y1) to (x2, y2).
    static final record 
    Polyline over a flat [x, y, x, y, ...] list of 2 to 32 pairs.
    static interface 
    A command debug_draw_set carries: the caller names its kind and its space, and the producer stores the geometry as sent.
    static final record 
    Axis-aligned rectangle, stroked or filled per DrawStyle.isFilled().
    static final record 
    A caption anchored at (x, y).
    static final record 
    A highlight over exactly one game tile, on a named plane.
  • Method Summary

    Modifier and Type
    Method
    Description
    key()
    The caller-chosen identity of this command within its connection.
    The primitive this command draws.
    static String
    The key, validated.
    The coordinate space this command's geometry is expressed in.
    Colour, stroke, fill, order and lifetime.
  • Method Details

    • key

      String key()
      The caller-chosen identity of this command within its connection.
    • space

      DrawSpace space()
      The coordinate space this command's geometry is expressed in.
    • style

      DrawStyle style()
      Colour, stroke, fill, order and lifetime.
    • kind

      DrawKind kind()
      The primitive this command draws.
    • requireKey

      static String requireKey(String key)
      The key, validated.

      Rejected here rather than on the wire so a script author gets the failure at the call site with a stack trace, instead of a dropped count from a batch that is already gone.

      The producer measures a key in UTF-8 bytes, so that is what is measured here; String.length() would wave through keys the producer refuses.