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 TypeMethodDescriptionintgetId()Returns the NPC definition identifier.intgetIndex()Returns the current scene index.getName()Returns the captured NPC name.getTile()Returns the captured world location.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
-
-
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
-
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
-