2007-11-30 23:19:05 +00:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Threading;
|
2008-07-21 21:12:59 +00:00
|
|
|
using OpenMetaverse;
|
|
|
|
|
using OpenMetaverse.Packets;
|
2007-11-30 23:19:05 +00:00
|
|
|
|
2008-07-21 21:12:59 +00:00
|
|
|
namespace OpenMetaverse.TestClient
|
2007-11-30 23:19:05 +00:00
|
|
|
{
|
|
|
|
|
public class CloneCommand : Command
|
|
|
|
|
{
|
|
|
|
|
uint SerialNum = 2;
|
|
|
|
|
|
|
|
|
|
public CloneCommand(TestClient testClient)
|
|
|
|
|
{
|
|
|
|
|
Name = "clone";
|
|
|
|
|
Description = "Clone the appearance of a nearby avatar. Usage: clone [name]";
|
2008-07-25 08:55:36 +00:00
|
|
|
Category = CommandCategory.Appearance;
|
2007-11-30 23:19:05 +00:00
|
|
|
}
|
|
|
|
|
|
2008-07-25 05:15:05 +00:00
|
|
|
public override string Execute(string[] args, UUID fromAgentID)
|
2007-11-30 23:19:05 +00:00
|
|
|
{
|
|
|
|
|
string targetName = String.Empty;
|
|
|
|
|
List<DirectoryManager.AgentSearchData> matches;
|
|
|
|
|
|
|
|
|
|
for (int ct = 0; ct < args.Length; ct++)
|
|
|
|
|
targetName = targetName + args[ct] + " ";
|
|
|
|
|
targetName = targetName.TrimEnd();
|
|
|
|
|
|
|
|
|
|
if (targetName.Length == 0)
|
|
|
|
|
return "Usage: clone [name]";
|
|
|
|
|
|
|
|
|
|
if (Client.Directory.PeopleSearch(DirectoryManager.DirFindFlags.People, targetName, 0, 1000 * 10,
|
|
|
|
|
out matches) && matches.Count > 0)
|
|
|
|
|
{
|
2008-07-25 05:15:05 +00:00
|
|
|
UUID target = matches[0].AgentID;
|
2007-11-30 23:19:05 +00:00
|
|
|
targetName += String.Format(" ({0})", target);
|
|
|
|
|
|
|
|
|
|
if (Client.Appearances.ContainsKey(target))
|
|
|
|
|
{
|
|
|
|
|
#region AvatarAppearance to AgentSetAppearance
|
|
|
|
|
|
|
|
|
|
AvatarAppearancePacket appearance = Client.Appearances[target];
|
|
|
|
|
|
|
|
|
|
AgentSetAppearancePacket set = new AgentSetAppearancePacket();
|
|
|
|
|
set.AgentData.AgentID = Client.Self.AgentID;
|
|
|
|
|
set.AgentData.SessionID = Client.Self.SessionID;
|
|
|
|
|
set.AgentData.SerialNum = SerialNum++;
|
2008-07-25 05:15:05 +00:00
|
|
|
set.AgentData.Size = new Vector3(2f, 2f, 2f); // HACK
|
2007-11-30 23:19:05 +00:00
|
|
|
|
|
|
|
|
set.WearableData = new AgentSetAppearancePacket.WearableDataBlock[0];
|
|
|
|
|
set.VisualParam = new AgentSetAppearancePacket.VisualParamBlock[appearance.VisualParam.Length];
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < appearance.VisualParam.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
set.VisualParam[i] = new AgentSetAppearancePacket.VisualParamBlock();
|
|
|
|
|
set.VisualParam[i].ParamValue = appearance.VisualParam[i].ParamValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set.ObjectData.TextureEntry = appearance.ObjectData.TextureEntry;
|
|
|
|
|
|
|
|
|
|
#endregion AvatarAppearance to AgentSetAppearance
|
|
|
|
|
|
|
|
|
|
// Detach everything we are currently wearing
|
2008-08-21 01:19:06 +00:00
|
|
|
Client.Appearance.AddAttachments(new List<InventoryBase>(), true);
|
2007-11-30 23:19:05 +00:00
|
|
|
|
|
|
|
|
// Send the new appearance packet
|
|
|
|
|
Client.Network.SendPacket(set);
|
|
|
|
|
|
|
|
|
|
return "Cloned " + targetName;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return "Don't know the appearance of avatar " + targetName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return "Couldn't find avatar " + targetName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|