Пример #1
0
        public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine)
        {
            if (Chat.InvokeRequired)
            {
                if (!Instance.MonoRuntime || Chat.IsHandleCreated)
                {
                    Chat.Invoke(new MethodInvoker(() => Execute(name, cmdArgs, WriteLine)));
                }
                return;
            }

            if (cmdArgs.Length == 0)
            {
                if (Instance.State.FollowName == string.Empty)
                {
                    WriteLine("Follow inactive, type {0}follow person name, to start following them", CommandsManager.CmdPrefix);
                }
                else
                {
                    WriteLine("Following {0}", Instance.State.FollowName);
                }
                return;
            }

            string cmd = string.Join(" ", cmdArgs);

            if (cmd == "stop")
            {
                Instance.State.StopFollowing();
                WriteLine("Following stopped");
                return;
            }

            List <UUID> people = Chat.GetAvatarList();
            UUID        person = people.Find((UUID id) => { return(Instance.Names.Get(id).ToLower().StartsWith(cmd.ToLower())); });

            if (person == UUID.Zero)
            {
                WriteLine("Could not find {0}", cmd);
                return;
            }

            Instance.State.Follow(Instance.Names.Get(person), person);
            WriteLine("Following {0}", Instance.State.FollowName);
        }
Пример #2
0
        public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine)
        {
            if (Chat.InvokeRequired)
            {
                if (!Instance.MonoRuntime || Chat.IsHandleCreated)
                {
                    Chat.Invoke(new MethodInvoker(() => Execute(name, cmdArgs, WriteLine)));
                }
                return;
            }
            wl = WriteLine;

            string        cmd  = string.Join(" ", cmdArgs);
            List <string> args = new List <string>(Regex.Split(cmd, @"\s", regexOptions));

            if (args.Count == 0)
            {
                PrintUsage(); return;
            }

            string subcmd = args[0];

            args.RemoveAt(0);
            string subarg = string.Empty;

            // Face certain direction
            int heading = 0;

            if (int.TryParse(subcmd, out heading))
            {
                double rad = 0.0174532925d * heading;
                Client.Self.Movement.UpdateFromHeading(rad, true);
                WriteLine("Facing {0} degrees", heading % 360);
                return;
            }

            if (subcmd == "help")
            {
                PrintFullUsage();
                return;
            }

            KnownHeading kh = null;

            kh = StateManager.KnownHeadings.Find(h => { return(h.ID == subcmd.ToUpper()); });
            if (kh != null)
            {
                Client.Self.Movement.BodyRotation = Client.Self.Movement.HeadRotation = kh.Heading;
                WriteLine("Facing {0}", kh.Name);
                return;
            }

            if (args.Count == 0)
            {
                PrintUsage(); return;
            }
            subarg = string.Join(" ", args.ToArray());

            // Move towards
            switch (subcmd)
            {
            case "person":
                List <UUID> people = Chat.GetAvatarList();
                UUID        person = people.Find(id => { return(Instance.Names.Get(id).ToLower().StartsWith(subarg.ToLower())); });
                if (person == UUID.Zero)
                {
                    WriteLine("Could not find {0}", subarg);
                    return;
                }
                string pname = Instance.Names.Get(person);

                if (!Instance.State.TryFindAvatar(person, out targetPos))
                {
                    WriteLine("Could not locate {0}", pname);
                    return;
                }

                WriteLine("Facing {0}", pname);
                Client.Self.Movement.TurnToward(targetPos);

                return;

            case "object":

                if (!TC.TabExists("objects"))
                {
                    RadegastTab tab = TC.AddTab("objects", "Objects", new ObjectsConsole(Instance));
                    tab.AllowClose  = true;
                    tab.AllowDetach = true;
                    tab.Visible     = true;
                    tab.AllowHide   = false;
                    ((ObjectsConsole)tab.Control).RefreshObjectList();
                    TC.Tabs["chat"].Select();

                    WriteLine("Objects list was not active. Started getting object names, please try again in a minute.");
                    return;
                }

                Objects = (ObjectsConsole)TC.Tabs["objects"].Control;
                List <Primitive> prims = Objects.GetObjectList();

                Primitive target = prims.Find(prim =>
                {
                    return(prim.Properties != null &&
                           prim.Properties.Name.ToLower().Contains(subarg.ToLower()));
                });

                if (target == null)
                {
                    WriteLine("Could not find '{0}' nearby", subarg);
                    return;
                }

                targetPos = target.Position;

                WriteLine("Facing object '{0}'", target.Properties.Name);
                Client.Self.Movement.TurnToward(targetPos);
                return;

            default:
                WriteLine("Unrecognized face command {0}", subcmd);
                return;
            }
        }
        public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine)
        {
            if (Chat.InvokeRequired)
            {
                if (!Instance.MonoRuntime || Chat.IsHandleCreated)
                {
                    Chat.Invoke(new MethodInvoker(() => Execute(name, cmdArgs, WriteLine)));
                }
                return;
            }
            wl = WriteLine;

            if (cmdArgs.Length == 0)
            {
                PrintUsage(); return;
            }

            string        cmd  = string.Join(" ", cmdArgs);
            List <string> args = new List <string>(Regex.Split(cmd, @"\s"));

            string subcmd = args[0];

            args.RemoveAt(0);
            if (args.Count == 0)
            {
                PrintUsage(); return;
            }
            string subarg = string.Join(" ", args.ToArray());

            Primitive seat = null;

            if (Client.Self.SittingOn != 0)
            {
                Client.Network.CurrentSim.ObjectsPrimitives.TryGetValue(Client.Self.SittingOn, out seat);
            }

            Vector3 mypos = Client.Self.RelativePosition;

            if (seat != null)
            {
                mypos = seat.Position + mypos;
            }
            StringBuilder sb = new StringBuilder();

            if (subcmd == "object")
            {
                if (!TC.TabExists("objects"))
                {
                    RadegastTab tab = TC.AddTab("objects", "Objects", new ObjectsConsole(Instance));
                    tab.AllowClose  = true;
                    tab.AllowDetach = true;
                    tab.Visible     = true;
                    tab.AllowHide   = false;
                    ((ObjectsConsole)tab.Control).RefreshObjectList();
                    TC.Tabs["chat"].Select();

                    WriteLine("Objects list was not active. Started getting object names, please try again in a minute.");
                    return;
                }

                Objects = (ObjectsConsole)TC.Tabs["objects"].Control;
                List <Primitive> prims = Objects.GetObjectList();

                List <Primitive> targets = prims.FindAll(prim => prim.Properties != null &&
                                                         prim.Properties.Name.ToLower().Contains(subarg.ToLower()));

                if (targets.Count == 0)
                {
                    WriteLine("Could not find '{0}' nearby", subarg);
                    return;
                }

                foreach (Primitive target in targets)
                {
                    Vector3 heading = StateManager.RotToEuler(Vector3.RotationBetween(Vector3.UnitX, Vector3.Normalize(target.Position - mypos)));
                    int     facing  = (int)(57.2957795d * heading.Z);
                    if (facing < 0)
                    {
                        facing = 360 + facing;
                    }

                    sb.AppendFormat("{0} is {1:0} meters away to the {2}",
                                    target.Properties.Name,
                                    Vector3.Distance(mypos, target.Position),
                                    StateManager.ClosestKnownHeading(facing)
                                    );

                    float elev = target.Position.Z - mypos.Z;
                    if (Math.Abs(elev) < 2f)
                    {
                        sb.Append(" at our level");
                    }
                    else if (elev > 0)
                    {
                        sb.AppendFormat(", {0:0} meters above our level", elev);
                    }
                    else
                    {
                        sb.AppendFormat(", {0:0} meters below our level", -elev);
                    }

                    sb.AppendLine();
                }

                wl(sb.ToString());

                return;
            }

            if (subcmd == "person")
            {
                List <UUID> people = Chat.GetAvatarList();
                people = people.FindAll(id => id != Client.Self.AgentID && Instance.Names.Get(id).ToLower().StartsWith(subarg.ToLower()));
                if (people.Count == 0)
                {
                    WriteLine("Could not find {0}", subarg);
                    return;
                }

                foreach (UUID person in people)
                {
                    string pname = Instance.Names.Get(person);

                    Vector3 targetPos = Vector3.Zero;

                    // try to find where they are
                    Avatar avi = Client.Network.CurrentSim.ObjectsAvatars.Find(av => av.ID == person);

                    if (avi != null)
                    {
                        if (avi.ParentID == 0)
                        {
                            targetPos = avi.Position;
                        }
                        else
                        {
                            Primitive theirSeat;
                            if (Client.Network.CurrentSim.ObjectsPrimitives.TryGetValue(avi.ParentID, out theirSeat))
                            {
                                targetPos = theirSeat.Position + avi.Position;
                            }
                        }
                    }
                    else
                    {
                        if (Client.Network.CurrentSim.AvatarPositions.ContainsKey(person))
                        {
                            targetPos = Client.Network.CurrentSim.AvatarPositions[person];
                        }
                    }

                    if (targetPos.Z < 0.01f)
                    {
                        WriteLine("Could not locate {0}", pname);
                        return;
                    }

                    Vector3 heading = StateManager.RotToEuler(Vector3.RotationBetween(Vector3.UnitX, Vector3.Normalize(targetPos - mypos)));
                    int     facing  = (int)(57.2957795d * heading.Z);
                    if (facing < 0)
                    {
                        facing = 360 + facing;
                    }

                    sb.AppendFormat("{0} is {1:0} meters away to the {2}",
                                    pname,
                                    Vector3.Distance(mypos, targetPos),
                                    StateManager.ClosestKnownHeading(facing)
                                    );

                    float elev = targetPos.Z - mypos.Z;
                    if (Math.Abs(elev) < 2f)
                    {
                        sb.Append(" at our level");
                    }
                    else if (elev > 0)
                    {
                        sb.AppendFormat(", {0:0} meters above our level", elev);
                    }
                    else
                    {
                        sb.AppendFormat(", {0:0} meters below our level", -elev);
                    }

                    sb.AppendLine();
                }

                wl(sb.ToString());
            }
        }
