2007-04-28 20:54:02 +00:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using libsecondlife;
|
|
|
|
|
using libsecondlife.Packets;
|
|
|
|
|
|
|
|
|
|
namespace libsecondlife.TestClient
|
|
|
|
|
{
|
|
|
|
|
public class SitCommand: Command
|
|
|
|
|
{
|
|
|
|
|
public SitCommand(TestClient testClient)
|
|
|
|
|
{
|
|
|
|
|
Name = "sit";
|
|
|
|
|
Description = "Attempt to sit on the closest prim";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string Execute(string[] args, LLUUID fromAgentID)
|
|
|
|
|
{
|
|
|
|
|
Primitive closest = null;
|
|
|
|
|
double closestDistance = Double.MaxValue;
|
|
|
|
|
|
2007-08-29 08:55:53 +00:00
|
|
|
Client.Network.CurrentSim.Objects.ForEach(
|
|
|
|
|
delegate(Primitive prim)
|
2007-04-28 20:54:02 +00:00
|
|
|
{
|
2007-11-06 09:26:10 +00:00
|
|
|
float distance = LLVector3.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)
|
|
|
|
|
{
|
|
|
|
|
Client.Self.RequestSit(closest.ID, LLVector3.Zero);
|
|
|
|
|
Client.Self.Sit();
|
|
|
|
|
|
|
|
|
|
return "Sat on " + closest.ID + ". Distance: " + closestDistance;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return "Couldn't find a nearby prim to sit on";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|