Class SceneObject

java.lang.Object
com.botwithus.bot.api.entities.SceneObject
All Implemented Interfaces:
EntityContext

public final class SceneObject extends Object implements EntityContext
Rich wrapper around SceneObjectInfo with lazy LocationType resolution and option-keyed interact.

Obtained through SceneObjects.query() — don't construct directly. The facade owns the LocationType cache that backs getType() repeats.

  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Chebyshev distance to the local player tile, or MAX_VALUE if the player isn't loaded.
    Right-click options.
    Cached LocationType for this object.
    int
     
    boolean
    hasOption(String option)
    True if any option matches option case-insensitively.
    void
    interact(int optionIndex)
    Queue an action by 1-based right-click option index.
    void
    interact(int optionIndex, int unusedSubOption)
    Two-arg variant kept for pre-rewrite scripts.
    boolean
    interact(String option)
    Queue an action by option text.
    boolean
    The snapshot only carries visible objects; this stub always returns false.
    Display name.
    int
    Plane / height level (0-3).
    raw()
     
    int
    The loc id whose definition carries this object's name and right-click options, with the morphvarp ("multiloc") transform already applied by the producer.
    The producer resolves morphvarp transforms before publishing the snapshot and the result rides on the row as resolvedId(), so this is a no-op identity.
    int
    How far this loc's model is turned, in quarter turns 0..3, exactly as the producer published it.
    int
    The scenery shape code as published on the wire, which says what kind of placement this loc is: a wall, a wall decoration, a ground decoration, a centrepiece and so on.
    int
    Absolute world tile X.
    int
    Absolute world tile Y.
     
    int
    The loc id the server sent.

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface EntityContext

    distanceTo, distanceTo
  • Method Details

    • raw

      public SceneObjectInfo raw()
    • handle

      public int handle()
    • typeId

      public int typeId()
      The loc id the server sent. This is what identity and hardcoded id sets are keyed on, and what an interaction is addressed to — it is deliberately not the id whose definition carries the name, which is resolvedId().
    • resolvedId

      public int resolvedId()
      The loc id whose definition carries this object's name and right-click options, with the morphvarp ("multiloc") transform already applied by the producer.

      Equal to typeId() for a loc that does not morph, so it is always usable. For one that does — a Range, a bonfire, a bank chest, a construction hotspot, most instanced scenery — the server publishes a base id whose definition has an empty name and no options, and only this id resolves to the real thing.

    • name

      public String name()
      Display name. Prefers the pre-resolved raw.name from the RPC (cheap, no defn fetch) and falls back to the LocationType when the producer didn't fill it in — which, since that LocationType is looked up on resolvedId(), is the real name even for a morph loc.
    • tileX

      public int tileX()
      Description copied from interface: EntityContext
      Absolute world tile X.
      Specified by:
      tileX in interface EntityContext
    • tileY

      public int tileY()
      Description copied from interface: EntityContext
      Absolute world tile Y.
      Specified by:
      tileY in interface EntityContext
    • plane

      public int plane()
      Description copied from interface: EntityContext
      Plane / height level (0-3).
      Specified by:
      plane in interface EntityContext
    • rotation

      public int rotation()
      How far this loc's model is turned, in quarter turns 0..3, exactly as the producer published it.

      This is not a compass heading. It turns the loc away from its model's own default pose, and that pose is chosen per model, so the value is only meaningful when compared against another rotation of the same loc, or read together with shape() to work out which tile edge a wall occupies.

      Inside an instance the chunk the tile was copied from may itself be rotated, by SourceTile.rotation(); anything directional read from the source region has to account for both.

      Returns:
      0..3, or SceneObjectInfo.UNKNOWN_ROTATION for a row built without one
    • shape

      public int shape()
      The scenery shape code as published on the wire, which says what kind of placement this loc is: a wall, a wall decoration, a ground decoration, a centrepiece and so on.
      Returns:
      the shape code, or SceneObjectInfo.UNKNOWN_SHAPE for a row built without one
    • isHidden

      public boolean isHidden()
      The snapshot only carries visible objects; this stub always returns false.
    • distanceToPlayer

      public int distanceToPlayer()
      Chebyshev distance to the local player tile, or MAX_VALUE if the player isn't loaded.
    • resolveTransform

      public SceneObject resolveTransform()
      The producer resolves morphvarp transforms before publishing the snapshot and the result rides on the row as resolvedId(), so this is a no-op identity. Kept so pre-rewrite scripts compile unchanged.

      That claim was aspirational until wire v20 and is now true: getType(), name() and getOptions() all resolve through the morph-resolved id.

    • interact

      public void interact(int optionIndex, int unusedSubOption)
      Two-arg variant kept for pre-rewrite scripts. unusedSubOption is ignored — the option index encodes everything the action queue needs. Delegates to interact(int).
    • getType

      public LocationType getType()
      Cached LocationType for this object. Resolved off resolvedId(), never typeId(): a morph loc's base definition has an empty name and no options, so looking up the base id is what made Ranges, bonfires, bank chests and construction hotspots invisible to every name- or option-based query. null if lookup fails.
    • getOptions

      public List<String> getOptions()
      Right-click options. Prefers the pre-resolved raw.options from the RPC; falls back to LocationType.options() when raw came back empty — and that LocationType is the morph-resolved one, so the options are the ones the player actually sees.
    • hasOption

      public boolean hasOption(String option)
      True if any option matches option case-insensitively.
    • interact

      public void interact(int optionIndex)
      Queue an action by 1-based right-click option index.
      Throws:
      IllegalArgumentException - for optionIndex outside [1, 6]
    • interact

      public boolean interact(String option)
      Queue an action by option text. Returns false when the option isn't on this object's menu (no action queued).
    • toString

      public String toString()
      Overrides:
      toString in class Object