コード例 #1
0
        void EventManager_OnObjectGrabUpdate(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs)
        {
            // Add to queue for all scripts in ObjectID object
            DetectParams[] det = new DetectParams[1];
            det[0]     = new DetectParams();
            det[0].Key = remoteClient.AgentId;
            det[0].Populate(myScriptEngine.World);
            det[0].OffsetPos = offsetPos;

            if (originalID == 0)
            {
                SceneObjectPart part =
                    myScriptEngine.World.GetSceneObjectPart(localID);

                if (part == null)
                {
                    return;
                }

                det[0].LinkNum = part.LinkNum;
            }
            else
            {
                SceneObjectPart originalPart =
                    myScriptEngine.World.GetSceneObjectPart(originalID);
                det[0].LinkNum = originalPart.LinkNum;
            }
            if (surfaceArgs != null)
            {
                det[0].SurfaceTouchArgs = surfaceArgs;
            }

            myScriptEngine.UpdateTouchData(localID, det);
        }
コード例 #2
0
        public void touch_end(uint localID, uint originalID, IClientAPI remoteClient)
        {
            // Add to queue for all scripts in ObjectID object
            DetectParams[] det = new DetectParams[1];
            det[0]     = new DetectParams();
            det[0].Key = remoteClient.AgentId;
            det[0].Populate(myScriptEngine.World);

            if (originalID == 0)
            {
                SceneObjectPart part = myScriptEngine.World.GetSceneObjectPart(localID);
                if (part == null)
                {
                    return;
                }

                det[0].LinkNum = part.LinkNum;
            }
            else
            {
                SceneObjectPart originalPart = myScriptEngine.World.GetSceneObjectPart(originalID);
                det[0].LinkNum = originalPart.LinkNum;
            }

            myScriptEngine.PostObjectEvent(localID, new EventParams(
                                               "touch_end", new Object[] { new LSL_Types.LSLInteger(1) },
                                               det));
        }
コード例 #3
0
        private void OnObjectGrab(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs)
        {
            // Add to queue for all scripts in ObjectID object
            DetectParams[] det = new DetectParams[1];
            det[0]     = new DetectParams();
            det[0].Key = remoteClient.AgentId;
            //det[0].Populate(World);

            if (originalID == 0)
            {
                SceneObjectPart part =
                    CurrentRegion.Scene.GetSceneObjectPart(localID);

                if (part == null)
                {
                    return;
                }

                det[0].LinkNum = part.LinkNum;
            }
            else
            {
                SceneObjectPart originalPart =
                    CurrentRegion.Scene.GetSceneObjectPart(originalID);
                det[0].LinkNum = originalPart.LinkNum;
            }
            if (surfaceArgs != null)
            {
                det[0].SurfaceTouchArgs = surfaceArgs;
            }
            Shared.EventParams ep =
                new Shared.EventParams(localID, "touch_start", new Object[] { new LSL_Types.LSLInteger(1) }, det);
            CurrentRegion.Executors_Execute(ep);
        }
コード例 #4
0
        private void collisions(uint localID, ColliderArgs col, string eventname)
        {
            int dc = col.Colliders.Count;

            if (dc > 0)
            {
                DetectParams[] det = new DetectParams[dc];
                int            i   = 0;
                foreach (DetectedObject detobj in col.Colliders)
                {
                    DetectParams d = new DetectParams();
                    det[i++] = d;

                    d.Key = detobj.keyUUID;
                    d.Populate(this.World);

                    /* not done by XEngine...
                     * d.Position = detobj.posVector;
                     * d.Rotation = detobj.rotQuat;
                     * d.Velocity = detobj.velVector;
                     * ... */
                }

                this.PostObjectEvent(localID, new EventParams(
                                         eventname,
                                         new Object[] { dc },
                                         det));
            }
        }
コード例 #5
0
        public void touch(uint localID, uint originalID, Vector3 offsetPos,
                          IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs)
        {
            // Add to queue for all scripts in ObjectID object
            DetectParams[] det = new DetectParams[1];
            det[0]     = new DetectParams();
            det[0].Key = remoteClient.AgentId;
            det[0].Populate(myScriptEngine.World);
            det[0].OffsetPos = offsetPos;

            if (originalID == 0)
            {
                SceneObjectPart part = myScriptEngine.World.GetSceneObjectPart(localID);
                if (part == null)
                {
                    return;
                }

                det[0].LinkNum = part.LinkNum;
            }
            else
            {
                SceneObjectPart originalPart = myScriptEngine.World.GetSceneObjectPart(originalID);
                det[0].LinkNum = originalPart.LinkNum;
            }
            if (surfaceArgs != null)
            {
                det[0].SurfaceTouchArgs = surfaceArgs;
            }

            myScriptEngine.PostObjectEvent(localID, new EventParams(
                                               "touch", new Object[] { new LSL_Types.LSLInteger(1) },
                                               det));
        }
