Class Npc

java.lang.Object
com.valhalla.sdk.api.entities.Npc
All Implemented Interfaces:
Identifiable, Indexed, Interactable, Locatable, Nameable

public final class Npc extends Object implements Locatable, Identifiable, Indexed, Nameable, Interactable
Immutable non-player-character snapshot.
  • Constructor Details

    • Npc

      public Npc(int index, int id, String name, Tile tile)
      Creates an immutable NPC snapshot.
      Parameters:
      index - current scene index used for interactions
      id - NPC definition identifier, or -1 when unresolved
      name - captured display name, possibly blank
      tile - current world tile
  • Method Details

    • getIndex

      public int getIndex()
      Returns the current scene index.
      Specified by:
      getIndex in interface Indexed
      Returns:
      current scene index used for native interaction
    • getId

      public int getId()
      Returns the NPC definition identifier.
      Specified by:
      getId in interface Identifiable
      Returns:
      NPC definition identifier, or -1 when unresolved
    • getName

      public String getName()
      Returns the captured NPC name.
      Specified by:
      getName in interface Nameable
      Returns:
      captured NPC name, possibly blank
    • hasDefinition

      public boolean hasDefinition()
      Reports whether definition metadata was decoded.
      Returns:
      true when both a non-negative definition ID and name were decoded
    • getTile

      public Tile getTile()
      Returns the captured world location.
      Specified by:
      getTile in interface Locatable
      Returns:
      current world tile captured in this snapshot
    • interact

      public boolean interact(int action)
      Dispatches a raw NPC action opcode using this snapshot's scene index.
      Specified by:
      interact in interface Interactable
      Parameters:
      action - native action opcode
      Returns:
      true when the runtime accepted the action
    • interact

      public boolean interact(NpcAction action)
      Dispatches a typed NPC menu action using this snapshot's scene index.
      Parameters:
      action - action to dispatch
      Returns:
      true when accepted; verify subsequent gameplay state for completion
    • toString

      public String toString()
      Overrides:
      toString in class Object