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
    • Npc

      public Npc(int index, int id, String name, Tile tile, NpcDefinition definition)
      Creates an NPC snapshot with revision-pinned action metadata.
      Parameters:
      definition - matching active-revision cache definition, or null
  • 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
    • hasActionDefinition

      public boolean hasActionDefinition()
      Reports whether this snapshot has revision-pinned action metadata.
      Returns:
      true when the native adapter resolved this exact NPC ID
    • getDefinition

      public Optional<NpcDefinition> getDefinition()
      Returns the reviewed cache definition for this exact NPC ID.
      Returns:
      metadata with original action slots, or empty when unavailable
    • findAction

      public Optional<NpcAction> findAction(String action)
      Resolves an exact cache action label to its native menu slot.
    • hasAction

      public boolean hasAction(String action)
      Tests whether the reviewed cache definition contains an exact action label.
    • 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