From 970249a3c7b1d9cffe88eb8d7075cce6fa8ca3d9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 4 Oct 2013 19:40:43 +0100 Subject: Add OnChatToNPC and OnInstantMessageToNPC messages to NPCAvatar to allow region modules to directly subscribe to chat and messages received by NPCs Currently still requires INPC from NPCModule.GetNPC() to be cast to an NPCAvatar. --- .../Region/OptionalModules/World/NPC/NPCAvatar.cs | 27 +++++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 9a61702..a895ee1 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -44,6 +44,20 @@ namespace OpenSim.Region.OptionalModules.World.NPC { public bool SenseAsAgent { get; set; } + public delegate void ChatToNPC( + string message, byte type, Vector3 fromPos, string fromName, + UUID fromAgentID, UUID ownerID, byte source, byte audible); + + /// + /// Fired when the NPC receives a chat message. + /// + public event ChatToNPC OnChatToNPC; + + /// + /// Fired when the NPC receives an instant message. + /// + public event Action OnInstantMessageToNPC; + private readonly string m_firstname; private readonly string m_lastname; private readonly Vector3 m_startPos; @@ -614,17 +628,18 @@ namespace OpenSim.Region.OptionalModules.World.NPC string message, byte type, Vector3 fromPos, string fromName, UUID fromAgentID, UUID ownerID, byte source, byte audible) { - } + ChatToNPC ctn = OnChatToNPC; - public virtual void SendChatMessage( - byte[] message, byte type, Vector3 fromPos, string fromName, - UUID fromAgentID, UUID ownerID, byte source, byte audible) - { + if (ctn != null) + ctn(message, type, fromPos, fromName, fromAgentID, ownerID, source, audible); } public void SendInstantMessage(GridInstantMessage im) { - + Action oimtn = OnInstantMessageToNPC; + + if (oimtn != null) + oimtn(im); } public void SendGenericMessage(string method, UUID invoice, List message) -- cgit v1.1