Пример #4
0
        public override void Execute(string name, string[] cmdArgs, ConsoleWriteLine WriteLine)
        {
            if (Chat.InvokeRequired)
            {
                if (!Instance.MonoRuntime || Chat.IsHandleCreated)
                {
                    Chat.Invoke(new MethodInvoker(() => Execute(name, cmdArgs, WriteLine)));
                }
                return;
            }
            wl = WriteLine;

            string        cmd  = string.Join(" ", cmdArgs);
            List <string> args = new List <string>(Regex.Split(cmd, @"\s", regexOptions));

            if (args.Count == 0)
            {
                PrintUsage(); return;
            }

            bool useTP = false;

            if (args[0] == "tp")
            {
                useTP = true;
                args.RemoveAt(0);
            }

            if (args.Count == 0)
            {
                PrintUsage(); return;
            }

            string subcmd = args[0];

            args.RemoveAt(0);
            string subarg = string.Empty;

            // Move certain distance
            int distance = 0;

            if (int.TryParse(subcmd, out distance))
            {
                if (distance < 1)
                {
                    return;
                }
                Quaternion   heading = Client.Self.Movement.BodyRotation;
                KnownHeading kh      = null;

                if (args.Count > 0)
                {
                    kh = StateManager.KnownHeadings.Find((KnownHeading h) => { return(h.ID == args[0].ToUpper()); });
                    if (kh != null)
                    {
                        heading = kh.Heading;
                    }
                }

                targetPos = Client.Self.SimPosition + new Vector3((float)distance, 0f, 0f) * heading;
                Client.Self.Movement.BodyRotation = Client.Self.Movement.HeadRotation = heading;
                Client.Self.Movement.Camera.LookAt(Client.Self.SimPosition, targetPos);
                Client.Self.Movement.SendUpdate(true);
                WriteLine("Going {0} to {1:0},{2:0},{3:0}", kh == null ? string.Empty : kh.Name, targetPos.X, targetPos.Y, targetPos.Z);
                Instance.State.MoveTo(targetPos, useTP);
                return;
            }

            if (subcmd == "help")
            {
                PrintFullUsage();
                return;
            }

            if (args.Count == 0)
            {
                PrintUsage(); return;
            }
            subarg = string.Join(" ", args.ToArray());

            // Move towards
            switch (subcmd)
            {
            case "xyz":
                string[] coords = Regex.Split(subarg, @"\D+");
                if (coords.Length < 2)
                {
                    PrintUsage(); return;
                }
                int x = int.Parse(coords[0]);
                int y = int.Parse(coords[1]);
                int z = coords.Length > 2 ? int.Parse(coords[2]) : (int)Client.Self.SimPosition.Z;
                targetPos = new Vector3(x, y, z);
                WriteLine("Going to {0:0},{1:0},{2:0}", targetPos.X, targetPos.Y, targetPos.Z);
                Instance.State.MoveTo(targetPos, useTP);
                return;

            case "person":
                List <UUID> people = Chat.GetAvatarList();
                UUID        person = people.Find((UUID id) => { return(Instance.Names.Get(id).ToLower().StartsWith(subarg.ToLower())); });
                if (person == UUID.Zero)
                {
                    WriteLine("Could not find {0}", subarg);
                    return;
                }
                string pname = Instance.Names.Get(person);

                targetPos = Vector3.Zero;

                if (!Instance.State.TryFindAvatar(person, out targetPos))
                {
                    WriteLine("Could not locate {0}", pname);
                    return;
                }

                WriteLine("Going to {3} at {0:0},{1:0},{2:0}", targetPos.X, targetPos.Y, targetPos.Z, pname);
                Instance.State.MoveTo(targetPos, useTP);

                return;

            case "object":

                if (!TC.TabExists("objects"))
                {
                    METAboltTab tab = TC.AddTab("objects", "Objects", new ObjectsConsole(Instance));
                    tab.AllowClose  = true;
                    tab.AllowDetach = true;
                    tab.Visible     = true;
                    tab.AllowHide   = false;
                    ((ObjectsConsole)tab.Control).RefreshObjectList();
                    WriteLine("Objects list was not active. Started getting object names, please try again in a minute.");
                    TC.Tabs["chat"].Select();
                    return;
                }

                Objects = (ObjectsConsole)TC.Tabs["objects"].Control;
                List <Primitive> prims = Objects.GetObjectList();

                Primitive target = prims.Find((Primitive prim) =>
                {
                    return(prim.Properties != null &&
                           prim.Properties.Name.ToLower().Contains(subarg.ToLower()));
                });

                if (target == null)
                {
                    WriteLine("Could not find '{0}' nearby", subarg);
                    return;
                }

                targetPos = target.Position;

                WriteLine("Going to object '{0}' at {1:0},{2:0},{3:0}", target.Properties.Name, targetPos.X, targetPos.Y, targetPos.Z);
                Instance.State.MoveTo(targetPos, useTP);
                return;

            default:
                WriteLine("Unrecognized go command {0}", subcmd);
                return;
            }
        }