Added code to propogate event OnAttach.

dsg
Huaiyu (Kitty) Liu 2011-02-18 17:05:25 -08:00
parent 1d2a25689a
commit 513ca97eb0
3 changed files with 67 additions and 2 deletions

View File

@ -692,6 +692,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
case EventManager.EventNames.ObjectDeGrab: case EventManager.EventNames.ObjectDeGrab:
OnLocalDeGrabObject((uint)evArgs[0], (uint)evArgs[1], (IClientAPI)evArgs[2], (SurfaceTouchEventArgs)evArgs[3]); OnLocalDeGrabObject((uint)evArgs[0], (uint)evArgs[1], (IClientAPI)evArgs[2], (SurfaceTouchEventArgs)evArgs[3]);
return; return;
case EventManager.EventNames.Attach:
OnLocalAttach((uint)evArgs[0], (UUID)evArgs[1], (UUID)evArgs[2]);
return;
default: default:
return; return;
} }
@ -1431,6 +1434,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
case SymmetricSyncMessage.MsgType.ObjectGrab: case SymmetricSyncMessage.MsgType.ObjectGrab:
case SymmetricSyncMessage.MsgType.ObjectGrabbing: case SymmetricSyncMessage.MsgType.ObjectGrabbing:
case SymmetricSyncMessage.MsgType.ObjectDeGrab: case SymmetricSyncMessage.MsgType.ObjectDeGrab:
case SymmetricSyncMessage.MsgType.Attach:
{ {
HandleRemoteEvent(msg, senderActorID); HandleRemoteEvent(msg, senderActorID);
return; return;
@ -1766,6 +1770,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
case SymmetricSyncMessage.MsgType.ObjectDeGrab: case SymmetricSyncMessage.MsgType.ObjectDeGrab:
HandleRemoteEvent_OnObjectDeGrab(init_actorID, evSeqNum, data); HandleRemoteEvent_OnObjectDeGrab(init_actorID, evSeqNum, data);
break; break;
case SymmetricSyncMessage.MsgType.Attach:
HandleRemoteEvent_OnAttach(init_actorID, evSeqNum, data);
break;
} }
//if this is a relay node, forwards the event //if this is a relay node, forwards the event
@ -2018,6 +2025,24 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
m_scene.EventManager.TriggerObjectDeGrabLocally(part.LocalId, originalID, remoteClinet, surfaceArgs); m_scene.EventManager.TriggerObjectDeGrabLocally(part.LocalId, originalID, remoteClinet, surfaceArgs);
} }
private void HandleRemoteEvent_OnAttach(string actorID, ulong evSeqNum, OSDMap data)
{
UUID primID = data["primID"].AsUUID();
UUID itemID = data["itemID"].AsUUID();
UUID avatarID = data["avatarID"].AsUUID();
SceneObjectPart part = m_scene.GetSceneObjectPart(primID);
if (part == null)
{
m_log.Warn(LogHeader + ", HandleRemoteEvent_OnAttach: no part with UUID " + primID + " found");
return;
}
uint localID = part.LocalId;
m_scene.EventManager.TriggerOnAttachLocally(localID, itemID, avatarID);
}
/// <summary> /// <summary>
/// The handler for (locally initiated) event OnNewScript: triggered by client's RezSript packet, publish it to other actors. /// The handler for (locally initiated) event OnNewScript: triggered by client's RezSript packet, publish it to other actors.
@ -2127,7 +2152,23 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
data["type"] = OSD.FromInteger((int)chat.Type); data["type"] = OSD.FromInteger((int)chat.Type);
SendSceneEvent(SymmetricSyncMessage.MsgType.ChatFromWorld, data); SendSceneEvent(SymmetricSyncMessage.MsgType.ChatFromWorld, data);
} }
private void OnLocalAttach(uint localID, UUID itemID, UUID avatarID)
{
OSDMap data = new OSDMap();
SceneObjectPart part = m_scene.GetSceneObjectPart(localID);
if (part == null)
{
m_log.Warn(LogHeader + ", OnLocalAttach: no part with localID: " + localID);
return;
}
data["primID"] = OSD.FromUUID(part.UUID);
data["itemID"] = OSD.FromUUID(itemID);
data["avatarID"] = OSD.FromUUID(avatarID);
SendSceneEvent(SymmetricSyncMessage.MsgType.Attach, data);
}
private void OnLocalGrabObject(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) private void OnLocalGrabObject(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs)
{ {
/* /*
@ -2239,6 +2280,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
} }
private void SendSceneEvent(SymmetricSyncMessage.MsgType msgType, OSDMap data) private void SendSceneEvent(SymmetricSyncMessage.MsgType msgType, OSDMap data)
{ {
data["actorID"] = OSD.FromString(m_actorID); data["actorID"] = OSD.FromString(m_actorID);

View File

@ -45,6 +45,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
ObjectGrab, ObjectGrab,
ObjectGrabbing, ObjectGrabbing,
ObjectDeGrab, ObjectDeGrab,
Attach,
} }
#endregion #endregion

View File

@ -58,6 +58,7 @@ namespace OpenSim.Region.Framework.Scenes
ObjectGrab, ObjectGrab,
ObjectGrabbing, ObjectGrabbing,
ObjectDeGrab, ObjectDeGrab,
Attach, //attaching object to avatar
} }
@ -238,6 +239,25 @@ namespace OpenSim.Region.Framework.Scenes
base.TriggerObjectDeGrab(localID, originalID, remoteClient, surfaceArgs); base.TriggerObjectDeGrab(localID, originalID, remoteClient, surfaceArgs);
} }
public override void TriggerOnAttach(uint localID, UUID itemID, UUID avatarID)
{
if (m_scene.RegionSyncModule != null)
{
Object[] eventArgs = new Object[4];
eventArgs[0] = (Object)localID;
eventArgs[1] = (Object)itemID;
eventArgs[2] = (Object)avatarID;
m_scene.RegionSyncModule.PublishSceneEvent(EventNames.Attach, eventArgs);
}
TriggerOnAttachLocally(localID, itemID, avatarID);
}
public void TriggerOnAttachLocally(uint localID, UUID itemID, UUID avatarID)
{
base.TriggerOnAttach(localID, itemID, avatarID);
}
#endregion //GrabObject #endregion //GrabObject
} }
@ -645,7 +665,8 @@ namespace OpenSim.Region.Framework.Scenes
public event LandBuy OnLandBuy; public event LandBuy OnLandBuy;
public event LandBuy OnValidateLandBuy; public event LandBuy OnValidateLandBuy;
public void TriggerOnAttach(uint localID, UUID itemID, UUID avatarID) //public void TriggerOnAttach(uint localID, UUID itemID, UUID avatarID)
public virtual void TriggerOnAttach(uint localID, UUID itemID, UUID avatarID)
{ {
Attach handlerOnAttach = OnAttach; Attach handlerOnAttach = OnAttach;
if (handlerOnAttach != null) if (handlerOnAttach != null)