コード例 #6
0
ファイル: XMRInstBackend.cs プロジェクト: osCore2/osCore2-1
        private static object[] DetPrmsToObjArr(DetectParams[] dps)
        {
            int len = dps.Length;

            object[] obs = new object[len * 16 + 1];
            int      j   = 0;

            obs[j++] = (LSL_Integer)saveDPVer;
            for (int i = 0; i < len; i++)
            {
                DetectParams dp = dps[i];
                obs[j++] = (LSL_String)dp.Key.ToString();    // UUID
                obs[j++] = dp.OffsetPos;                     // vector
                obs[j++] = (LSL_Integer)dp.LinkNum;          // integer
                obs[j++] = (LSL_String)dp.Group.ToString();  // UUID
                obs[j++] = (LSL_String)dp.Name;              // string
                obs[j++] = (LSL_String)dp.Owner.ToString();  // UUID
                obs[j++] = dp.Position;                      // vector
                obs[j++] = dp.Rotation;                      // rotation
                obs[j++] = (LSL_Integer)dp.Type;             // integer
                obs[j++] = dp.Velocity;                      // vector
                obs[j++] = dp.TouchST;                       // vector
                obs[j++] = dp.TouchNormal;                   // vector
                obs[j++] = dp.TouchBinormal;                 // vector
                obs[j++] = dp.TouchPos;                      // vector
                obs[j++] = dp.TouchUV;                       // vector
                obs[j++] = (LSL_Integer)dp.TouchFace;        // integer
            }
            return(obs);
        }
コード例 #7
0
        /// <summary>
        /// When an object gets paid by an avatar and generates the paid event,
        /// this will pipe it to the script engine
        /// </summary>
        /// <param name="objectID">Object ID that got paid</param>
        /// <param name="agentID">Agent Id that did the paying</param>
        /// <param name="amount">Amount paid</param>
        private void HandleObjectPaid(UUID objectID, UUID agentID,
                                      int amount)
        {
            // Add to queue for all scripts in ObjectID object
            DetectParams[] det = new DetectParams[1];
            det[0]     = new DetectParams();
            det[0].Key = agentID;
            det[0].Populate(this.World);

            // Since this is an event from a shared module, all scenes will
            // get it. But only one has the object in question. The others
            // just ignore it.
            //
            SceneObjectPart part = World.GetSceneObjectPart(objectID);

            if (part == null)
            {
                return;
            }

            if ((part.ScriptEvents & scriptEvents.money) == 0)
            {
                part = part.ParentGroup.RootPart;
            }

            Verbose("Paid: " + objectID + " from " + agentID + ", amount " + amount);

            if (part != null)
            {
                money(part.LocalId, agentID, amount, det);
            }
        }
コード例 #8
0
        public string cmDetectedCountry(int number)
        {
            m_host.AddScriptLPS(1);
            if (!m_CMFunctionsEnabled)
            {
                return(String.Empty);
            }
            if (World.UserAccountService == null)
            {
                return(String.Empty);
            }
            DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);

            if (detectedParams == null)
            {
                return(String.Empty);
            }
            UUID key = detectedParams.Key;

            if (key == UUID.Zero)
            {
                return(String.Empty);
            }
            UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, key);

            return(account.UserCountry);
        }
コード例 #9
0
        private static XmlElement GetXMLDetect(XmlDocument doc, DetectParams d)
        {
            XmlElement detectParamsN = doc.CreateElement("", "DetectParams", "");

            XmlAttribute d_key = doc.CreateAttribute("", "key", "");

            d_key.Value = d.Key.ToString();
            detectParamsN.Attributes.Append(d_key);

            XmlAttribute pos = doc.CreateAttribute("", "pos", "");

            pos.Value = d.OffsetPos.ToString();
            detectParamsN.Attributes.Append(pos);

            XmlAttribute d_linkNum = doc.CreateAttribute("", "linkNum", "");

            d_linkNum.Value = d.LinkNum.ToString();
            detectParamsN.Attributes.Append(d_linkNum);

            XmlAttribute d_group = doc.CreateAttribute("", "group", "");

            d_group.Value = d.Group.ToString();
            detectParamsN.Attributes.Append(d_group);

            XmlAttribute d_name = doc.CreateAttribute("", "name", "");

            d_name.Value = d.Name.ToString();
            detectParamsN.Attributes.Append(d_name);

            XmlAttribute d_owner = doc.CreateAttribute("", "owner", "");

            d_owner.Value = d.Owner.ToString();
            detectParamsN.Attributes.Append(d_owner);

            XmlAttribute d_position = doc.CreateAttribute("", "position", "");

            d_position.Value = d.Position.ToString();
            detectParamsN.Attributes.Append(d_position);

            XmlAttribute d_rotation = doc.CreateAttribute("", "rotation", "");

            d_rotation.Value = d.Rotation.ToString();
            detectParamsN.Attributes.Append(d_rotation);

            XmlAttribute d_type = doc.CreateAttribute("", "type", "");

            d_type.Value = d.Type.ToString();
            detectParamsN.Attributes.Append(d_type);

            XmlAttribute d_velocity = doc.CreateAttribute("", "velocity", "");

            d_velocity.Value = d.Velocity.ToString();
            detectParamsN.Attributes.Append(d_velocity);

            return(detectParamsN);
        }
コード例 #10
0
ファイル: XMRInstBackend.cs プロジェクト: osCore2/xmrengine
        /**
         * @brief The script is calling one of the llDetected...(int number)
         *        functions.  Return corresponding DetectParams pointer.
         */
        public DetectParams GetDetectParams(int number)
        {
            DetectParams dp = null;

            if ((number >= 0) && (m_DetectParams != null) && (number < m_DetectParams.Length))
            {
                dp = m_DetectParams[number];
            }
            return(dp);
        }
