From 9ffe4d850e9ccf2fc40901e186af3d38c31b9a6d Mon Sep 17 00:00:00 2001 From: Alan Webb Date: Mon, 3 Aug 2009 21:43:08 -0400 Subject: This change adds support for the attach event in scripts. [1] Added a new OnAttach event to Scene/EventManager [2] Hooked up existing attach event handler in XEngine. [3] Modified SceneGraph and Scene.Inventory to trigger attach events at the appropriate places. I was forced to distribut the changes across two files because of the way attach processing is distributed across the two files. [4] In the case of RezSingleAttachmentFromInventory it is necessary to handle event scheduling in a special way. There is no synchronous path available, so the fact that this object is attached, and who it is attached to, is cached when the ScriptInstance is created. When the script is started, the attached handler is driven after on_rez (but before changed, this should be reviewed). Signed-off-by: dr scofield (aka dirk husemann) --- .../ScriptEngine/Shared/Instance/ScriptInstance.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 42d61a7..586f926 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -89,6 +89,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance private long m_eventDelayTicks = 0; private long m_nextEventTimeTicks = 0; private bool m_startOnInit = true; + private bool m_isAttachment = false; + private UUID m_attachedAvatar = UUID.Zero; private StateSource m_stateSource; private bool m_postOnRez; private bool m_startedFromSavedState = false; @@ -232,6 +234,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance m_MaxScriptQueue = maxScriptQueue; m_stateSource = stateSource; m_postOnRez = postOnRez; + m_isAttachment = part.IsAttachment; + m_attachedAvatar = part.AttachedAvatar; m_RegionID = part.ParentGroup.Scene.RegionInfo.RegionID; if (part != null) @@ -379,6 +383,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance new Object[] {new LSL_Types.LSLInteger(m_StartParam)}, new DetectParams[0])); } + if (m_isAttachment) + { + PostEvent(new EventParams("attach", + new object[] { new LSL_Types.LSLString(m_attachedAvatar.ToString()) }, new DetectParams[0])); + } + if (m_stateSource == StateSource.NewRez) { // m_log.Debug("[Script] Posted changed(CHANGED_REGION_RESTART) to script"); @@ -403,6 +413,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance new Object[] {new LSL_Types.LSLInteger(m_StartParam)}, new DetectParams[0])); } + if (m_isAttachment) + { + PostEvent(new EventParams("attach", + new object[] { new LSL_Types.LSLString(m_attachedAvatar.ToString()) }, new DetectParams[0])); + } + } } -- cgit v1.1