Beispiel #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 (p.IsSuper)
            {
                // undo them across all loaded levels
                Level[] levels = LevelInfo.Loaded.Items;

                foreach (Level lvl in levels)
                {
                    op.SetMarks(marks);
                    op.SetLevel(lvl);
                    op.Player = p;
                    DrawOpPerformer.Execute(p, op, null, marks);
                }
                p.level = null;
            }
            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
            {
                p.Message("No changes found by {1} %Sin the past &b{0}", delta.Shorten(true), namesStr);
            }
        }
Beispiel #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)   // TODO bug assumes no other queued drawops
            {
                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);
            }
        }