Attachments now persist across logouts. Mostly untested.0.6.0-stable
parent
b4355e4564
commit
29530f3029
|
@ -528,22 +528,26 @@ namespace OpenSim.Framework
|
|||
m_attachments[attachpoint][1] = asset;
|
||||
}
|
||||
|
||||
public void DetachAttachment(LLUUID itemID)
|
||||
public int GetAttachpoint(LLUUID itemID)
|
||||
{
|
||||
int attachpoint = 0;
|
||||
|
||||
foreach (KeyValuePair<int, LLUUID[]> kvp in m_attachments)
|
||||
{
|
||||
if(kvp.Value[0] == itemID)
|
||||
{
|
||||
attachpoint = kvp.Key;
|
||||
break;
|
||||
return kvp.Key;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void DetachAttachment(LLUUID itemID)
|
||||
{
|
||||
int attachpoint = GetAttachpoint(itemID);
|
||||
|
||||
if(attachpoint > 0)
|
||||
m_attachments.Remove(attachpoint);
|
||||
}
|
||||
|
||||
string GetAttachmentsString()
|
||||
{
|
||||
List<string> strings = new List<string>();
|
||||
|
|
|
@ -47,11 +47,15 @@ namespace OpenSim.Framework.Communications.Cache
|
|||
internal delegate void SendInventoryDescendentsDelegate(
|
||||
IClientAPI client, LLUUID folderID, bool fetchFolders, bool fetchItems);
|
||||
|
||||
public delegate void OnItemReceivedDelegate(LLUUID itemID);
|
||||
|
||||
/// <summary>
|
||||
/// Stores user profile and inventory data received from backend services for a particular user.
|
||||
/// </summary>
|
||||
public class CachedUserInfo
|
||||
{
|
||||
public event OnItemReceivedDelegate OnItemReceived;
|
||||
|
||||
private static readonly ILog m_log
|
||||
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
|
@ -306,6 +310,9 @@ namespace OpenSim.Framework.Communications.Cache
|
|||
{
|
||||
folder.Items[itemInfo.ID] = itemInfo;
|
||||
}
|
||||
|
||||
if (OnItemReceived != null)
|
||||
OnItemReceived(itemInfo.ID);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -2308,15 +2308,6 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
EventManager.TriggerStopScript(part.LocalId, itemID);
|
||||
}
|
||||
|
||||
// public void TestFunction()
|
||||
// {
|
||||
// IInventoryModule imod = RequestModuleInterface<IInventoryModule>();
|
||||
// if (imod == null)
|
||||
// return;
|
||||
//
|
||||
// imod.TestFunction();
|
||||
// }
|
||||
|
||||
public void RezSingleAttachment(IClientAPI remoteClient, LLUUID itemID,
|
||||
uint AttachmentPt, uint ItemFlags, uint NextOwnerMask)
|
||||
{
|
||||
|
@ -2328,13 +2319,21 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
return;
|
||||
}
|
||||
|
||||
RezSingleAttachment(att, remoteClient, itemID, AttachmentPt,
|
||||
ItemFlags, NextOwnerMask);
|
||||
}
|
||||
|
||||
public void RezSingleAttachment(SceneObjectGroup att,
|
||||
IClientAPI remoteClient, LLUUID itemID, uint AttachmentPt,
|
||||
uint ItemFlags, uint NextOwnerMask)
|
||||
{
|
||||
if (att.RootPart != null)
|
||||
AttachmentPt = att.RootPart.AttachmentPoint;
|
||||
|
||||
ScenePresence presence;
|
||||
if(TryGetAvatar(remoteClient.AgentId, out presence))
|
||||
{
|
||||
presence.Appearance.SetAttachment((int)AttachmentPt, itemID, att.GetFromAssetID());
|
||||
presence.Appearance.SetAttachment((int)AttachmentPt, itemID, att.UUID);
|
||||
IAvatarFactory ava = RequestModuleInterface<IAvatarFactory>();
|
||||
if(ava != null)
|
||||
{
|
||||
|
|
|
@ -36,6 +36,7 @@ using libsecondlife.Packets;
|
|||
using log4net;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Communications.Cache;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using OpenSim.Region.Environment.Types;
|
||||
using OpenSim.Region.Physics.Manager;
|
||||
|
||||
|
@ -416,7 +417,8 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
RegisterToEvents();
|
||||
SetDirectionVectors();
|
||||
|
||||
|
||||
CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(m_uuid);
|
||||
userInfo.OnItemReceived += ItemReceived;
|
||||
}
|
||||
|
||||
public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, byte[] visualParams,
|
||||
|
@ -604,6 +606,12 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
/// </summary>
|
||||
public void MakeRootAgent(LLVector3 pos, bool isFlying)
|
||||
{
|
||||
IAvatarFactory ava = m_scene.RequestModuleInterface<IAvatarFactory>();
|
||||
if(ava != null)
|
||||
{
|
||||
ava.TryGetAvatarAppearance(m_uuid, out m_appearance);
|
||||
}
|
||||
|
||||
// m_log.DebugFormat(
|
||||
// "[SCENE PRESENCE]: Upgrading child agent {0}, {1} to a root agent in {2} at pos {3}",
|
||||
// Name, UUID, m_scene.RegionInfo.RegionName, pos);
|
||||
|
@ -2862,5 +2870,32 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
//DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG
|
||||
return flags;
|
||||
}
|
||||
|
||||
private void ItemReceived(LLUUID itemID)
|
||||
{
|
||||
int attachpoint = m_appearance.GetAttachpoint(itemID);
|
||||
if (attachpoint == 0)
|
||||
return;
|
||||
|
||||
SceneObjectPart att = m_scene.GetSceneObjectPart(m_appearance.GetAttachedAsset(attachpoint));
|
||||
|
||||
|
||||
// If this is null, then we have just rezzed in. Non null means
|
||||
// we're crossing
|
||||
//
|
||||
if (att != null)
|
||||
{
|
||||
System.Console.WriteLine("Attach from world {0}", itemID.ToString());
|
||||
// Attach from world
|
||||
if(att.ParentGroup != null)
|
||||
m_scene.RezSingleAttachment(att.ParentGroup, ControllingClient, itemID, (uint)attachpoint, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
System.Console.WriteLine("Rez attachment {0}", itemID.ToString());
|
||||
// Rez from inventory
|
||||
m_scene.RezSingleAttachment(ControllingClient, itemID, (uint)attachpoint, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue