2007-04-28 20:54:02 +00:00
|
|
|
using System;
|
|
|
|
|
|
2008-07-21 21:12:59 +00:00
|
|
|
namespace OpenMetaverse.TestClient
|
2007-04-28 20:54:02 +00:00
|
|
|
{
|
|
|
|
|
public class SitCommand: Command
|
|
|
|
|
{
|
|
|
|
|
public SitCommand(TestClient testClient)
|
|
|
|
|
{
|
|
|
|
|
Name = "sit";
|
|
|
|
|
Description = "Attempt to sit on the closest prim";
|
2008-07-25 08:55:36 +00:00
|
|
|
Category = CommandCategory.Movement;
|
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
|
|
|
{
|
|
|
|
|
Primitive closest = null;
|
2022-02-25 19:38:11 -06:00
|
|
|
double closestDistance = double.MaxValue;
|
2007-04-28 20:54:02 +00:00
|
|
|
|
2025-05-27 14:16:03 -05:00
|
|
|
foreach (var kvp in Client.Network.CurrentSim.ObjectsPrimitives)
|
2007-04-28 20:54:02 +00:00
|
|
|
{
|
2025-05-27 14:16:03 -05:00
|
|
|
if (kvp.Value == null) { continue; }
|
2007-04-28 20:54:02 +00:00
|
|
|
|
2025-05-27 14:16:03 -05:00
|
|
|
var prim = kvp.Value;
|
|
|
|
|
var distance = Vector3.Distance(Client.Self.SimPosition, prim.Position);
|
|
|
|
|
if (closest == null || distance < closestDistance)
|
|
|
|
|
{
|
|
|
|
|
closest = prim;
|
|
|
|
|
closestDistance = distance;
|
|
|
|
|
}
|
2007-04-28 20:54:02 +00:00
|
|
|
}
|
2025-05-27 14:16:03 -05:00
|
|
|
|
|
|
|
|
if (closest == null)
|
2007-04-28 20:54:02 +00:00
|
|
|
{
|
|
|
|
|
return "Couldn't find a nearby prim to sit on";
|
|
|
|
|
}
|
2025-05-27 14:16:03 -05:00
|
|
|
Client.Self.RequestSit(closest.ID, Vector3.Zero);
|
|
|
|
|
Client.Self.Sit();
|
|
|
|
|
|
|
|
|
|
return $"Sat on {closest.ID} ({closest.LocalID}). Distance: {closestDistance}";
|
|
|
|
|
|
|
|
|
|
}
|
2007-04-28 20:54:02 +00:00
|
|
|
}
|
|
|
|
|
}
|