Package com.valhalla.sdk.api.entities
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindAction(String action) Resolves an exact cache action label to its native menu slot.Returns the reviewed cache definition for this exact NPC ID.intgetId()Returns the NPC definition identifier.intgetIndex()Returns the current scene index.getName()Returns the captured NPC name.getTile()Returns the captured world location.booleanTests whether the reviewed cache definition contains an exact action label.booleanReports whether this snapshot has revision-pinned action metadata.booleanReports whether definition metadata was decoded.booleaninteract(int action) Dispatches a raw NPC action opcode using this snapshot's scene index.booleanDispatches a typed NPC menu action using this snapshot's scene index.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.valhalla.sdk.api.entities.Locatable
canReach, canReach, distance, distanceTo, getGridX, getGridY, getPlane, getRegionId, getX, getY, getZ, isInArea, isWithinDistance, walkingDistance
-
Constructor Details
-
Npc
Creates an immutable NPC snapshot.- Parameters:
index- current scene index used for interactionsid- NPC definition identifier, or-1when unresolvedname- captured display name, possibly blanktile- current world tile
-
Npc
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. -
getId
public int getId()Returns the NPC definition identifier.- Specified by:
getIdin interfaceIdentifiable- Returns:
- NPC definition identifier, or
-1when unresolved
-
getName
Returns the captured NPC name. -
hasDefinition
public boolean hasDefinition()Reports whether definition metadata was decoded.- Returns:
truewhen 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
Returns the reviewed cache definition for this exact NPC ID.- Returns:
- metadata with original action slots, or empty when unavailable
-
findAction
Resolves an exact cache action label to its native menu slot. -
hasAction
Tests whether the reviewed cache definition contains an exact action label. -
getTile
Returns the captured world location. -
interact
public boolean interact(int action) Dispatches a raw NPC action opcode using this snapshot's scene index.- Specified by:
interactin interfaceInteractable- Parameters:
action- native action opcode- Returns:
truewhen the runtime accepted the action
-
interact
Dispatches a typed NPC menu action using this snapshot's scene index.- Parameters:
action- action to dispatch- Returns:
truewhen accepted; verify subsequent gameplay state for completion
-
toString
-