コード例 #11
0
ファイル: CM_Api.cs プロジェクト: MandarinkaTasty/OpenSim
        public string cmDetectedCountry(int number)
        {
            m_host.AddScriptLPS(1);
            DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, number);

            if (detectedParams == null)
            {
                return(String.Empty);
            }
            return(detectedParams.Country);
        }
コード例 #12
0
        public void money(SceneObjectPart part, UUID agentID, int amount, int paidLinkNum)
        {
            DetectParams[] det = new DetectParams[1];
            det[0]         = new DetectParams();
            det[0].Key     = agentID;
            det[0].LinkNum = paidLinkNum;

            myScriptEngine.PostObjectEvent(part.LocalId, new EventParams(
                                               "money", new object[] {
                agentID.ToString(),
                amount
            },
                                               det));
        }
コード例 #13
0
        private void touches(uint localID, uint originalID, Vector3 offsetPos,
                             IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs, string eventname)
        {
            if (m_Exiting)
            {
                return;
            }

            SceneObjectPart part = World.GetSceneObjectPart(localID);

            if (part == null || part.IsDeleted)
            {
                return;
            }

            int linknum;

            if (originalID != 0 && originalID != localID)
            {
                SceneObjectPart srcpart = World.GetSceneObjectPart(originalID);
                if (srcpart == null || part.IsDeleted)
                {
                    return;
                }
                linknum = srcpart.LinkNum;
            }
            else
            {
                linknum = part.LinkNum;
            }

            DetectParams det = new DetectParams();

            det.Key = remoteClient.AgentId;
            det.Populate(World);
            det.OffsetPos = new LSL_Vector(offsetPos.X,
                                           offsetPos.Y,
                                           offsetPos.Z);
            det.LinkNum = linknum;

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

            // Add to queue for all scripts in ObjectID object
            PostPrimEvent(part, new EventParams(
                              eventname, oneObjectArrayOne,
                              new DetectParams[] { det }));
        }
コード例 #14
0
        public void land_collision_end(uint localID, ColliderArgs col)
        {
            List <DetectParams> det = new List <DetectParams>();

            foreach (DetectedObject detobj in col.Colliders)
            {
                DetectParams d = new DetectParams();
                d.Populate(myScriptEngine.World, detobj);
                det.Add(d);
                myScriptEngine.PostObjectEvent(localID, new EventParams(
                                                   "land_collision_end",
                                                   new Object[] { new LSL_Types.Vector3(d.Position) },
                                                   det.ToArray()));
            }
        }
コード例 #15
0
        public LSL_Integer llDetectedType(int number)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
            {
                return(new LSL_Integer());
            }

            DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_host.UUID, m_itemID, number);

            if (detectedParams == null)
            {
                return(0);
            }
            return(new LSL_Integer(detectedParams.Type));
        }
コード例 #16
0
        public LSL_Rotation llDetectedRot(int number)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
            {
                return(new LSL_Rotation());
            }

            DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_host.UUID, m_itemID, number);

            if (detectedParams == null)
            {
                return(new LSL_Rotation());
            }
            return(detectedParams.Rotation);
        }
コード例 #17
0
        /// <summary>
        ///     See http://wiki.secondlife.com/wiki/LlDetectedTouchFace for details
        /// </summary>
        public LSL_Integer llDetectedTouchFace(int index)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
            {
                return(new LSL_Integer());
            }

            DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_host.UUID, m_itemID, index);

            if (detectedParams == null)
            {
                return(new LSL_Integer(-1));
            }
            return(new LSL_Integer(detectedParams.TouchFace));
        }
コード例 #18
0
        /// <summary>
        ///     See http://wiki.secondlife.com/wiki/LlDetectedTouchUV for details
        /// </summary>
        public LSL_Vector llDetectedTouchUV(int index)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
            {
                return(new LSL_Vector());
            }

            DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_host.UUID, m_itemID, index);

            if (detectedParams == null)
            {
                return(new LSL_Vector(-1.0, -1.0, 0.0));
            }
            return(detectedParams.TouchUV);
        }
コード例 #19
0
        public LSL_String llDetectedKey(int number)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
            {
                return(new LSL_String());
            }

            DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_host.UUID, m_itemID, number);

            if (detectedParams == null)
            {
                return(string.Empty);
            }
            return(detectedParams.Key.ToString());
        }
コード例 #20
0
        public LSL_Vector llDetectedGrab(int number)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
            {
                return(new LSL_Vector());
            }

            DetectParams parms = m_ScriptEngine.GetDetectParams(m_host.UUID, m_itemID, number);

            if (parms == null)
            {
                return(new LSL_Vector(0, 0, 0));
            }

            return(parms.OffsetPos);
        }
コード例 #21
0
        public void collision(uint localID, ColliderArgs col)
        {
            // Add to queue for all scripts in ObjectID object
            List <DetectParams> det = new List <DetectParams>();

            foreach (DetectedObject detobj in col.Colliders)
            {
                DetectParams d = DetectParams.FromDetectedObject(detobj);
                det.Add(d);
            }

            if (det.Count > 0)
            {
                myScriptEngine.PostObjectEvent(localID, new EventParams(
                                                   "collision", new Object[] { det.Count },
                                                   det.ToArray()));
            }
        }
