Class SignalManager
java.lang.Object
net.citizensnpcs.api.ai.tree.expr.SignalManager
Manages signals for behavior trees. Signals allow behavior trees to communicate and wait for events.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceListener interface for signal notifications. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclearListeners(NPC npc) Clears all listeners for a specific NPC.voidEmits a signal for a specific NPC.voidemitGlobal(String signal) Emits a global signal that all NPCs can receive.voidEmits a signal to a specific NPC by ID.voidlisten(NPC npc, String signal, SignalManager.SignalListener listener) Registers a listener for a signal on a specific NPC.voidunlisten(NPC npc, String signal, SignalManager.SignalListener listener) Removes a listener.
-
Constructor Details
-
SignalManager
public SignalManager()
-
-
Method Details
-
clearListeners
Clears all listeners for a specific NPC.- Parameters:
npc- the NPC
-
emit
Emits a signal for a specific NPC. All behaviors waiting for this signal will be notified.- Parameters:
npc- the NPC emitting the signalsignal- the signal name
-
emitGlobal
Emits a global signal that all NPCs can receive.- Parameters:
signal- the signal name
-
emitToNPC
Emits a signal to a specific NPC by ID. All behaviors waiting for this signal will be notified.- Parameters:
npcId- the NPC IDsignal- the signal name
-
listen
Registers a listener for a signal on a specific NPC.- Parameters:
npc- the NPC to listen onsignal- the signal namelistener- the listener to notify
-
unlisten
Removes a listener.- Parameters:
npc- the NPCsignal- the signal namelistener- the listener to remove
-