Moving examples, mapgenerator, and VisualParamGenerator to Programs folder (SVN is seriously ruined still, don't check out yet)
git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@1961 52acb1d6-8a22-11de-b505-999d5b087335
This commit is contained in:
48
Programs/examples/TestClient/Commands/Movement/SitCommand.cs
Normal file
48
Programs/examples/TestClient/Commands/Movement/SitCommand.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Packets;
|
||||
|
||||
namespace OpenMetaverse.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.ObjectsPrimitives.ForEach(
|
||||
delegate(Primitive prim)
|
||||
{
|
||||
float distance = LLVector3.Dist(Client.Self.SimPosition, 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 + " (" + closest.LocalID + "). Distance: " + closestDistance;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Couldn't find a nearby prim to sit on";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user