コード例 #22
0
ファイル: XMRInstBackend.cs プロジェクト: osCore2/xmrengine
        private static DetectParams[] ObjArrToDetPrms(object[] objs)
        {
            int j = 0;

            if ((objs.Length % 16 != 1) || (ListInt(objs[j++]) != saveDPVer))
            {
                throw new Exception("invalid detect param format");
            }

            int len = objs.Length / 16;

            DetectParams[] dps = new DetectParams[len];

            for (int i = 0; i < len; i++)
            {
                DetectParams dp = new DetectParams();

                dp.Key       = new UUID(ListStr(objs[j++]));
                dp.OffsetPos = (LSL_Vector)objs[j++];
                dp.LinkNum   = ListInt(objs[j++]);
                dp.Group     = new UUID(ListStr(objs[j++]));
                dp.Name      = ListStr(objs[j++]);
                dp.Owner     = new UUID(ListStr(objs[j++]));
                dp.Position  = (LSL_Vector)objs[j++];
                dp.Rotation  = (LSL_Rotation)objs[j++];
                dp.Type      = ListInt(objs[j++]);
                dp.Velocity  = (LSL_Vector)objs[j++];

                SurfaceTouchEventArgs stea = new SurfaceTouchEventArgs();

                stea.STCoord   = LSLVec2OMVec((LSL_Vector)objs[j++]);
                stea.Normal    = LSLVec2OMVec((LSL_Vector)objs[j++]);
                stea.Binormal  = LSLVec2OMVec((LSL_Vector)objs[j++]);
                stea.Position  = LSLVec2OMVec((LSL_Vector)objs[j++]);
                stea.UVCoord   = LSLVec2OMVec((LSL_Vector)objs[j++]);
                stea.FaceIndex = ListInt(objs[j++]);

                dp.SurfaceTouchArgs = stea;

                dps[i] = dp;
            }

            return(dps);
        }
コード例 #23
0
        public void collision(uint localID, ColliderArgs col)
        {
            // Add to queue for all scripts in ObjectID object
            List <DetectParams> det = new List <DetectParams>();

            foreach (DetectedObject detobj in col.Colliders)
            {
                DetectParams d = new DetectParams();
                d.Populate(myScriptEngine.World, detobj);
                det.Add(d);
            }

            if (det.Count > 0)
            {
                myScriptEngine.PostObjectEvent(localID, new EventParams(
                                                   "collision", new Object[] { new LSL_Types.LSLInteger(det.Count) },
                                                   det.ToArray()));
            }
        }
コード例 #24
0
        public DateTime llMapDestination(string simname, LSL_Vector pos, LSL_Vector lookAt)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID))
            {
                return(DateTime.Now);
            }

            UUID         avatarID       = m_host.OwnerID;
            DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_host.UUID, m_itemID, 0);

            // only works on the first detected avatar
            //This only works in touch events or if the item is attached to the avatar
            if (detectedParams == null && !m_host.IsAttachment)
            {
                return(DateTime.Now);
            }

            if (detectedParams != null)
            {
                avatarID = detectedParams.Key;
            }

            IScenePresence avatar = World.GetScenePresence(avatarID);

            if (avatar != null)
            {
                IMuteListModule module = m_host.ParentEntity.Scene.RequestModuleInterface <IMuteListModule>();
                if (module != null)
                {
                    bool cached = false; //Unneeded
                    if (module.GetMutes(avatar.UUID, out cached).Any(mute => mute.MuteID == m_host.OwnerID))
                    {
                        return(DateTime.Now); //If the avatar is muted, they don't get any contact from the muted av
                    }
                }
                avatar.ControllingClient.SendScriptTeleportRequest(m_host.Name, simname,
                                                                   new Vector3((float)pos.x, (float)pos.y,
                                                                               (float)pos.z),
                                                                   new Vector3((float)lookAt.x, (float)lookAt.y,
                                                                               (float)lookAt.z));
            }
            return(PScriptSleep(m_sleepMsOnMapDestination));
        }
コード例 #25
0
        /**
         * @brief Read llDetectedGrab, etc, values from XML
         *  <DetectArray>
         *      <DetectParams>...</DetectParams>
         *          .
         *          .
         *          .
         *  </DetectArray>
         */
        private DetectParams[] RestoreDetectParams(XmlNode detectedN)
        {
            if (detectedN == null)
            {
                return(null);
            }

            List <DetectParams> detected = new List <DetectParams>();
            XmlNodeList         detectL  = detectedN.SelectNodes("DetectParams");

            DetectParams detprm = new DetectParams();

            foreach (XmlNode detxml in detectL)
            {
                try
                {
                    detprm.Group = new UUID(detxml.Attributes.GetNamedItem("group").Value);
                    detprm.Key   = new UUID(detxml.Attributes.GetNamedItem("key").Value);
                    detprm.Owner = new UUID(detxml.Attributes.GetNamedItem("owner").Value);

                    detprm.LinkNum = Int32.Parse(detxml.Attributes.GetNamedItem("linkNum").Value);
                    detprm.Type    = Int32.Parse(detxml.Attributes.GetNamedItem("type").Value);

                    detprm.Name = detxml.Attributes.GetNamedItem("name").Value;

                    detprm.OffsetPos = new LSL_Types.Vector3(detxml.Attributes.GetNamedItem("pos").Value);
                    detprm.Position  = new LSL_Types.Vector3(detxml.Attributes.GetNamedItem("position").Value);
                    detprm.Velocity  = new LSL_Types.Vector3(detxml.Attributes.GetNamedItem("velocity").Value);

                    detprm.Rotation = new LSL_Types.Quaternion(detxml.Attributes.GetNamedItem("rotation").Value);

                    detected.Add(detprm);
                    detprm = new DetectParams();
                }
                catch (Exception e)
                {
                    m_log.Warn("[YEngine]: RestoreDetectParams bad XML: " + detxml.ToString());
                    m_log.Warn("[YEngine]: ... " + e.ToString());
                }
            }

            return(detected.ToArray());
        }
