From 491b8181ad4fcb0a8002ee2406703b89c4928219 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 26 Jul 2010 20:13:26 +0100 Subject: Add EventManager.OnSceneObjectLoaded() for future use. This is fired immediately after a scene object is loaded from storage. --- .../CoreModules/World/Media/Moap/MoapModule.cs | 19 +++++++++---- OpenSim/Region/Framework/Scenes/EventManager.cs | 32 ++++++++++++++++++++-- OpenSim/Region/Framework/Scenes/Scene.cs | 4 ++- 3 files changed, 46 insertions(+), 9 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs index 0130ff9..2771492 100644 --- a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs +++ b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs @@ -98,17 +98,19 @@ namespace OpenSim.Region.CoreModules.Media.Moap public void RegionLoaded(Scene scene) { - m_scene.EventManager.OnRegisterCaps += RegisterCaps; - m_scene.EventManager.OnDeregisterCaps += DeregisterCaps; + m_scene.EventManager.OnRegisterCaps += OnRegisterCaps; + m_scene.EventManager.OnDeregisterCaps += OnDeregisterCaps; + m_scene.EventManager.OnSceneObjectLoaded += OnSceneObjectLoaded; } public void Close() { - m_scene.EventManager.OnRegisterCaps -= RegisterCaps; - m_scene.EventManager.OnDeregisterCaps -= DeregisterCaps; + m_scene.EventManager.OnRegisterCaps -= OnRegisterCaps; + m_scene.EventManager.OnDeregisterCaps -= OnDeregisterCaps; + m_scene.EventManager.OnSceneObjectLoaded -= OnSceneObjectLoaded; } - public void RegisterCaps(UUID agentID, Caps caps) + public void OnRegisterCaps(UUID agentID, Caps caps) { m_log.DebugFormat( "[MOAP]: Registering ObjectMedia and ObjectMediaNavigate capabilities for agent {0}", agentID); @@ -138,7 +140,7 @@ namespace OpenSim.Region.CoreModules.Media.Moap } } - public void DeregisterCaps(UUID agentID, Caps caps) + public void OnDeregisterCaps(UUID agentID, Caps caps) { lock (m_omCapUsers) { @@ -155,6 +157,11 @@ namespace OpenSim.Region.CoreModules.Media.Moap } } + public void OnSceneObjectLoaded(SceneObjectGroup sog) + { + m_log.DebugFormat("[MOAP]: OnSceneObjectLoaded fired for {0} {1}", sog.Name, sog.UUID); + } + 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 ef125cd..46e17c5 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -331,9 +331,16 @@ namespace OpenSim.Region.Framework.Scenes /// the avatarID is UUID.Zero (I know, this doesn't make much sense but now it's historical). public delegate void Attach(uint localID, UUID itemID, UUID avatarID); public event Attach OnAttach; + + public delegate void SceneObjectDelegate(SceneObjectGroup so); + + /// + /// Called immediately after an object is loaded from storage. + /// + public event SceneObjectDelegate OnSceneObjectLoaded; public delegate void RegionUp(GridRegion region); - public event RegionUp OnRegionUp; + public event RegionUp OnRegionUp; public class MoneyTransferArgs : EventArgs { @@ -2013,5 +2020,26 @@ namespace OpenSim.Region.Framework.Scenes } } } + + public void TriggerOnSceneObjectLoaded(SceneObjectGroup so) + { + SceneObjectDelegate handler = OnSceneObjectLoaded; + if (handler != null) + { + foreach (SceneObjectDelegate d in handler.GetInvocationList()) + { + try + { + d(so); + } + catch (Exception e) + { + m_log.ErrorFormat( + "[EVENT MANAGER]: Delegate for TriggerOnSceneObjectLoaded failed - continuing. {0} {1}", + e.Message, e.StackTrace); + } + } + } + } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index e2ab643..5542a0c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1887,9 +1887,11 @@ namespace OpenSim.Region.Framework.Scenes foreach (SceneObjectGroup group in PrimsFromDB) { + EventManager.TriggerOnSceneObjectLoaded(group); + if (group.RootPart == null) { - m_log.ErrorFormat("[SCENE] Found a SceneObjectGroup with m_rootPart == null and {0} children", + m_log.ErrorFormat("[SCENE]: Found a SceneObjectGroup with m_rootPart == null and {0} children", group.Children == null ? 0 : group.Children.Count); } -- cgit v1.1