From 5b6afeafbc249ba88dcc20d1fbc98ce12418b21b Mon Sep 17 00:00:00 2001 From: gareth Date: Tue, 8 May 2007 00:10:04 +0000 Subject: Brought in TestClient code for teh fork --- ExportBot/Commands/Movement/SitCommand.cs | 52 +++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 ExportBot/Commands/Movement/SitCommand.cs (limited to 'ExportBot/Commands/Movement/SitCommand.cs') diff --git a/ExportBot/Commands/Movement/SitCommand.cs b/ExportBot/Commands/Movement/SitCommand.cs new file mode 100644 index 0000000..b9ef6be --- /dev/null +++ b/ExportBot/Commands/Movement/SitCommand.cs @@ -0,0 +1,52 @@ +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; + + lock (Client.SimPrims) + { + if (Client.SimPrims.ContainsKey(Client.Network.CurrentSim)) + { + foreach (Primitive p in Client.SimPrims[Client.Network.CurrentSim].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 "Sat on " + closest.ID + ". Distance: " + closestDistance; + } + else + { + return "Couldn't find a nearby prim to sit on"; + } + } + } +} -- cgit v1.1