コード例 #26
0
 public void changed(uint localID, uint change, object parameter)
 {
     // Add to queue for all scripts in localID, Object pass change.
     if (parameter == null)
     {
         myScriptEngine.PostObjectEvent(localID, new EventParams(
                                            "changed", new object[] { new LSL_Types.LSLInteger(change) },
                                            new DetectParams[0]));
         return;
     }
     if (parameter is UUID)
     {
         DetectParams det = new DetectParams();
         det.Key = (UUID)parameter;
         myScriptEngine.PostObjectEvent(localID, new EventParams(
                                            "changed", new object[] { new LSL_Types.LSLInteger(change) },
                                            new DetectParams[] { det }));
         return;
     }
 }
コード例 #27
0
        public void collision(uint localID, ColliderArgs col)
        {
            // Add to queue for all scripts in ObjectID object
            List <DetectParams> det = new List <DetectParams>();

            foreach (DetectedObject detobj in col.Colliders)
            {
                DetectParams d = new DetectParams();
                d.Key = detobj.keyUUID;
                d.Populate(myScriptEngine.World);
                d.LinkNum = detobj.linkNumber; // do it here since currently linknum is collided part
                det.Add(d);
            }

            if (det.Count > 0)
            {
                myScriptEngine.PostObjectEvent(localID, new EventParams(
                                                   "collision", new Object[] { new LSL_Types.LSLInteger(det.Count) },
                                                   det.ToArray()));
            }
        }
コード例 #28
0
        public void changed(uint localID, uint change, object parameter)
        {
            int ch = (int)change;

            // Add to queue for all scripts in localID, Object pass change.
            if (parameter == null)
            {
                PostObjectEvent(localID, new EventParams(
                                    "changed", new object[] { ch },
                                    zeroDetectParams));
                return;
            }
            if (parameter is UUID)
            {
                DetectParams det = new DetectParams();
                det.Key = (UUID)parameter;
                PostObjectEvent(localID, new EventParams(
                                    "changed", new object[] { ch },
                                    new DetectParams[] { det }));
                return;
            }
        }
コード例 #29
0
        private void collisions(uint localID, ColliderArgs col, string eventname)
        {
            int dc = col.Colliders.Count;

            if (dc > 0)
            {
                DetectParams[] det = new DetectParams[dc];
                int            i   = 0;
                foreach (DetectedObject detobj in col.Colliders)
                {
                    DetectParams d = new DetectParams();
                    det[i++] = d;

                    d.Key = detobj.keyUUID;
                    d.Populate(World, detobj);
                }

                this.PostObjectEvent(localID, new EventParams(
                                         eventname,
                                         new Object[] { dc },
                                         det));
            }
        }
コード例 #30
0
        private void touches(uint localID, uint originalID, Vector3 offsetPos,
                             IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs, string eventname)
        {
            SceneObjectPart part;

            if (originalID == 0)
            {
                part = this.World.GetSceneObjectPart(localID);
                if (part == null)
                {
                    return;
                }
            }
            else
            {
                part = this.World.GetSceneObjectPart(originalID);
            }

            DetectParams det = new DetectParams();

            det.Key = remoteClient.AgentId;
            det.Populate(this.World);
            det.OffsetPos = new LSL_Vector(offsetPos.X,
                                           offsetPos.Y,
                                           offsetPos.Z);
            det.LinkNum = part.LinkNum;

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

            // Add to queue for all scripts in ObjectID object
            this.PostObjectEvent(localID, new EventParams(
                                     eventname, oneObjectArrayOne,
                                     new DetectParams[] { det }));
        }
