Interface DrawTarget

All Known Implementing Classes:
Draw, DrawFrame

public sealed interface DrawTarget permits Draw, DrawFrame
Somewhere a draw command can be sent — either straight down the wire (Draw) or into a batch (DrawFrame).

The primitives live here as defaults so the two destinations cannot drift apart: draw.rect(...) and frame.rect(...) are the same code, differing only in where submit(DrawCommand) puts the result.

  • Method Details

    • submit

      String submit(DrawCommand command)
      Route a fully-built command, answering the key it is stored under.

      The plumbing seam the fluent builders call, and the escape hatch for a caller holding a DrawCommand it built or stored itself.

    • line

      default DrawBuilder line(String key, int x1, int y1, int x2, int y2)
      Straight segment from (x1, y1) to (x2, y2).
    • rect

      default DrawBuilder rect(String key, int x, int y, int w, int h)
      Axis-aligned rectangle. Stroked unless DrawBuilder.filled().
    • ellipse

      default DrawBuilder ellipse(String key, int x, int y, int w, int h)
      Ellipse inscribed in the given rectangle.
    • text

      default DrawCaptionBuilder text(String key, int x, int y, String text)
      A caption anchored at (x, y), drawn as-is.

      Returns a DrawCaptionBuilder, so font(...) and value(...) are reachable here and nowhere a shape can see them.

    • value

      default DrawCaptionBuilder value(String key, int x, int y, long value, int decimals)
      A scaled number anchored at (x, y): value(key, x, y, 1234, 2) draws "12.34".

      There is no float anywhere on this wire, deliberately. Send a scaled integer and say what you scaled it by.

    • poly

      default DrawBuilder poly(String key, List<Integer> points)
      Polyline over a flat [x, y, x, y, ...] list.
    • component

      default DrawCaptionBuilder component(String key, int interfaceId, int componentId)
      Highlight an interface component under a key you choose. The producer re-resolves the rect every tick, so the highlight follows the component rather than drifting when the UI relays out.
    • component

      default DrawCaptionBuilder component(int interfaceId, int componentId)
      Highlight an interface component under the conventional auto key comp:<iface>:<comp>.

      The key is computed here rather than left to the producer, so it is known before the command is sent and DrawBuilder.submit() can answer it. A caller who never learns the key cannot clear the highlight; DrawCommand.ComponentTarget.autoKey(int, int) is the same format, exposed for anyone predicting it.

    • npc

      default HighlightBuilder npc(String key, Npc npc)
      Highlight an NPC, tracked. The box follows the NPC as it walks, and sits at the NPC's own height rather than the local player's.

      This is the call the older, worse version of this helper was a placeholder for. It used to send a world-space rect at the tile the NPC occupied when it was called, which marked a position: the box stayed put once the NPC moved, and it carried no plane, so an NPC upstairs was marked on the ground floor. Its javadoc promised that binding the producer's semantic highlight would "change what this sends rather than how it is called". This is that change, and the promise held for the name and the arguments.

      Migrating: the return type moved from DrawBuilder to HighlightBuilder. A chained call is unaffected — draw.npc(key, npc).color(...).ttl(...).submit() compiles and reads exactly as before. What no longer compiles is assigning the result to a DrawBuilder variable, and calling screen(), world() or closed() on it: a highlight's space is not a caller's choice, so offering it would be offering a decision that does not exist. Where you held the builder in a local, change its type; the fluent methods you were calling are all still there.

      Footprint defaults to one tile. Use npc(String, Npc, int, int) for a big NPC, or the box will sit inside it.

    • npc

      default HighlightBuilder npc(String key, Npc npc, int widthTiles, int heightTiles)
      Highlight an NPC, tracked, with a footprint in tiles.
    • npc

      default HighlightBuilder npc(Npc npc)
      Highlight an NPC under the conventional auto key npc:<index>.

      The key is computed here rather than left to the producer, so it is known before the command is sent and HighlightBuilder.submit() can answer it — a caller who never learns the key cannot clear the highlight. DrawCommand.Entity.autoKey(EntityRef, int) is the same format, exposed for anyone predicting it.

    • player

      default HighlightBuilder player(String key, Player player)
      Highlight another player, tracked. Same contract as npc(String, Npc).
    • player

      default HighlightBuilder player(Player player)
      Highlight another player under the conventional auto key player:<index>.
    • self

      default HighlightBuilder self(String key)
      Highlight the local player, tracked.

      Takes no index and stores none: the producer re-resolves the local player's list slot every tick, so this survives a world hop that would leave a stored index pointing at whoever took the seat.

    • self

      default HighlightBuilder self()
      Highlight the local player under the conventional auto key self.
    • entity

      default HighlightBuilder entity(String key, EntityRef ref, int serverIndex)
      Highlight an entity by list and server index — the general form the three named entity helpers funnel through, for a caller holding an index without a snapshot row to go with it.

      Exactly one list is named, which is why EntityRef is a parameter rather than two nullable ones: the producer refuses both npc and player together and refuses neither, because "which wins" is not a rule a caller could guess from a reply that succeeded. NPC 42 and player 42 are different entities.

    • entity

      default HighlightBuilder entity(String key, EntityRef ref, int serverIndex, int widthTiles, int heightTiles)
      entity(String, EntityRef, int) with a footprint in tiles.
    • tile

      default HighlightBuilder tile(String key, int tileX, int tileY)
      Highlight one game tile on the ground floor, in whole tiles.

      Kept at this signature because it already had it — this is the same call, now sending highlight_tile instead of a world-space rect, which is what its old javadoc said binding the highlight would do. It still lands on plane 0 for the same reason it did before: no plane was ever sent. Prefer tile(String, int, int, int) and pass the plane you mean.

      Note the unit change against the primitives: this takes tiles, while rect(...).world() at the same place takes tile * DrawLimits.SUBTILE_SCALE. That split is the producer's and its handler is the one place the two meet.

    • tile

      default HighlightBuilder tile(String key, int tileX, int tileY, int plane)
      Highlight one game tile on a named plane, in whole tiles.

      A plane other than the one the local player is standing on draws nothing. Not an error — the call is accepted and stored — but it resolves unavailable, because the producer's only ground-height source is the player's own elevation and it refuses rather than placing a marker convincingly wrong on the player's floor. npc(String, Npc) and the other entity highlights are the exemption, because an entity carries its own height. See DrawCommand.Tile.

    • tile

      default HighlightBuilder tile(int tileX, int tileY, int plane)
      Highlight one game tile under the conventional auto key tile:<x>:<y>:<plane>.
    • area

      default HighlightBuilder area(String key, int tileX, int tileY, int widthTiles, int heightTiles, int plane)
      Highlight a widthTiles by heightTiles block of ground, anchored at its minimum corner, all in whole tiles.

      The separate call rather than a w/h on tile(String, int, int), because highlight_tile refuses an extent rather than dropping one — a silently-ignored w is how a caller ends up convinced a 5x5 highlight rendered as 1x1 because of a projection bug. Carries the same plane rule as tile(String, int, int, int).

    • area

      default HighlightBuilder area(int tileX, int tileY, int widthTiles, int heightTiles, int plane)
      Highlight a block of ground under the conventional auto key area:<x>:<y>:<w>:<h>:<plane>.