private SimPosition GetSimV(string[] tokens, int start, out int argsUsed, SimPosition offset) { // not enough args if (tokens.Length < start) { argsUsed = 0; return(offset); } if (start > 0) { tokens = Parser.SplitOff(tokens, start); start = 0; } int maxArgs = 0; string first = tokens[0]; argsUsed = 1; if (first == "last") { return(offset); } if (first.EndsWith("s")) { first = first.Substring(0, first.Length - 1); } if (first == "forward") { return(SimOffsetPosition.WithOrientation(offset, new Vector3(0, 1, 0))); } if (first.EndsWith("ward")) { first = first.Substring(0, first.Length - 4); } if (first == "west") { return(new SimOffsetPosition(offset, new Vector3(-1, 0, 0))); } if (first == "east") { return(new SimOffsetPosition(offset, new Vector3(1, 0, 0))); } if (first == "north") { return(new SimOffsetPosition(offset, new Vector3(0, 1, 0))); } if (first == "south") { return(new SimOffsetPosition(offset, new Vector3(0, -1, 0))); } if (first == "left") { return(SimOffsetPosition.WithOrientation(offset, new Vector3(-1, 0, 0))); } if (first == "right") { return(SimOffsetPosition.WithOrientation(offset, new Vector3(1, 0, 0))); } if (first == "back") { return(SimOffsetPosition.WithOrientation(offset, new Vector3(0, -1, 0))); } if (first.Contains("/")) { argsUsed = 1; int uu; return(GetSimV(first.Split(new char[] { '/' }), 0, out uu, offset)); } bool relative = false; for (int st = start; st < tokens.Length; st++) { if (maxArgs > 2) { break; } string str = tokens[st]; double doublke; if (double.TryParse(str, out doublke)) { maxArgs++; } else { break; } } Vector3 rel = offset.SimPosition; Vector3 target; first = tokens[start]; // Polar coords if (first.Contains("*")) { return(GetPolarRelative(offset, first, out argsUsed)); } if (RelTryParse(first, out target.X, rel.X) && RelTryParse(tokens[start + 1], out target.Y, rel.Y)) { argsUsed = 2; target.Z = rel.Z; if (tokens.Length > start + 1) { RelTryParse(tokens[start + 2], out target.Z, rel.Z); argsUsed = 3; } if (target.X > 512 || target.Y > 512) { // Globals return(SimWaypointImpl.CreateGlobal(target.X, target.Y, target.Z)); } return(SimWaypointImpl.CreateLocal(target, offset.PathStore)); } argsUsed = 0; return(null); }
public static CmdResult ExecuteRequestProc(CmdRequest args, Command cmd) { if (!args.ContainsKey("to")) { args.SetValue("to", "verb"); } ; if (!cmd.Client.IsLoggedInAndReady) { return(cmd.Failure("Not yet logged in!")); } var TheSimAvatar = cmd.WorldSystem.TheSimAvatar; if (TheSimAvatar.IsSitting && !TheSimAvatar.IsDrivingVehical) { cmd.WriteLine("$bot is standing up before moving."); TheSimAvatar.StandUp(); // WriteLine("$bot is sitting, Please stand up to move."); } SimPosition position; if (!args.TryGetValue("to", out position)) { return(cmd.Failure("I don't understand how to move " + args.str)); } if (position == null) { return(cmd.Failure("Coulnd not resolve location: " + args.str)); } if (!position.IsRegionAttached) { return(cmd.Failure("!IsRegionAttached: " + position)); } if (position.SimPosition == Vector3.Zero) { return(cmd.Failure("SimPosition.Zero: " + position)); } Vector3d delta0 = position.GlobalPosition - TheSimAvatar.GlobalPosition; Vector3 delta = new Vector3((float)delta0.X, (float)delta0.Y, (float)delta0.Z); float fnd; if (args.TryGetValue("dist", out fnd)) { delta.Normalize(); delta = delta * fnd; position = new SimOffsetPosition(TheSimAvatar, delta); } MovementProceedure proc; bool salientProc = args.TryGetValue("sproc", out proc); if (salientProc) { TheSimAvatar.SalientMovementProceedure = proc; } if (args.TryGetValue("proc", out proc)) { TheSimAvatar.SimpleMoveToMovementProceedure = proc; } Vector3d g = position.GlobalPosition; TheSimAvatar.SetClient(cmd.TheBotClient); if (salientProc) { return(cmd.Result(string.Format("SalientGoto: {0},{1},{2}", position, g, position.SimPosition), TheSimAvatar.SalientGoto(position))); } else { TheSimAvatar.SetMoveTarget(position, position.GetSizeDistance()); } //Client.Self.AutoPilot(g.X, g.Y, g.Z); // MoveThread = new Thread(MoveProc); return(cmd.Success(string.Format("SetMoveTarget: {0},{1},{2}", position, g, position.SimPosition))); }