コード例 #31
0
        public static void Deserialize(string xml, ScriptInstance instance)
        {
            XmlDocument doc = new XmlDocument();

            Dictionary<string, object> vars = instance.GetVars();

            instance.PluginData = new Object[0];

            // Avoid removal of whitepace from LSL string vars
            doc.PreserveWhitespace = true;
            doc.LoadXml(xml);

            XmlNodeList rootL = doc.GetElementsByTagName("ScriptState");
            if (rootL.Count != 1)
            {
                return;
            }
            XmlNode rootNode = rootL[0];

            if (rootNode != null)
            {
                object varValue;
                XmlNodeList partL = rootNode.ChildNodes;

                foreach (XmlNode part in partL)
                {
                    switch (part.Name)
                    {
                    case "State":
                        instance.State=part.InnerText;
                        break;
                    case "Running":
                        instance.Running=bool.Parse(part.InnerText);
                        break;
                    case "Variables":
                        XmlNodeList varL = part.ChildNodes;
                        foreach (XmlNode var in varL)
                        {
                            string varName;
                            varValue=ReadTypedValue(var, out varName);

                            if (vars.ContainsKey(varName))
                            {
                                vars[varName] = varValue;
                            }
                        }
                        instance.SetVars(vars);
                        break;
                    case "Queue":
                        XmlNodeList itemL = part.ChildNodes;
                        foreach (XmlNode item in itemL)
                        {
                            List<Object> parms = new List<Object>();
                            List<DetectParams> detected =
                                    new List<DetectParams>();

                            string eventName =
                                    item.Attributes.GetNamedItem("event").Value;
                            XmlNodeList eventL = item.ChildNodes;
                            foreach (XmlNode evt in eventL)
                            {
                                switch (evt.Name)
                                {
                                case "Params":
                                    XmlNodeList prms = evt.ChildNodes;
                                    foreach (XmlNode pm in prms)
                                        parms.Add(ReadTypedValue(pm));

                                    break;
                                case "Detected":
                                    XmlNodeList detL = evt.ChildNodes;
                                    foreach (XmlNode det in detL)
                                    {
                                        string vect =
                                                det.Attributes.GetNamedItem(
                                                "pos").Value;
                                        LSL_Types.Vector3 v =
                                                new LSL_Types.Vector3(vect);

                                        int d_linkNum=0;
                                        UUID d_group = UUID.Zero;
                                        string d_name = String.Empty;
                                        UUID d_owner = UUID.Zero;
                                        LSL_Types.Vector3 d_position =
                                            new LSL_Types.Vector3();
                                        LSL_Types.Quaternion d_rotation =
                                            new LSL_Types.Quaternion();
                                        int d_type = 0;
                                        LSL_Types.Vector3 d_velocity =
                                            new LSL_Types.Vector3();

                                        try
                                        {
                                            string tmp;

                                            tmp = det.Attributes.GetNamedItem(
                                                    "linkNum").Value;
                                            int.TryParse(tmp, out d_linkNum);

                                            tmp = det.Attributes.GetNamedItem(
                                                    "group").Value;
                                            UUID.TryParse(tmp, out d_group);

                                            d_name = det.Attributes.GetNamedItem(
                                                    "name").Value;

                                            tmp = det.Attributes.GetNamedItem(
                                                    "owner").Value;
                                            UUID.TryParse(tmp, out d_owner);

                                            tmp = det.Attributes.GetNamedItem(
                                                    "position").Value;
                                            d_position =
                                                new LSL_Types.Vector3(tmp);

                                            tmp = det.Attributes.GetNamedItem(
                                                    "rotation").Value;
                                            d_rotation =
                                                new LSL_Types.Quaternion(tmp);

                                            tmp = det.Attributes.GetNamedItem(
                                                    "type").Value;
                                            int.TryParse(tmp, out d_type);

                                            tmp = det.Attributes.GetNamedItem(
                                                    "velocity").Value;
                                            d_velocity =
                                                new LSL_Types.Vector3(tmp);

                                        }
                                        catch (Exception) // Old version XML
                                        {
                                        }

                                        UUID uuid = new UUID();
                                        UUID.TryParse(det.InnerText,
                                                out uuid);

                                        DetectParams d = new DetectParams();
                                        d.Key = uuid;
                                        d.OffsetPos = v;
                                        d.LinkNum = d_linkNum;
                                        d.Group = d_group;
                                        d.Name = d_name;
                                        d.Owner = d_owner;
                                        d.Position = d_position;
                                        d.Rotation = d_rotation;
                                        d.Type = d_type;
                                        d.Velocity = d_velocity;

                                        detected.Add(d);
                                    }
                                    break;
                                }
                            }
                            EventParams ep = new EventParams(
                                    eventName, parms.ToArray(),
                                    detected.ToArray());
                            instance.EnqueueEvent(ep);
                        }
                        break;
                    case "Plugins":
                        instance.PluginData = ReadList(part).Data;
                        break;
                    case "Permissions":
                        string tmpPerm;
                        int mask = 0;
                        tmpPerm = part.Attributes.GetNamedItem("mask").Value;
                        if (tmpPerm != null)
                        {
                            int.TryParse(tmpPerm, out mask);
                            if (mask != 0)
                            {
                                tmpPerm = part.Attributes.GetNamedItem("granter").Value;
                                if (tmpPerm != null)
                                {
                                    UUID granter = new UUID();
                                    UUID.TryParse(tmpPerm, out granter);
                                    if (granter != UUID.Zero)
                                    {
                                        instance.ScriptTask.PermsMask = mask;
                                        instance.ScriptTask.PermsGranter = granter;
                                    }
                                }
                            }
                        }
                        break;
                    case "MinEventDelay":
                        double minEventDelay = 0.0;
                        double.TryParse(part.InnerText, NumberStyles.Float, Culture.NumberFormatInfo, out minEventDelay);
                        instance.MinEventDelay = minEventDelay;
                        break;
                }
              }
            }
        }
