Add EventManager.OnSceneObjectLoaded() for future use. This is fired immediately after a scene object is loaded from storage.

prebuild-update
Justin Clark-Casey (justincc) 2010-07-26 20:13:26 +01:00
parent afdbeba4e4
commit 586ae0f6a0
3 changed files with 46 additions and 9 deletions

View File

@ -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;

View File

@ -332,6 +332,13 @@ namespace OpenSim.Region.Framework.Scenes
public delegate void Attach(uint localID, UUID itemID, UUID avatarID);
public event Attach OnAttach;
public delegate void SceneObjectDelegate(SceneObjectGroup so);
/// <summary>
/// Called immediately after an object is loaded from storage.
/// </summary>
public event SceneObjectDelegate OnSceneObjectLoaded;
public delegate void RegionUp(GridRegion region);
public event RegionUp OnRegionUp;
@ -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);
}
}
}
}
}
}

View File

@ -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);
}