2007-04-28 20:54:02 +00:00
|
|
|
using System;
|
2009-10-19 23:50:07 +00:00
|
|
|
using System.Collections.Generic;
|
2022-02-25 19:38:11 -06:00
|
|
|
using System.Linq;
|
2007-04-28 20:54:02 +00:00
|
|
|
|
2008-07-21 21:12:59 +00:00
|
|
|
namespace OpenMetaverse.TestClient
|
2007-04-28 20:54:02 +00:00
|
|
|
{
|
|
|
|
|
public class WearCommand : Command
|
|
|
|
|
{
|
2008-08-21 01:19:06 +00:00
|
|
|
public WearCommand(TestClient testClient)
|
2007-04-28 20:54:02 +00:00
|
|
|
{
|
2007-07-11 09:17:46 +00:00
|
|
|
Client = testClient;
|
2007-04-28 20:54:02 +00:00
|
|
|
Name = "wear";
|
2009-10-19 23:50:07 +00:00
|
|
|
Description = "Wear an outfit folder from inventory. Usage: wear [outfit name]";
|
2008-07-25 08:55:36 +00:00
|
|
|
Category = CommandCategory.Appearance;
|
2007-04-28 20:54:02 +00:00
|
|
|
}
|
|
|
|
|
|
2008-07-25 05:15:05 +00:00
|
|
|
public override string Execute(string[] args, UUID fromAgentID)
|
2007-04-28 20:54:02 +00:00
|
|
|
{
|
2008-04-07 17:12:20 +00:00
|
|
|
if (args.Length < 1)
|
2009-10-19 23:50:07 +00:00
|
|
|
return "Usage: wear [outfit name] eg: 'wear Clothing/My Outfit";
|
2008-04-07 17:12:20 +00:00
|
|
|
|
2022-02-25 19:38:11 -06:00
|
|
|
string target = args.Aggregate(string.Empty, (current, t) => current + (t + " "));
|
2008-08-12 05:55:42 +00:00
|
|
|
|
2008-08-21 01:19:06 +00:00
|
|
|
target = target.TrimEnd();
|
2007-08-25 09:36:33 +00:00
|
|
|
|
2025-01-13 07:44:05 -06:00
|
|
|
UUID folder = Client.Inventory.FindObjectByPath(Client.Inventory.Store.RootFolder.UUID, Client.Self.AgentID, target, TimeSpan.FromSeconds(20));
|
2009-10-19 23:50:07 +00:00
|
|
|
|
|
|
|
|
if (folder == UUID.Zero)
|
|
|
|
|
{
|
|
|
|
|
return "Outfit path " + target + " not found";
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-13 07:44:05 -06:00
|
|
|
List<InventoryBase> contents = Client.Inventory.FolderContents(folder, Client.Self.AgentID, true, true, InventorySortOrder.ByName, TimeSpan.FromSeconds(20));
|
2009-10-19 23:50:07 +00:00
|
|
|
List<InventoryItem> items = new List<InventoryItem>();
|
|
|
|
|
|
|
|
|
|
if (contents == null)
|
|
|
|
|
{
|
|
|
|
|
return "Failed to get contents of " + target;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (InventoryBase item in contents)
|
|
|
|
|
{
|
2020-05-09 08:41:30 -05:00
|
|
|
if (item is InventoryItem inventoryItem)
|
|
|
|
|
items.Add(inventoryItem);
|
2009-10-19 23:50:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Client.Appearance.ReplaceOutfit(items);
|
|
|
|
|
|
|
|
|
|
return "Starting to change outfit to " + target;
|
2007-04-28 20:54:02 +00:00
|
|
|
|
|
|
|
|
}
|
2007-05-12 01:42:28 +00:00
|
|
|
}
|
|
|
|
|
}
|