public static Level Setup(DrawOp op, Player p, Vec3S32[] marks)
        {
            op.SetMarks(marks);
            Level lvl = p.level;

            op.SetLevel(lvl);
            op.Player = p;
            return(lvl);
        }
Beispiel #2
0
        public static bool DoDrawOp(DrawOp op, Brush brush, Player p,
                                    Vec3S32[] marks, bool checkLimit = true)
        {
            op.SetMarks(marks);
            op.Level  = p == null ? null : p.level;
            op.Player = p;

            if (op.Level != null && !op.Level.DrawingAllowed)
            {
                Player.Message(p, "Drawing commands are turned off on this map.");
                return(false);
            }
            if (op.Level != null && op.Level.BuildAccess.Check(p) == LevelAccess.Blacklisted)
            {
                Player.Message(p, "You are blacklisted from building in this map, " +
                               "hence you cannot draw in this map");
                return(false);
            }

            long affected = op.BlocksAffected(op.Level, marks);

            if (p != null && op.AffectedByTransform)
            {
                p.Transform.GetBlocksAffected(ref affected);
            }

            if (checkLimit && !op.CanDraw(marks, p, affected))
            {
                return(false);
            }
            if (brush != null && affected != -1)
            {
                const string format = "{0}({1}): affecting up to {2} blocks";
                Player.Message(p, format, op.Name, brush.Name, affected);
            }
            else if (affected != -1)
            {
                const string format = "{0}: affecting up to {1} blocks";
                Player.Message(p, format, op.Name, affected);
            }

            AppendDrawOp(p, op, brush, marks, affected);
            return(true);
        }