diff --git a/OpenSim/Framework/General/Interfaces/IClientAPI.cs b/OpenSim/Framework/General/Interfaces/IClientAPI.cs index 0dad91f4ae..7cb18e5459 100644 --- a/OpenSim/Framework/General/Interfaces/IClientAPI.cs +++ b/OpenSim/Framework/General/Interfaces/IClientAPI.cs @@ -169,6 +169,8 @@ namespace OpenSim.Framework.Interfaces public delegate void StatusChange(bool status); public delegate void NewAvatar(IClientAPI remoteClient, LLUUID agentID, bool status); public delegate void UpdateAgent(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation); + public delegate void AgentRequestSit(IClientAPI remoteClient, LLUUID agentID, LLUUID targetID); + public delegate void AgentSit(IClientAPI remoteClient, LLUUID agentID); public delegate void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 grapPos, IClientAPI remoteClient); public delegate void ParcelPropertiesRequest(int start_x, int start_y, int end_x, int end_y, int sequence_id, bool snap_selection, IClientAPI remote_client); @@ -217,6 +219,8 @@ namespace OpenSim.Framework.Interfaces event GenericCall OnRequestWearables; event GenericCall2 OnCompleteMovementToRegion; event UpdateAgent OnAgentUpdate; + event AgentRequestSit OnAgentRequestSit; + event AgentSit OnAgentSit; event GenericCall OnRequestAvatarsData; event AddNewPrim OnAddPrim; event ObjectDuplicate OnObjectDuplicate; @@ -321,7 +325,7 @@ namespace OpenSim.Framework.Interfaces void SendTeleportLocationStart(); void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance); - void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, LLVector3 Pos, byte[] textureEntry); + void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, LLVector3 Pos, byte[] textureEntry, uint parentID); void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLVector3 velocity, LLQuaternion rotation); void SendCoarseLocationUpdate(List CoarseLocations); diff --git a/OpenSim/Region/ClientStack/ClientView.API.cs b/OpenSim/Region/ClientStack/ClientView.API.cs index a1e4b56f11..74f1824ee4 100644 --- a/OpenSim/Region/ClientStack/ClientView.API.cs +++ b/OpenSim/Region/ClientStack/ClientView.API.cs @@ -54,6 +54,8 @@ namespace OpenSim.Region.ClientStack public event SetAppearance OnSetAppearance; public event GenericCall2 OnCompleteMovementToRegion; public event UpdateAgent OnAgentUpdate; + public event AgentRequestSit OnAgentRequestSit; + public event AgentSit OnAgentSit; public event StartAnim OnStartAnim; public event GenericCall OnRequestAvatarsData; public event LinkObjects OnLinkObjects; @@ -807,6 +809,19 @@ namespace OpenSim.Region.ClientStack avatarReply.PropertiesData.PartnerID = partnerID; OutPacket(avatarReply); } + + public void SendSitResponse(LLUUID targetID, LLVector3 offset) + { + AvatarSitResponsePacket avatarSitResponse = new AvatarSitResponsePacket(); + + avatarSitResponse.SitObject.ID = targetID; + + avatarSitResponse.SitTransform.AutoPilot = true; + avatarSitResponse.SitTransform.SitPosition = offset; + avatarSitResponse.SitTransform.SitRotation = new LLQuaternion(0.0f, 0.0f, 0.0f, 1.0f); + + OutPacket(avatarSitResponse); + } #endregion #region Appearance/ Wearables Methods @@ -889,7 +904,7 @@ namespace OpenSim.Region.ClientStack /// /// /// - public void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, LLVector3 Pos, byte[] textureEntry) + public void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, LLVector3 Pos, byte[] textureEntry, uint parentID) { ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); objupdate.RegionData.RegionHandle = regionHandle; @@ -900,6 +915,7 @@ namespace OpenSim.Region.ClientStack //give this avatar object a local id and assign the user a name objupdate.ObjectData[0].ID = avatarLocalID; objupdate.ObjectData[0].FullID = avatarID; + objupdate.ObjectData[0].ParentID = parentID; objupdate.ObjectData[0].NameValue = Helpers.StringToField("FirstName STRING RW SV " + firstName + "\nLastName STRING RW SV " + lastName); LLVector3 pos2 = new LLVector3((float)Pos.X, (float)Pos.Y, (float)Pos.Z); byte[] pb = pos2.GetBytes(); diff --git a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs index 05b11189ef..65a0e44656 100644 --- a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs +++ b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs @@ -34,6 +34,7 @@ using OpenSim.Framework.Inventory; using OpenSim.Framework.Types; using OpenSim.Framework.Utilities; using OpenSim.Framework.Interfaces; +using OpenSim.Region.Environment.Scenes; namespace OpenSim.Region.ClientStack { @@ -198,6 +199,21 @@ namespace OpenSim.Region.ClientStack } } break; + case PacketType.AgentRequestSit: + AgentRequestSitPacket agentRequestSit = (AgentRequestSitPacket)Pack; + SendSitResponse(agentRequestSit.TargetObject.TargetID, agentRequestSit.TargetObject.Offset); + if (OnAgentRequestSit != null) + { + OnAgentRequestSit(this, agentRequestSit.AgentData.AgentID, agentRequestSit.TargetObject.TargetID); + } + break; + case PacketType.AgentSit: + if (OnAgentSit != null) + { + AgentSitPacket agentSit = (AgentSitPacket) Pack; + OnAgentSit(this, agentSit.AgentData.AgentID); + } + break; #endregion diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 256b6b50b6..716aaa68fe 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -51,6 +51,7 @@ namespace OpenSim.Region.Environment.Scenes private byte m_movementflag = 0; private readonly List m_forcesList = new List(); private short m_updateCount = 0; + private uint m_requestedSitTargetID = 0; private Quaternion bodyRot; private byte[] m_visualParams; @@ -216,6 +217,13 @@ namespace OpenSim.Region.Environment.Scenes set { m_isChildAgent = value; } } + private uint m_parentID = 0; + public uint ParentID + { + get { return m_parentID; } + set { m_parentID = value; } + } + #endregion #region Constructor(s) @@ -245,6 +253,8 @@ namespace OpenSim.Region.Environment.Scenes m_controllingClient.OnCompleteMovementToRegion += CompleteMovement; m_controllingClient.OnCompleteMovementToRegion += SendInitialData; m_controllingClient.OnAgentUpdate += HandleAgentUpdate; + m_controllingClient.OnAgentRequestSit += HandleAgentRequestSit; + m_controllingClient.OnAgentSit += HandleAgentSit; // ControllingClient.OnStartAnim += new StartAnim(this.SendAnimPack); // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); //ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); @@ -454,33 +464,44 @@ namespace OpenSim.Region.Environment.Scenes update_movementflag = true; } + if ((flags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) + { + StandUp(); + update_movementflag = true; + } + if (q != bodyRot) { bodyRot = q; update_rotation = true; } - foreach (Dir_ControlFlags DCF in Enum.GetValues(typeof(Dir_ControlFlags))) + + if (m_parentID == 0) { - if ((flags & (uint)DCF) != 0) + foreach (Dir_ControlFlags DCF in Enum.GetValues(typeof(Dir_ControlFlags))) { - DCFlagKeyPressed = true; - agent_control_v3 += Dir_Vectors[i]; - if ((m_movementflag & (uint)DCF) == 0) + if ((flags & (uint)DCF) != 0) { - m_movementflag += (byte)(uint)DCF; - update_movementflag = true; + DCFlagKeyPressed = true; + agent_control_v3 += Dir_Vectors[i]; + if ((m_movementflag & (uint)DCF) == 0) + { + m_movementflag += (byte)(uint)DCF; + update_movementflag = true; + } } - } - else - { - if ((m_movementflag & (uint)DCF) != 0) + else { - m_movementflag -= (byte)(uint)DCF; - update_movementflag = true; + if ((m_movementflag & (uint)DCF) != 0) + { + m_movementflag -= (byte)(uint)DCF; + update_movementflag = true; + } } + i++; } - i++; } + if ((update_movementflag) || (update_rotation && DCFlagKeyPressed)) { AddNewMovement(agent_control_v3, q); @@ -488,6 +509,46 @@ namespace OpenSim.Region.Environment.Scenes UpdateMovementAnimations(update_movementflag); } + protected void StandUp() + { + if (m_parentID != 0) + { + SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); + if (part != null) + AbsolutePosition = part.AbsolutePosition; + m_parentID = 0; + SendFullUpdateToAllClients(); + } + } + + public void HandleAgentRequestSit(IClientAPI remoteClient, LLUUID agentID, LLUUID targetID) + { + if (m_parentID != 0) + { + StandUp(); + UpdateMovementAnimations(true); + } + + SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); + + if (part != null) + { + m_requestedSitTargetID = part.LocalID; + } + else + { + MainLog.Instance.Warn("Sit requested on unknown object: " + targetID.ToString()); + } + } + + public void HandleAgentSit(IClientAPI remoteClient, LLUUID agentID) + { + AbsolutePosition = new LLVector3(0F, 0F, 0F); + m_parentID = m_requestedSitTargetID; + SendAnimPack(Animations.AnimsLLUUID["SIT"], 1); + SendFullUpdateToAllClients(); + } + protected void UpdateMovementAnimations(bool update_movementflag) { if (update_movementflag) @@ -641,7 +702,7 @@ namespace OpenSim.Region.Environment.Scenes public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar) { remoteAvatar.m_controllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_uuid, - LocalId, AbsolutePosition, m_textureEntry.ToBytes()); + LocalId, AbsolutePosition, m_textureEntry.ToBytes(), m_parentID); } public void SendFullUpdateToAllClients() @@ -667,7 +728,7 @@ namespace OpenSim.Region.Environment.Scenes public void SendInitialData() { m_controllingClient.SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_uuid, LocalId, - AbsolutePosition, m_textureEntry.ToBytes()); + AbsolutePosition, m_textureEntry.ToBytes(), m_parentID); if (!m_isChildAgent) { m_scene.InformClientOfNeighbours(m_controllingClient); diff --git a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs index 1460b81bfb..7962698cdb 100644 --- a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs @@ -68,6 +68,8 @@ namespace SimpleApp public event GenericCall OnRequestWearables; public event GenericCall2 OnCompleteMovementToRegion; public event UpdateAgent OnAgentUpdate; + public event AgentRequestSit OnAgentRequestSit; + public event AgentSit OnAgentSit; public event GenericCall OnRequestAvatarsData; public event AddNewPrim OnAddPrim; public event ObjectDuplicate OnObjectDuplicate; @@ -179,7 +181,7 @@ namespace SimpleApp public virtual void SendTeleportLocationStart() { } public virtual void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance) { } - public virtual void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, LLVector3 Pos, byte[] textureEntry) { } + public virtual void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, LLVector3 Pos, byte[] textureEntry, uint parentID) { } public virtual void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLVector3 velocity, LLQuaternion rotation) { } public virtual void SendCoarseLocationUpdate(List CoarseLocations) { } diff --git a/bin/data/avataranimations.xml b/bin/data/avataranimations.xml index 8a98c621de..99953115fe 100644 --- a/bin/data/avataranimations.xml +++ b/bin/data/avataranimations.xml @@ -7,4 +7,5 @@ 2408fe9e-df1d-1d7d-f4ff-1384fa7b350f 6ed24bd8-91aa-4b12-ccc7-c97c857ab4e0 aec4610c-757f-bc4e-c092-c6e9caf18daf - \ No newline at end of file + 1a5fe8ac-a804-8a5d-7cbd-56bd83184568 +