From 0f15ccb2cf994c64fb8c7f71a64721a3e5fe3085 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 28 Jul 2010 19:23:30 +0100 Subject: relocate moap specific cloning code to MoapModule --- .../CoreModules/World/Media/Moap/MoapModule.cs | 20 +++++++++++++++ OpenSim/Region/Framework/Scenes/EventManager.cs | 29 +++++++++++++++++++++- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 15 +---------- 3 files changed, 49 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs index 6d74b8e..f4814ce 100644 --- a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs +++ b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs @@ -122,6 +122,7 @@ namespace OpenSim.Region.CoreModules.Media.Moap m_scene.EventManager.OnDeregisterCaps += OnDeregisterCaps; m_scene.EventManager.OnSceneObjectLoaded += OnSceneObjectLoaded; m_scene.EventManager.OnSceneObjectPreSave += OnSceneObjectPreSave; + m_scene.EventManager.OnSceneObjectPartCopy += OnSceneObjectPartCopy; } public void Close() @@ -133,6 +134,7 @@ namespace OpenSim.Region.CoreModules.Media.Moap m_scene.EventManager.OnDeregisterCaps -= OnDeregisterCaps; m_scene.EventManager.OnSceneObjectLoaded -= OnSceneObjectLoaded; m_scene.EventManager.OnSceneObjectPreSave -= OnSceneObjectPreSave; + m_scene.EventManager.OnSceneObjectPartCopy -= OnSceneObjectPartCopy; } public void OnRegisterCaps(UUID agentID, Caps caps) @@ -264,6 +266,24 @@ namespace OpenSim.Region.CoreModules.Media.Moap } } + protected void OnSceneObjectPartCopy(SceneObjectPart copy, SceneObjectPart original) + { + if (original.Shape.Media != null) + { + List dupeMedia = new List(); + + foreach (MediaEntry me in original.Shape.Media) + { + if (me != null) + dupeMedia.Add(MediaEntry.FromOSD(me.GetOSD())); + else + dupeMedia.Add(null); + } + + copy.Shape.Media = dupeMedia; + } + } + public MediaEntry GetMediaEntry(SceneObjectPart part, int face) { MediaEntry me = null; diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 3b8d727..0a9a29e 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -350,6 +350,12 @@ namespace OpenSim.Region.Framework.Scenes /// public event SceneObjectPreSaveDelegate OnSceneObjectPreSave; public delegate void SceneObjectPreSaveDelegate(SceneObjectGroup persistingSo, SceneObjectGroup originalSo); + + /// + /// Called when a scene object part is cloned within the region. + /// + public event SceneObjectPartCopyDelegate OnSceneObjectPartCopy; + public delegate void SceneObjectPartCopyDelegate(SceneObjectPart copy, SceneObjectPart original); public delegate void RegionUp(GridRegion region); public event RegionUp OnRegionUp; @@ -2073,6 +2079,27 @@ namespace OpenSim.Region.Framework.Scenes } } } - } + } + + public void TriggerOnSceneObjectPartCopy(SceneObjectPart copy, SceneObjectPart original) + { + SceneObjectPartCopyDelegate handler = OnSceneObjectPartCopy; + if (handler != null) + { + foreach (SceneObjectPartCopyDelegate d in handler.GetInvocationList()) + { + try + { + d(copy, original); + } + catch (Exception e) + { + m_log.ErrorFormat( + "[EVENT MANAGER]: Delegate for TriggerOnSceneObjectPartCopy failed - continuing. {0} {1}", + e.Message, e.StackTrace); + } + } + } + } } } \ No newline at end of file diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 085da19..71ca605 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1617,20 +1617,7 @@ namespace OpenSim.Region.Framework.Scenes dupe.DoPhysicsPropertyUpdate(UsePhysics, true); } - if (Shape.Media != null) - { - List dupeMedia = new List(); - - foreach (MediaEntry me in Shape.Media) - { - if (me != null) - dupeMedia.Add(MediaEntry.FromOSD(me.GetOSD())); - else - dupeMedia.Add(null); - } - - dupe.Shape.Media = dupeMedia; - } + ParentGroup.Scene.EventManager.TriggerOnSceneObjectPartCopy(dupe, this); // m_log.DebugFormat("[SCENE OBJECT PART]: Clone of {0} {1} finished", Name, UUID); -- cgit v1.1