コード例 #32
0
ファイル: Objects.cs プロジェクト: osgrid/openmetaverse
        void ObjectDeGrabHandler(Packet packet, LLAgent agent)
        {
            ObjectDeGrabPacket degrab = (ObjectDeGrabPacket)packet;

            ISceneEntity entity;
            if (m_scene.TryGetEntity(degrab.ObjectData.LocalID, out entity))
            {
                if (m_lslScriptEngine != null)
                {
                    //TODO: change 1 to real count
                    List<DetectParams> touches = new List<DetectParams>(1);
                    DetectParams detect = new DetectParams();
                    detect.Name = agent.Name;
                    detect.Key = agent.ID;
                    detect.Owner = agent.OwnerID;
                    detect.Group = agent.GroupID;
                    touches.Add(detect);

                    m_lslScriptEngine.PostObjectEvent(entity.ID, "touch_end", new object[] { 1 }, touches.ToArray());
                }
            }
        }
コード例 #33
0
ファイル: Objects.cs プロジェクト: osgrid/openmetaverse
        void ObjectGrabHandler(Packet packet, LLAgent agent)
        {
            ObjectGrabPacket grab = (ObjectGrabPacket)packet;

            ISceneEntity entity;
            if (m_scene.TryGetEntity(grab.ObjectData.LocalID, out entity))
            {
                List<DetectParams> touches = new List<DetectParams>(grab.SurfaceInfo.Length);
                bool held = false;

                for (int i = 0; i < grab.SurfaceInfo.Length; i++)
                {
                    ObjectGrabPacket.SurfaceInfoBlock block = grab.SurfaceInfo[i];

                    DetectParams touch = new DetectParams();
                    touch.Group = entity.GroupID;
                    touch.Key = entity.ID;
                    if (entity is ILinkable) touch.LinkNum = ((ILinkable)entity).LinkNumber;
                    touch.Name = entity.Name;
                    //touch.Offset = Vector3.Zero;
                    touch.Owner = entity.OwnerID;
                    touch.Position = entity.RelativePosition;
                    touch.Rotation = entity.RelativeRotation;
                    touch.TouchBinormal = block.Binormal;
                    touch.TouchFace = block.FaceIndex;
                    touch.TouchNormal = block.Normal;
                    touch.TouchPos = block.Position;
                    touch.TouchST = block.STCoord;
                    touch.TouchUV = block.UVCoord;
                    if (entity is IPhysical) touch.Velocity = ((IPhysical)entity).Velocity;

                    // Set the active or passive flag based on the entity velocity
                    if (touch.Velocity != Vector3.Zero)
                    {
                        held = true;
                        touch.Type |= ACTIVE;
                    }
                    else
                    {
                        touch.Type |= PASSIVE;
                    }

                    // Is this an agent?
                    if (entity is IScenePresence)
                        touch.Type |= AGENT;

                    // Is this entity scripted?
                    if (entity is LLPrimitive)
                    {
                        LLPrimitive prim = (LLPrimitive)entity;
                        if (prim.Prim.Flags.HasFlag(PrimFlags.Scripted))
                            touch.Type |= SCRIPTED;
                    }

                    touches.Add(touch);
                }

                if (!held && m_lslScriptEngine != null)
                {
                    m_lslScriptEngine.PostObjectEvent(entity.ID, "touch_start", new object[] { 1 }, touches.ToArray());
                }
            }
        }
コード例 #34
0
ファイル: Objects.cs プロジェクト: osgrid/openmetaverse
        void ObjectGrabUpdateHandler(Packet packet, LLAgent agent)
        {
            ObjectGrabUpdatePacket update = (ObjectGrabUpdatePacket)packet;

            ISceneEntity entity;
            if (m_scene.TryGetEntity(update.ObjectData.ObjectID, out entity))
            {
                List<DetectParams> touches = new List<DetectParams>(update.SurfaceInfo.Length);
                for (int i = 0; i < update.SurfaceInfo.Length; i++)
                {
                    ObjectGrabUpdatePacket.SurfaceInfoBlock block = update.SurfaceInfo[i];

                    DetectParams touch = new DetectParams();
                    touch.Group = entity.GroupID;
                    touch.Key = entity.ID;
                    if (entity is ILinkable) touch.LinkNum = ((ILinkable)entity).LinkNumber;
                    touch.Name = entity.Name;
                    touch.Offset = update.ObjectData.GrabOffsetInitial;
                    touch.Owner = entity.OwnerID;
                    touch.Position = entity.RelativePosition;
                    touch.Rotation = entity.RelativeRotation;
                    touch.TouchBinormal = block.Binormal;
                    touch.TouchFace = block.FaceIndex;
                    touch.TouchNormal = block.Normal;
                    touch.TouchPos = block.Position;
                    touch.TouchST = block.STCoord;
                    touch.TouchUV = block.UVCoord;
                    if (entity is IPhysical) touch.Velocity = ((IPhysical)entity).Velocity;

                    // Set the active or passive flag based on the entity velocity
                    if (touch.Velocity != Vector3.Zero)
                        touch.Type |= ACTIVE;
                    else
                        touch.Type |= PASSIVE;
                    // Is this an agent?
                    if (entity is IScenePresence)
                        touch.Type |= AGENT;
                    // Is this entity scripted?
                    if (entity is LLPrimitive && (((LLPrimitive)entity).Prim.Flags & PrimFlags.Scripted) == PrimFlags.Scripted)
                        touch.Type |= SCRIPTED;

                    touches.Add(touch);
                }

                if (m_lslScriptEngine != null)
                {
                    m_lslScriptEngine.PostObjectEvent(entity.ID, "touch", new object[] { 1 }, touches.ToArray());
                }
            }
        }
