Files
libremetaverse/libsecondlife/examples/TestClient/Commands/Movement/SitCommand.cs
John Hurliman 349830c983 * Object tracker dictionaries are now internal and only accessible through various methods and properties to prevent locking disasters. Basis of this code written by jradford in issue 342
* Added a Client.Self.Name property for the full name of the avatar which does smart caching
* Adds BackupCommand to TestClient (submitted by CheechBode in issue 314), backs up notecards and scripts from your inventory to hard drive. Needs more refining but it works
* Parsing problems in TestClient no longer crash the app

git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@1378 52acb1d6-8a22-11de-b505-999d5b087335
2007-08-29 08:55:53 +00:00

49 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(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;
Client.Network.CurrentSim.Objects.ForEach(
delegate(Primitive prim)
{
float distance = Helpers.VecDist(Client.Self.Position, prim.Position);
if (closest == null || distance < closestDistance)
{
closest = prim;
closestDistance = distance;
}
}
);
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";
}
}
}
}