Esempio n. 1
0
 /// <summary>
 /// Sends a request to sit on the specified object
 /// </summary>
 /// <param name="targetID"><seealso cref="UUID"/> of the object to sit on</param>
 /// <param name="offset">Sit at offset</param>
 public void RequestSit(UUID targetID, Vector3 offset)
 {
     AgentRequestSitPacket requestSit = new AgentRequestSitPacket();
     requestSit.AgentData.AgentID = Client.Self.AgentID;
     requestSit.AgentData.SessionID = Client.Self.SessionID;
     requestSit.TargetObject.TargetID = targetID;
     requestSit.TargetObject.Offset = offset;
     Client.Network.SendPacket(requestSit);
 }
Esempio n. 2
0
        private void AgentRequestSitHandler(Packet packet, LLAgent agent)
        {
            AgentRequestSitPacket request = (AgentRequestSitPacket)packet;

            agent.RequestedSitTarget = request.TargetObject.TargetID;
            agent.RequestedSitOffset = request.TargetObject.Offset;

            //TODO: move to AgentSitHandler when we figure out how to make the client send AgentSit
            ISceneEntity seat;

            if (m_scene.TryGetEntity(agent.RequestedSitTarget, out seat) && seat is ILinkable)
            {
                agent.SetParent((ILinkable)seat, false, false);

                AvatarSitResponsePacket response = new AvatarSitResponsePacket();
                response.SitObject.ID = agent.RequestedSitTarget;

                if (seat is LLPrimitive)
                {
                    LLPrimitive prim = (LLPrimitive)seat;
                    if (prim.SitPosition != Vector3.Zero)
                    {
                        // llSitTarget is set

                        response.SitTransform.SitPosition = prim.SitPosition;
                        response.SitTransform.SitRotation = prim.SitRotation;

                        agent.RelativePosition = LLUtil.GetSitTarget(prim.SitPosition, agent.Scale);
                        agent.RelativeRotation = prim.SitRotation;
                    }
                    else
                    {
                        // No sit target set

                        Vector3 sitPos = LLUtil.GetSitTarget(agent.RequestedSitOffset, agent.Scale);

                        response.SitTransform.SitPosition = sitPos;
                        response.SitTransform.SitRotation = Quaternion.Identity;

                        agent.RelativePosition = sitPos;
                        agent.RelativeRotation = Quaternion.Identity;
                    }
                }

                m_udp.SendPacket(agent, response, ThrottleCategory.Task, false);

                m_scene.EntityAddOrUpdate(this, agent, UpdateFlags.Parent, 0);

                agent.Animations.SetDefaultAnimation(OpenMetaverse.Animations.SIT, 1);
                m_scene.SendPresenceAnimations(this, agent);

                if (m_lslScriptEngine != null)
                {
                    m_lslScriptEngine.PostObjectEvent(seat.ID, "changed", new object[] { CHANGED_LINK }, new DetectParams[0]);
                }
            }
            else
            {
                //TODO: send error message
            }
        }