コード例 #35
0
        void SensorSweep(SenseRepeatClass ts)
        {
            if (ts.host == null)
            {
                return;
            }

            List<SensedEntity> sensedEntities = new List<SensedEntity>();

            // Is the sensor type is AGENT and not SCRIPTED then include agents
            if ((ts.type & (AGENT | AGENT_BY_USERNAME)) != 0 && (ts.type & SCRIPTED) == 0)
            {
                sensedEntities.AddRange(doAgentSensor(ts));
            }

            // If SCRIPTED or PASSIVE or ACTIVE check objects
            if ((ts.type & SCRIPTED) != 0 || (ts.type & PASSIVE) != 0 || (ts.type & ACTIVE) != 0)
            {
                sensedEntities.AddRange(doObjectSensor(ts));
            }

            lock (SenseLock)
            {
                if (sensedEntities.Count == 0)
                {
                    // send a "no_sensor"
                    // Add it to queue
                    m_ScriptEngine.PostScriptEvent(ts.itemID, ts.objectID,
                                                   new EventParams("no_sensor", new object[0],
                                                                   new DetectParams[0]), EventPriority.Suspended);
                }
                else
                {
                    // Sort the list to get everything ordered by distance
                    sensedEntities.Sort();
                    int count = sensedEntities.Count;
                    int idx;
                    List<DetectParams> detected = new List<DetectParams>();
                    for (idx = 0; idx < count; idx++)
                    {
                        if (ts.host != null && ts.host.ParentEntity != null && ts.host.ParentEntity.Scene != null)
                        {
                            DetectParams detect = new DetectParams {Key = sensedEntities[idx].itemID};
                            detect.Populate(ts.host.ParentEntity.Scene);
                            detected.Add(detect);
                            if (detected.Count == maximumToReturn &&
                                usemaximumToReturn)
                                break;
                        }
                    }

                    if (detected.Count == 0)
                    {
                        // To get here with zero in the list there must have been some sort of problem
                        // like the object being deleted or the avatar leaving to have caused some
                        // difficulty during the Populate above so fire a no_sensor event
                        m_ScriptEngine.PostScriptEvent(ts.itemID, ts.objectID,
                                                       new EventParams("no_sensor", new object[0],
                                                                       new DetectParams[0]), EventPriority.Suspended);
                    }
                    else
                    {
                        m_ScriptEngine.PostScriptEvent(ts.itemID, ts.objectID,
                                                       new EventParams("sensor",
                                                                       new object[]
                                                                           {new LSL_Types.LSLInteger(detected.Count)},
                                                                       detected.ToArray()), EventPriority.Suspended);
                    }
                }
            }
        }
コード例 #36
0
        private void SensorSweep(SensorInfo ts)
        {
            if (ts.host == null)
            {
                return;
            }

            List<SensedEntity> sensedEntities = new List<SensedEntity>();

            // Is the sensor type is AGENT and not SCRIPTED then include agents
            if ((ts.type & (AGENT | AGENT_BY_USERNAME | NPC | OS_NPC)) != 0 && (ts.type & SCRIPTED) == 0)
            {
                sensedEntities.AddRange(doAgentSensor(ts));
            }

            // If SCRIPTED or PASSIVE or ACTIVE check objects
            if ((ts.type & SCRIPTED) != 0 || (ts.type & PASSIVE) != 0 || (ts.type & ACTIVE) != 0)
            {
                sensedEntities.AddRange(doObjectSensor(ts));
            }

            if (sensedEntities.Count == 0)
            {
                // send a "no_sensor"
                // Add it to queue
                m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID,
                        new EventParams("no_sensor", new Object[0],
                        new DetectParams[0]));
            }
            else
            {
                // Sort the list to get everything ordered by distance
                sensedEntities.Sort();
                int count = sensedEntities.Count;
                int idx;
                List<DetectParams> detected = new List<DetectParams>();
                for (idx = 0; idx < count; idx++)
                {
                    try
                    {
                        DetectParams detect = new DetectParams();
                        detect.Key = sensedEntities[idx].itemID;
                        detect.Populate(m_CmdManager.m_ScriptEngine.World);
                        detected.Add(detect);
                    }
                    catch (Exception)
                    {
                        // Ignore errors, the object has been deleted or the avatar has gone and
                        // there was a problem in detect.Populate so nothing added to the list
                    }
                    if (detected.Count == maximumToReturn)
                        break;
                }

                if (detected.Count == 0)
                {
                    // To get here with zero in the list there must have been some sort of problem
                    // like the object being deleted or the avatar leaving to have caused some
                    // difficulty during the Populate above so fire a no_sensor event
                    m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID,
                            new EventParams("no_sensor", new Object[0],
                            new DetectParams[0]));
                }
                else
                {
                    m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID,
                            new EventParams("sensor",
                            new Object[] {new LSL_Types.LSLInteger(detected.Count) },
                            detected.ToArray()));
                }
            }
        }