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
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.Primitivenames its ownkindandspaceand ridesdebug_draw_set— or, many at a time,debug_draw_set_batch. - A
DrawCommand.Highlightnames 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 ownhighlight_*call. A highlight cannot go in a batch, and the type system is what enforces that — seeDrawCommand.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 ClassesModifier and TypeInterfaceDescriptionstatic final recordA highlight over awidthTilesbyheightTilesblock of ground, anchored at its minimum corner.static final recordA highlight that tracks an interface component rather than a rectangle.static final recordEllipse inscribed in the given rectangle, stroked or filled.static final recordA highlight that tracks a live entity — an NPC, another player, or the local player.static interfaceA command only ahighlight_*call can carry, because what it marks is a thing rather than a place.static final recordStraight segment from(x1, y1)to(x2, y2).static final recordPolyline over a flat[x, y, x, y, ...]list of 2 to 32 pairs.static interfaceA commanddebug_draw_setcarries: the caller names itskindand itsspace, and the producer stores the geometry as sent.static final recordAxis-aligned rectangle, stroked or filled perDrawStyle.isFilled().static final recordA caption anchored at(x, y).static final recordA highlight over exactly one game tile, on a named plane. -
Method Summary
Modifier and TypeMethodDescriptionkey()The caller-chosen identity of this command within its connection.kind()The primitive this command draws.static StringrequireKey(String key) The key, validated.space()The coordinate space this command's geometry is expressed in.style()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
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
droppedcount 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.
-