From 5b80e3fc18bdb21a689c1806480714dbfff4200e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 30 Jul 2010 19:26:54 +0100 Subject: convert attachments module from old region module style to new --- .../Avatar/Attachments/AttachmentsModule.cs | 44 ++++++++++++---------- 1 file changed, 25 insertions(+), 19 deletions(-) (limited to 'OpenSim/Region/CoreModules/Avatar/Attachments') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index ff3036a..1187e91 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -29,6 +29,7 @@ using System; using System.Collections.Generic; using System.Reflection; using log4net; +using Mono.Addins; using Nini.Config; using OpenMetaverse; using OpenMetaverse.Packets; @@ -39,38 +40,43 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.CoreModules.Avatar.Attachments { - public class AttachmentsModule : IAttachmentsModule, IRegionModule + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AttachmentsModule")] + public class AttachmentsModule : IAttachmentsModule, INonSharedRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected Scene m_scene = null; + + public string Name { get { return "Attachments Module"; } } + public Type ReplaceableInterface { get { return null; } } - public void Initialise(Scene scene, IConfigSource source) + public void Initialise(IConfigSource source) {} + + public void AddRegion(Scene scene) { - scene.RegisterModuleInterface(this); m_scene = scene; + m_scene.RegisterModuleInterface(this); } - - public void PostInitialise() - { - } - - public void Close() - { - } - - public string Name + + public void RemoveRegion(Scene scene) { - get { return "Attachments Module"; } + m_scene.UnregisterModuleInterface(this); } - - public bool IsSharedModule + + public void RegionLoaded(Scene scene) {} + + public void Close() { - get { return false; } + RemoveRegion(m_scene); } - // Called by client - // + /// + /// Called by client + /// + /// + /// + /// + /// public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent) { m_log.Debug("[ATTACHMENTS MODULE]: Invoking AttachObject"); -- cgit v1.1 From 424b4b2b8663f0f6780d2d3a2656e5b298418711 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 30 Jul 2010 21:41:44 +0100 Subject: move attachment subscription events into AttachmentsModule from scene. restored to some heavy casting in order to preserve RegionCombinerModule semantics, pending better events. --- .../Avatar/Attachments/AttachmentsModule.cs | 23 +++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules/Avatar/Attachments') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 1187e91..d895bb1 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -56,11 +56,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments { m_scene = scene; m_scene.RegisterModuleInterface(this); + m_scene.EventManager.OnNewClient += SubscribeToClientEvents; + // TODO: Should probably be subscribing to CloseClient too, but this doesn't yet give us IClientAPI } public void RemoveRegion(Scene scene) { m_scene.UnregisterModuleInterface(this); + m_scene.EventManager.OnNewClient -= SubscribeToClientEvents; } public void RegionLoaded(Scene scene) {} @@ -69,7 +72,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments { RemoveRegion(m_scene); } - + + public void SubscribeToClientEvents(IClientAPI client) + { + client.OnRezSingleAttachmentFromInv += RezSingleAttachmentFromInventory; + client.OnRezMultipleAttachmentsFromInv += RezMultipleAttachmentsFromInventory; + client.OnObjectAttach += AttachObject; + client.OnObjectDetach += DetachObject; + client.OnDetachAttachmentIntoInv += ShowDetachInUserInventory; + } + + public void UnsubscribeFromClientEvents(IClientAPI client) + { + client.OnRezSingleAttachmentFromInv -= RezSingleAttachmentFromInventory; + client.OnRezMultipleAttachmentsFromInv -= RezMultipleAttachmentsFromInventory; + client.OnObjectAttach -= AttachObject; + client.OnObjectDetach -= DetachObject; + client.OnDetachAttachmentIntoInv -= ShowDetachInUserInventory; + } + /// /// Called by client /// -- cgit v1.1