Files
libremetaverse/libsecondlife-cs/examples/TestClient/Commands/SitCommand.cs
John Hurliman 4881411127 * Helpers.StringToField() returns an empty byte array when given an empty string
* MediaUrl can be set with Objects.SetTextures() now
* TestClient no longer sets appearance at bot login, until the appearance code is more reliable
* Some ImportCommand improvements

git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@699 52acb1d6-8a22-11de-b505-999d5b087335
2006-12-09 14:39:17 +00:00

50 lines
1.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
using libsecondlife.Packets;
namespace libsecondlife.TestClient
{
public class SitCommand: Command
{
public SitCommand()
{
Name = "sit";
Description = "Attempt to sit on the closest prim";
}
public override string Execute(SecondLife Client, string[] args, LLUUID fromAgentID)
{
PrimObject closest = null;
double closestDistance = Double.MaxValue;
lock (TestClient.Prims)
{
foreach (PrimObject p in TestClient.Prims.Values)
{
float distance = Helpers.VecDist(Client.Self.Position, p.Position);
if (closest == null || distance < closestDistance)
{
closest = p;
closestDistance = distance;
}
}
}
if (closest != null)
{
Client.Self.RequestSit(closest.ID, LLVector3.Zero);
Client.Self.Sit();
return TestClient.Prims.Count + " prims. Sat on " + closest.ID + ". Distance: " + closestDistance;
}
else
{
return "Couldn't find a nearby prim to sit on";
}
}
}
}