/// <summary>
        ///     Handles piping the proper stuff to The script engine for touching
        ///     Including DetectedParams
        /// </summary>
        /// <param name="part"></param>
        /// <param name="child"></param>
        /// <param name="offsetPos"></param>
        /// <param name="remoteClient"></param>
        /// <param name="surfaceArgs"></param>
        public void touch_start(ISceneChildEntity part, ISceneChildEntity child, Vector3 offsetPos,
                                IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs)
        {
            // Add to queue for all scripts in ObjectID object
            Dictionary<UUID, DetectParams> det = new Dictionary<UUID, DetectParams>();
            if (!CoalescedTouchEvents.TryGetValue(part.LocalId, out det))
                det = new Dictionary<UUID, DetectParams>();

            DetectParams detparam = new DetectParams {Key = remoteClient.AgentId};

            detparam.Populate(part.ParentEntity.Scene);
            detparam.LinkNum = child.LinkNum;

            if (surfaceArgs != null)
            {
                detparam.SurfaceTouchArgs = surfaceArgs;
            }

            det[remoteClient.AgentId] = detparam;
            CoalescedTouchEvents[part.LocalId] = det;

            ScriptData[] datas = ScriptEngine.ScriptProtection.GetScripts(part.UUID);

            if (datas == null || datas.Length == 0)
                return;

            string functionName = "touch_start";
            object[] param = new Object[] {new LSL_Types.LSLInteger(det.Count)};

            foreach (ScriptData ID in datas)
            {
                m_scriptEngine.AddToScriptQueue(ID, functionName, new List<DetectParams>(det.Values).ToArray(),
                                                EventPriority.FirstStart, param);
            }
        }
        public void botTouchObject(string bot, string objectID)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.Moderate, "botTouchObject", m_host, "bot", m_itemID))
                return;
            SurfaceTouchEventArgs touchArgs = new SurfaceTouchEventArgs();

            IScenePresence sp = World.GetScenePresence(UUID.Parse(bot));
            if (sp == null)
                return;
            ISceneChildEntity child = World.GetSceneObjectPart(UUID.Parse(objectID));
            if (child == null)
                throw new Exception("Failed to find entity to touch");

            World.EventManager.TriggerObjectGrab(child.ParentEntity.RootChild, child, Vector3.Zero, sp.ControllingClient,
                                                 touchArgs);
            World.EventManager.TriggerObjectGrabbing(child.ParentEntity.RootChild, child, Vector3.Zero,
                                                     sp.ControllingClient, touchArgs);
            World.EventManager.TriggerObjectDeGrab(child.ParentEntity.RootChild, child, sp.ControllingClient, touchArgs);
        }
 public void TriggerObjectGrabbing(ISceneChildEntity part, ISceneChildEntity child, Vector3 offsetPos,
                                   IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs)
 {
     ObjectGrabDelegate handlerObjectGrabbing = OnObjectGrabbing;
     if (handlerObjectGrabbing != null)
     {
         foreach (ObjectGrabDelegate d in handlerObjectGrabbing.GetInvocationList())
         {
             try
             {
                 d(part, child, offsetPos, remoteClient, surfaceArgs);
             }
             catch (Exception e)
             {
                 MainConsole.Instance.ErrorFormat(
                     "[EVENT MANAGER]: Delegate for TriggerObjectGrabbing failed - continuing.  {0} {1}",
                     e, e.StackTrace);
             }
         }
     }
 }
        private void EventManager_OnObjectGrab(ISceneChildEntity part, ISceneChildEntity child, Vector3 offsetPos,
                                               IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs)
        {
            if (_OnTouchActive && m_localID == part.LocalId)
            {
                TouchEventArgs e = new TouchEventArgs
                                       {
                                           Avatar = new SPAvatar(m_rootScene, remoteClient.AgentId, m_security),
                                           TouchBiNormal = surfaceArgs.Binormal,
                                           TouchMaterialIndex = surfaceArgs.FaceIndex,
                                           TouchNormal = surfaceArgs.Normal,
                                           TouchPosition = surfaceArgs.Position,
                                           TouchST = new Vector2(surfaceArgs.STCoord.X, surfaceArgs.STCoord.Y),
                                           TouchUV = new Vector2(surfaceArgs.UVCoord.X, surfaceArgs.UVCoord.Y)
                                       };

                IObject sender = this;

                if (_OnTouch != null)
                    _OnTouch(sender, e);
            }
        }