Files
libremetaverse/Programs/examples/TestClient/Commands/Land/AgentLocationsCommand.cs

51 lines
1.7 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
2021-07-25 11:10:52 -05:00
using System.Linq;
using System.Text;
namespace OpenMetaverse.TestClient
{
/// <summary>
/// Display a list of all agent locations in a specified region
/// </summary>
public class AgentLocationsCommand : Command
{
public AgentLocationsCommand(TestClient testClient)
{
Name = "agentlocations";
Description = "Downloads all of the agent locations in a specified region. Usage: agentlocations [regionhandle]";
Category = CommandCategory.Simulator;
}
public override string Execute(string[] args, UUID fromAgentID)
{
ulong regionHandle;
if (args.Length == 0)
regionHandle = Client.Network.CurrentSim.Handle;
else if (!(args.Length == 1 && UInt64.TryParse(args[0], out regionHandle)))
return "Usage: agentlocations [regionhandle]";
List<MapItem> items = Client.Grid.MapItems(regionHandle, GridItemType.AgentLocations,
GridLayerType.Objects, 1000 * 20);
if (items != null)
{
StringBuilder ret = new StringBuilder();
ret.AppendLine("Agent locations:");
2021-07-25 11:10:52 -05:00
foreach (var location in items.Cast<MapAgentLocation>())
{
2021-07-25 11:10:52 -05:00
ret.AppendLine($"{location.AvatarCount} avatar(s) at {location.LocalX},{location.LocalY}");
}
return ret.ToString();
}
else
{
return "Failed to fetch agent locations";
}
}
}
}