public List <SimObject> StartGetUnionExprsn(string[] args, out int argsUsed) { int argl = args.Length; if (argl == 0) { argsUsed = 0; return(new List <SimObject>()); } int argsUsedLocally; string arg0Lower = args[0].ToLower(); List <SimObject> starterSet = null; starterSet = ColToList(ResolveGroupVar(arg0Lower)); if (arg0Lower.StartsWith("$") && false) { argsUsed = 1; return(starterSet); } argsUsedLocally = starterSet != null ? 1 : 0; if (argl == argsUsedLocally) { argsUsed = argl; return(starterSet); } if (argsUsedLocally > 0) { args = Parser.SplitOff(args, argsUsedLocally); } else if (arg0Lower.StartsWith("+")) { starterSet = new List <SimObject>(); } else { starterSet = SimRootObjects.CopyOf(); } ICollection filterSimObjects = GetUnionExprsn(args, out argsUsed, starterSet, false, TheSimAvatar); if (argsUsed == 0 && args.Length != 0) { // filter failed throw new ParserFilterFormatException(arg0Lower, args, 0); } var prims = new List <SimObject>(); AsPrimitives(prims, filterSimObjects); if (argsUsed >= args.Length) { return(prims); } if (args[argsUsed - 1] == "]") { return(prims); } arg0Lower = args[argsUsed].ToLower(); if (arg0Lower == "]") { return(prims); } if (arg0Lower == "and" || arg0Lower == ",") { argsUsed++; int moreUsed; var more = GetUnion(Parser.SplitOff(args, argsUsed), out moreUsed); argsUsed += moreUsed; AsPrimitives(prims, more); } argsUsed += argsUsedLocally; return(prims); }
public List <SimObject> GetSingleArg(string[] splitted, out int argsUsed) { if (splitted.Length == 0) { argsUsed = 0; return(new List <SimObject>()); } SimObject prim; UUID uuid = UUID.Zero; string name = splitted[0].Trim().Replace(" ", " "); if (name.IndexOf("-") > 2 && UUID.TryParse(name, out uuid)) { prim = GetSimObjectFromUUID(uuid); argsUsed = 1; return(PrimOrNot(prim)); } var resolve = name.ToLower(); /* * if (resolve.Equals("pointing") || resolve.Equals("it")) * { * argsUsed = 1; * if (!client.TheRadegastInstance.State.IsPointing) * { * prim = null; * return false; * } * prim = GetPrimitive(client.TheRadegastInstance.State.TargetID, null); * return prim != null; * } */ foreach (string primid in new[] { "primid", "lid" }) { if (resolve.StartsWith(primid)) { int tl = primid.Length; if (name.Length > tl) { String s = name.Substring(tl); uint localID; if (uint.TryParse(s, out localID)) { prim = GetSimObject(localID, null); argsUsed = 1; return(PrimOrNot(prim)); } } } } if (name.StartsWith("@")) { int splitOffset = 0; name = name.Substring(1); if (name.Length == 0) { splitOffset = 1; splitted = Parser.SplitOff(splitted, 1); } else { splitted[0] = name; } int argsUsed0; SimPosition position = GetVector(splitted, out argsUsed0); if (argsUsed0 == 0) { argsUsed = splitOffset; prim = null; return(PrimOrNot(prim)); } double dist; prim = GetSimObjectFromVector(position.GlobalPosition, out dist); argsUsed = argsUsed0 + splitOffset; if (dist > 2) { prim = null; } return(PrimOrNot(prim)); } if (name.StartsWith("$")) { return(ResolveCollection(name, out argsUsed)); } if (name.StartsWith("[")) { var fnd = GetUnion(Parser.SplitOff(splitted, 1), out argsUsed); argsUsed++; if (argsUsed < splitted.Length) { string t = splitted[argsUsed]; if (t == "]") { argsUsed++; } } return(fnd); } if (name == "+") { var fnd = GetSingleArg(Parser.SplitOff(splitted, 1), out argsUsed); argsUsed++; return(fnd); } if (name.StartsWith("(")) { argsUsed = 1; var result = GridMaster.client.evalLispCode(name); var acol = SingleNameValue.AsCollection(result); if (acol == null) { argsUsed = 0; } var fnd = new List <SimObject>(); GridMaster.AsPrimitives(fnd, acol); return(fnd); } int nth; if (int.TryParse(name, out nth)) { nth--; splitted = Parser.SplitOff(splitted, 1); List <SimObject> fnd = null; if (splitted.Length == 0) { argsUsed = 1; fnd = SimRootObjects.CopyOf(); } else { fnd = GetSingleArg(splitted, out argsUsed); } if (fnd == null) { return(fnd); } if (nth >= fnd.Count) { nth = fnd.Count - 1; } if (nth < 0) { return(null); } if (m_TheSimAvatar != null) { fnd.Sort(((SimObject)m_TheSimAvatar).CompareDistance); } return(new List <SimObject>() { fnd[nth] }); } int len = splitted.Length; if (len > 1) { len = 2; } string largs = name.Replace("_", " "); if (largs.Contains(" ")) { len = 1; } argsUsed = 0; for (int i = len; i > 0; i--) { var fnd = new List <SimObject>(); name = string.Join(" ", splitted, 0, i); foreach (var o in SimObjects) { if (o.Matches(name)) { fnd.Add(o); argsUsed = i; } } if (fnd.Count > 0) { return(fnd); } } return(null); }