Class SignalManager

java.lang.Object
net.citizensnpcs.api.ai.tree.expr.SignalManager

public class SignalManager extends Object
Manages signals for behavior trees. Signals allow behavior trees to communicate and wait for events.
  • Constructor Details

    • SignalManager

      public SignalManager()
  • Method Details

    • clearListeners

      public void clearListeners(NPC npc)
      Clears all listeners for a specific NPC.
      Parameters:
      npc - the NPC
    • emit

      public void emit(NPC npc, String signal)
      Emits a signal for a specific NPC. All behaviors waiting for this signal will be notified.
      Parameters:
      npc - the NPC emitting the signal
      signal - the signal name
    • emitGlobal

      public void emitGlobal(String signal)
      Emits a global signal that all NPCs can receive.
      Parameters:
      signal - the signal name
    • emitToNPC

      public void emitToNPC(UUID npcId, String signal)
      Emits a signal to a specific NPC by ID. All behaviors waiting for this signal will be notified.
      Parameters:
      npcId - the NPC ID
      signal - the signal name
    • listen

      public void listen(NPC npc, String signal, SignalManager.SignalListener listener)
      Registers a listener for a signal on a specific NPC.
      Parameters:
      npc - the NPC to listen on
      signal - the signal name
      listener - the listener to notify
    • unlisten

      public void unlisten(NPC npc, String signal, SignalManager.SignalListener listener)
      Removes a listener.
      Parameters:
      npc - the NPC
      signal - the signal name
      listener - the listener to remove