Пример #1
0
        static void UndoPlayer(Player p, TimeSpan delta, string[] names, int[] ids, Vec3S32[] marks)
        {
            UndoDrawOp op = new UndoDrawOp();

            op.Start = DateTime.UtcNow.Subtract(delta);
            op.who   = names[0]; op.ids = ids;

            if (Player.IsSuper(p))
            {
                // undo them across all loaded levels
                Level[] levels = LevelInfo.Loaded.Items;
                if (p == null)
                {
                    p = new ConsolePlayer();
                }

                foreach (Level lvl in levels)
                {
                    op.SetMarks(marks);
                    op.SetLevel(lvl);
                    op.Player = p; p.level = lvl;
                    DrawOpPerformer.DoQueuedDrawOp(p, op, null, marks);
                }
            }
            else
            {
                DrawOpPerformer.Do(op, null, p, marks);
            }

            string namesStr = names.Join(name => PlayerInfo.GetColoredName(p, name));

            if (op.found)
            {
                Chat.MessageGlobal("Undid {1}%S's changes for the past &b{0}", delta.Shorten(true), namesStr);
                Logger.Log(LogType.UserActivity, "Actions of {0} for the past {1} were undone.", names.Join(), delta.Shorten(true));
            }
            else
            {
                Player.Message(p, "No changes found by {1} %Sin the past &b{0}", delta.Shorten(true), namesStr);
            }
        }
Пример #2
0
        static void UndoPlayer(Player p, TimeSpan delta, string[] names, int[] ids, Vec3S32[] marks)
        {
            UndoDrawOp op = new UndoDrawOp();

            op.Start        = DateTime.UtcNow.Subtract(delta);
            op.who          = names[0]; op.ids = ids;
            op.AlwaysUsable = true;

            if (p.IsSuper)
            {
                // undo them across all loaded levels
                Level[] levels = LevelInfo.Loaded.Items;

                foreach (Level lvl in levels)
                {
                    op.Setup(p, lvl, marks);
                    DrawOpPerformer.Execute(p, op, null, marks);
                }
                p.level = null;
            }
            else
            {
                DrawOpPerformer.Do(op, null, p, marks);
            }

            string namesStr = names.Join(name => p.FormatNick(name));

            if (op.found)
            {
                Chat.MessageGlobal("Undid {1}&S's changes for the past &b{0}", delta.Shorten(true), namesStr);
                Logger.Log(LogType.UserActivity, "Actions of {0} for the past {1} were undone.", names.Join(), delta.Shorten(true));
            }
            else
            {
                p.Message("No changes found by {1} &Sin the past &b{0}", delta.Shorten(true), namesStr);
            }
        }