Thank you kindly, Snowdrop/Snowcrash for a patch that:

This patch makes the worn attachments accessible to MRM scripting
0.6.6-post-fixes
Charles Krinke 2009-06-29 18:07:30 +00:00
parent 6da88dceb0
commit 7bb070be55
3 changed files with 81 additions and 2 deletions

View File

@ -32,8 +32,24 @@ using OpenMetaverse;
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{
public interface IAvatarAttachment
{
//// <value>
/// Describes where on the avatar the attachment is located
/// </value>
int Location { get ; }
//// <value>
/// Accessor to the rez'ed asset, representing the attachment
/// </value>
IObject Asset { get; }
}
public interface IAvatar : IEntity
{
//// <value>
/// Array of worn attachments, empty but not null, if no attachments are worn
/// </value>
IAvatarAttachment[] Attachments { get; }
}
}

View File

@ -26,15 +26,22 @@
*/
using System;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using OpenMetaverse;
using OpenSim.Region.Framework.Scenes;
using log4net;
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{
class SPAvatar : System.MarshalByRefObject, IAvatar
{
private readonly Scene m_rootScene;
private readonly UUID m_ID;
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public SPAvatar(Scene scene, UUID ID)
{
@ -63,5 +70,26 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
get { return GetSP().AbsolutePosition; }
set { GetSP().TeleportWithMomentum(value); }
}
#region IAvatar implementation
public IAvatarAttachment[] Attachments
{
get {
List<IAvatarAttachment> attachments = new List<IAvatarAttachment>();
Hashtable internalAttachments = GetSP().Appearance.GetAttachments();
if(internalAttachments != null)
{
foreach(DictionaryEntry element in internalAttachments)
{
Hashtable attachInfo = (Hashtable)element.Value;
attachments.Add(new SPAvatarAttachment(m_rootScene, this, (int)element.Key, new UUID((string)attachInfo["item"]), new UUID((string)attachInfo["asset"])));
}
}
return attachments.ToArray();
}
}
#endregion
}
}

View File

@ -0,0 +1,35 @@
using System;
using OpenMetaverse;
using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{
public class SPAvatarAttachment : IAvatarAttachment
{
private readonly Scene m_rootScene;
private readonly IAvatar m_parent;
private readonly int m_location;
private readonly UUID m_itemId;
private readonly UUID m_assetId;
public SPAvatarAttachment(Scene rootScene, IAvatar self, int location, UUID itemId, UUID assetId)
{
m_rootScene = rootScene;
m_parent = self;
m_location = location;
m_itemId = itemId;
m_assetId = assetId;
}
public int Location { get { return m_location; } }
public IObject Asset
{
get
{
return new SOPObject(m_rootScene, m_rootScene.GetSceneObjectPart(m_assetId).LocalId);
}
}
}
}