public override CmdResult ExecuteRequest(CmdRequest args) { if (args.Length < 1) { return(ShowUsage()); } int argsUsed; foreach (var p in WorldSystem.GetPrimitives(args, out argsUsed)) { if (p is SimAvatar) { SimAvatar a = (SimAvatar)p; AddSuccess("Showing " + a); TheBotClient.InvokeGUI(() => new Radegast.frmProfile(TheBotClient.TheRadegastInstance, a.GetName(), a.ID).Show()); } } return(SuccessOrFailure()); }
static public string argString(object arg) { if (arg == null) { return("NIL"); } Type type = arg.GetType(); if (arg is BotClient) { arg = ((BotClient)arg).GetAvatar(); if (arg is BotClient) { return(((BotClient)arg).ToString()); } } if (arg is WorldObjects) { arg = ((WorldObjects)arg).TheSimAvatar; } if (arg is Simulator) { Simulator sim = (Simulator)arg; uint globalX, globalY; Utils.LongToUInts(sim.Handle, out globalX, out globalY); return("'(simulator " + argString(sim.Name) + " " + globalX / 256 + " " + globalY / 256 + " " + argString(sim.IPEndPoint.ToString()) + ")"); } if (arg is Avatar) { Avatar prim = (Avatar)arg; arg = "'(SimAvatarFn "; //+ argString(prim.ID.ToString()); if (prim.Name != null) { arg = arg + " " + argString(prim.Name); } return(arg + ")"); } if ((arg is AssetAnimation) || (arg is AssetTexture) || (arg is AssetSound)) { Asset prim = (Asset)arg; arg = SimAssetStore.GetSimAsset(prim); } if (arg is SimAsset) { SimAsset prim = (SimAsset)arg; AssetType tyepe = prim.AssetType; arg = "'(Sim" + tyepe + "Fn "; //+ argString(prim.ID.ToString()); if (prim.Name != null) { arg = arg + " " + argString(prim.Name); } return(arg + ")"); } if (arg is Primitive) { Primitive prim = (Primitive)arg; arg = "'(SimObjectFn " + argString(prim.ID.ToString()); if (prim.Properties != null) { arg = arg + " " + argString(prim.Properties.Name); } return(arg + ")"); } if (arg is SimAvatar) { SimAvatar prim = (SimAvatar)arg; arg = "'(SimAvatarFn " + argString(prim.GetName()); return(arg + ")"); } if (arg is SimObject) { SimObject prim = (SimObject)arg; arg = "'(SimObjectFn " + argString(prim.ID.ToString()); string name = prim.GetName(); if (!string.IsNullOrEmpty(name)) { arg = arg + " #|" + argString(name) + "|# "; } return(arg + ")"); } if (type.IsEnum) { return(argString(arg.ToString())); } //InternalDictionary if (arg is IList) { String dictname = "'(list " + type.Name; IList list = (IList)arg; foreach (object key in list) { dictname += " " + argString(key); } return(dictname + ")"); } if (arg is Parcel) { String dictname = "'(parcel"; Parcel list = (Parcel)arg; dictname += " " + argString(list.SnapshotID.ToString()); dictname += " " + argString(list.Name); return(dictname + ")"); } if (arg is Group) { String dictname = "'(Group"; Group list = (Group)arg; dictname += " " + argString(list.Name); return(dictname + ")"); } if (arg is IDictionary) { String dictname = "'(dict " + type.Name; IDictionary dict0 = (IDictionary)arg; IDictionary dict = dict0; lock (dict.SyncRoot) { foreach (object key in dict.Keys) { Object o = dict[key]; dictname += " " + argString(key) + "=" + argString(o); } return(dictname + ")"); } } //if (arg is Quaternion) //{ // Quaternion quat = (Quaternion)arg; // quat.Normalize(); // arg = WorldSystem.QuatToRotation(quat); //} if (arg is Quaternion) { Quaternion vect = (Quaternion)arg; return("'(Quaternion " + vect.X + " " + vect.Y + " " + vect.Z + " " + vect.W + ")"); } if (arg is UUID) { // if (true) return argString(arg.ToString()); object found = WorldObjects.GridMaster.GetObject((UUID)arg); if (found == null || found is UUID) { return(argString(arg.ToString())); } return(argString(found)); } if (arg is Vector3) { Vector3 vect = (Vector3)arg; return("'(Vector3 " + vect.X + " " + vect.Y + " " + vect.Z + ")"); } if (arg is Vector2) { Vector2 vect = (Vector2)arg; return("'(Vector2 " + vect.X + " " + vect.Y + ")"); } if (arg is Vector3d) { Vector3d vect = (Vector3d)arg; return("'(Vector3d " + vect.X + " " + vect.Y + " " + vect.Z + ")"); } if (type.IsArray) { Array a = (Array)arg; return("#{/*" + type + "*/" + argsListString(a) + "}"); } if (arg is String) { return("\"" + arg.ToString().Replace("\"", "\\\"") + "\""); } if (type.Namespace.StartsWith("System")) { return("" + arg); } if (arg is IEnumerable) { IEnumerable a = (IEnumerable)arg; return("'(/*" + type + "*/" + argsListString(a) + ")"); } if (type.IsValueType) { String tostr = "{" + arg + ""; foreach (FieldInfo fi in type.GetFields()) { if (!fi.IsStatic) { tostr += ","; tostr += fi.Name + "="; tostr += argString(fi.GetValue(arg)); } } return(argString(tostr + "}")); } if (!type.IsValueType) { String tostr = "{" + arg + ""; foreach (FieldInfo fi in type.GetFields()) { if (!fi.IsStatic) { tostr += ","; tostr += fi.Name + "="; tostr += fi.GetValue(arg); } } return(argString(tostr + "}")); } return("" + arg); }