2006-11-22 00:09:31 +00:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using libsecondlife;
|
|
|
|
|
using libsecondlife.Packets;
|
|
|
|
|
|
2006-11-24 22:27:15 +00:00
|
|
|
namespace libsecondlife.TestClient
|
2006-11-22 00:09:31 +00:00
|
|
|
{
|
|
|
|
|
public class SitCommand: Command
|
|
|
|
|
{
|
2006-12-21 08:53:08 +00:00
|
|
|
public SitCommand(TestClient testClient)
|
2006-11-22 00:09:31 +00:00
|
|
|
{
|
|
|
|
|
Name = "sit";
|
2006-12-09 14:39:17 +00:00
|
|
|
Description = "Attempt to sit on the closest prim";
|
2006-11-22 00:09:31 +00:00
|
|
|
}
|
2006-12-16 09:07:28 +00:00
|
|
|
|
2006-12-21 08:53:08 +00:00
|
|
|
public override string Execute(string[] args, LLUUID fromAgentID)
|
2006-11-22 00:09:31 +00:00
|
|
|
{
|
|
|
|
|
PrimObject closest = null;
|
|
|
|
|
double closestDistance = Double.MaxValue;
|
|
|
|
|
|
2007-01-04 05:41:23 +00:00
|
|
|
lock (Client.SimPrims)
|
2006-11-22 00:09:31 +00:00
|
|
|
{
|
2007-01-04 05:41:23 +00:00
|
|
|
if (Client.SimPrims.ContainsKey(Client.Network.CurrentSim))
|
2006-12-13 21:15:49 +00:00
|
|
|
{
|
2007-01-04 05:41:23 +00:00
|
|
|
foreach (PrimObject p in Client.SimPrims[Client.Network.CurrentSim].Values)
|
2006-12-13 21:15:49 +00:00
|
|
|
{
|
|
|
|
|
float distance = Helpers.VecDist(Client.Self.Position, p.Position);
|
2006-11-22 00:09:31 +00:00
|
|
|
|
2006-12-13 21:15:49 +00:00
|
|
|
if (closest == null || distance < closestDistance)
|
|
|
|
|
{
|
|
|
|
|
closest = p;
|
|
|
|
|
closestDistance = distance;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-11-22 00:09:31 +00:00
|
|
|
}
|
|
|
|
|
|
2006-12-09 14:39:17 +00:00
|
|
|
if (closest != null)
|
|
|
|
|
{
|
|
|
|
|
Client.Self.RequestSit(closest.ID, LLVector3.Zero);
|
|
|
|
|
Client.Self.Sit();
|
|
|
|
|
|
2006-12-13 21:15:49 +00:00
|
|
|
return "Sat on " + closest.ID + ". Distance: " + closestDistance;
|
2006-12-09 14:39:17 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return "Couldn't find a nearby prim to sit on";
|
|
|
|
|
}
|
2006-11-22 00:09:31 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|