Add generic EventManager.OnObjectAddedToScene and get PrimCountModule to listen for that rather than EventManager.OnParcelPrimCountAdd

OnParcelPrimCountAdd had the wrong semantics for the PrimCountModule - it was invoked for every entity in the scene, not just new ones, which would screw up the untainted count.
Extend automated test for this scenario.
This commit is contained in:
Justin Clark-Casey (justincc)
2011-03-23 21:50:56 +00:00
parent 9c979dd0fc
commit d011896341
5 changed files with 59 additions and 5 deletions

View File

@@ -242,7 +242,15 @@ namespace OpenSim.Region.Framework.Scenes
public delegate void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID);
public event EstateToolsSunUpdate OnEstateToolsSunUpdate;
/// <summary>
/// Triggered when an object is added to the scene.
/// </summary>
public event Action<SceneObjectGroup> OnObjectAddedToScene;
/// <summary>
/// Triggered when an object is removed from the scene.
/// </summary>
public delegate void ObjectBeingRemovedFromScene(SceneObjectGroup obj);
public event ObjectBeingRemovedFromScene OnObjectBeingRemovedFromScene;
@@ -345,6 +353,7 @@ namespace OpenSim.Region.Framework.Scenes
public delegate void Attach(uint localID, UUID itemID, UUID avatarID);
public event Attach OnAttach;
/// <summary>
/// Called immediately after an object is loaded from storage.
/// </summary>
@@ -800,6 +809,27 @@ namespace OpenSim.Region.Framework.Scenes
}
}
public void TriggerObjectAddedToScene(SceneObjectGroup obj)
{
Action<SceneObjectGroup> handler = OnObjectAddedToScene;
if (handler != null)
{
foreach (Action<SceneObjectGroup> d in handler.GetInvocationList())
{
try
{
d(obj);
}
catch (Exception e)
{
m_log.ErrorFormat(
"[EVENT MANAGER]: Delegate for TriggerObjectAddedToScene failed - continuing. {0} {1}",
e.Message, e.StackTrace);
}
}
}
}
public void TriggerObjectBeingRemovedFromScene(SceneObjectGroup obj)
{
ObjectBeingRemovedFromScene handlerObjectBeingRemovedFromScene = OnObjectBeingRemovedFromScene;