2007-04-28 20:54:02 +00:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
2008-07-21 21:12:59 +00:00
|
|
|
using OpenMetaverse;
|
|
|
|
|
using OpenMetaverse.Packets;
|
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 SitCommand: Command
|
|
|
|
|
{
|
|
|
|
|
public SitCommand(TestClient testClient)
|
|
|
|
|
{
|
|
|
|
|
Name = "sit";
|
|
|
|
|
Description = "Attempt to sit on the closest prim";
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
double closestDistance = Double.MaxValue;
|
|
|
|
|
|
2008-01-03 21:55:49 +00:00
|
|
|
Client.Network.CurrentSim.ObjectsPrimitives.ForEach(
|
2007-08-29 08:55:53 +00:00
|
|
|
delegate(Primitive prim)
|
2007-04-28 20:54:02 +00:00
|
|
|
{
|
2008-07-25 05:15:05 +00:00
|
|
|
float distance = Vector3.Dist(Client.Self.SimPosition, prim.Position);
|
2007-04-28 20:54:02 +00:00
|
|
|
|
2007-08-20 09:26:21 +00:00
|
|
|
if (closest == null || distance < closestDistance)
|
|
|
|
|
{
|
2007-08-29 08:55:53 +00:00
|
|
|
closest = prim;
|
2007-08-20 09:26:21 +00:00
|
|
|
closestDistance = distance;
|
2007-04-28 20:54:02 +00:00
|
|
|
}
|
|
|
|
|
}
|
2007-08-29 08:55:53 +00:00
|
|
|
);
|
2007-04-28 20:54:02 +00:00
|
|
|
|
|
|
|
|
if (closest != null)
|
|
|
|
|
{
|
2008-07-25 05:15:05 +00:00
|
|
|
Client.Self.RequestSit(closest.ID, Vector3.Zero);
|
2007-04-28 20:54:02 +00:00
|
|
|
Client.Self.Sit();
|
|
|
|
|
|
2008-07-09 00:42:04 +00:00
|
|
|
return "Sat on " + closest.ID + " (" + closest.LocalID + "). Distance: " + closestDistance;
|
2007-04-28 20:54:02 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return "Couldn't find a nearby prim to sit on";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|