From 2cf117cc6c2c7cf106fa83785621577a8b713529 Mon Sep 17 00:00:00 2001
From: Jeff Ames
Date: Sun, 28 Oct 2007 03:58:46 +0000
Subject: Added preliminary support for sitting on prims
---
OpenSim/Region/ClientStack/ClientView.API.cs | 18 ++++-
.../ClientStack/ClientView.ProcessPackets.cs | 16 ++++
OpenSim/Region/Environment/Scenes/ScenePresence.cs | 93 ++++++++++++++++++----
.../Region/Examples/SimpleApp/MyNpcCharacter.cs | 4 +-
4 files changed, 113 insertions(+), 18 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/ClientStack/ClientView.API.cs b/OpenSim/Region/ClientStack/ClientView.API.cs
index a1e4b56..74f1824 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 05b1118..65a0e44 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 256b6b5..716aaa6 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 1460b81..7962698 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) { }
--
cgit v1.1