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 = 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 + ". Distance: " + closestDistance); } else { return("Couldn't find a nearby prim to sit on"); } }
public override void Think() { // Find the target position lock (Client.Network.Simulators) { for (int i = 0; i < Client.Network.Simulators.Count; i++) { Avatar targetAv; if (Client.Network.Simulators[i].ObjectsAvatars.TryGetValue(targetLocalID, out targetAv)) { float distance = 0.0f; if (Client.Network.Simulators[i] == Client.Network.CurrentSim) { distance = LLVector3.Dist(targetAv.Position, Client.Self.SimPosition); } else { // FIXME: Calculate global distances } if (distance > DISTANCE_BUFFER) { uint regionX, regionY; Helpers.LongToUInts(Client.Network.Simulators[i].Handle, out regionX, out regionY); double xTarget = (double)targetAv.Position.X + (double)regionX; double yTarget = (double)targetAv.Position.Y + (double)regionY; double zTarget = targetAv.Position.Z - 2f; Logger.DebugLog(String.Format("[Autopilot] {0} meters away from the target, starting autopilot to <{1},{2},{3}>", distance, xTarget, yTarget, zTarget), Client); Client.Self.AutoPilot(xTarget, yTarget, zTarget); } else { // We are in range of the target and moving, stop moving Client.Self.AutoPilotCancel(); } } } } base.Think(); }
public override string Execute(string[] args, LLUUID fromAgentID) { // *** parse arguments *** if ((args.Length < 1) || (args.Length > 2)) { return("Usage: findobjects [radius] <search-string>"); } float radius = float.Parse(args[0]); string searchString = (args.Length > 1)? args[1] : ""; // *** get current location *** LLVector3 location = Client.Self.SimPosition; // *** find all objects in radius *** List <Primitive> prims = Client.Network.CurrentSim.Objects.FindAll( delegate(Primitive prim) { LLVector3 pos = prim.Position; return((prim.ParentID == 0) && (pos != LLVector3.Zero) && (LLVector3.Dist(pos, location) < radius)); } ); // *** request properties of these objects *** bool complete = RequestObjectProperties(prims, 250); foreach (Primitive p in prims) { string name = p.Properties.Name; if ((name != null) && (name.Contains(searchString))) { Console.WriteLine(String.Format("Object '{0}': {1}", name, p.ID.ToString())); } } if (!complete) { Console.WriteLine("Warning: Unable to retrieve full properties for:"); foreach (LLUUID uuid in PrimsWaiting.Keys) { Console.WriteLine(uuid); } } return("Done searching"); }