Beispiel #1
0
        static void AppendDrawOp(Player p, DrawOp op, Brush brush, Vec3S32[] marks, long affected)
        {
            if (p == null)
            {
                BufferedBlockSender buffer = new BufferedBlockSender(op.Level);
                op.Perform(marks, brush, b => ConsoleOutputBlock(b, op.Level, buffer));
                buffer.Send(true);
                return;
            }

            PendingDrawOp item = new PendingDrawOp();

            item.Op    = op;
            item.Brush = brush;
            item.Marks = marks;

            lock (p.pendingDrawOpsLock) {
                p.PendingDrawOps.Add(item);
                // Another thread is already processing draw ops.
                if (p.PendingDrawOps.Count > 1)
                {
                    return;
                }
            }
            ProcessDrawOps(p);
        }
        internal static void Execute(Player p, DrawOp op, Brush brush, Vec3S32[] marks)
        {
            UndoDrawOpEntry entry = new UndoDrawOpEntry();

            entry.Init(op.Name, op.Level.name);

            if (brush != null)
            {
                brush.Configure(op, p);
            }
            Level           lvl       = op.Level;
            DrawOpOutputter outputter = new DrawOpOutputter(op);

            if (op.AffectedByTransform)
            {
                p.Transform.Perform(marks, p, lvl, op, brush, outputter.Output);
            }
            else
            {
                op.Perform(marks, brush, outputter.Output);
            }
            bool needsReload = op.TotalModified >= outputter.reloadThreshold;

            if (op.Undoable)
            {
                entry.Finish(p);
            }
            if (needsReload)
            {
                DoReload(p, op.Level);
            }
            op.TotalModified = 0; // reset total modified (as drawop instances are reused in static mode)
        }
Beispiel #3
0
        public override void Perform(Vec3S32[] marks, Brush brush, Action <DrawOpBlock> output)
        {
            Vec3U16 p1 = Clamp(Min), p2 = Clamp(Max);

            wallOp.Min    = Min; wallOp.Max = Max;
            baseOp.Min    = Min; baseOp.Max = Max;
            wallOp.Level  = Level; baseOp.Level = Level;
            wallOp.Player = Player; baseOp.Player = Player;

            while (true)
            {
                wallOp.Perform(marks, brush, output);
                if (p1.Y >= Level.Height || Math.Abs(p2.X - p1.X) <= 1 || Math.Abs(p2.Z - p1.Z) <= 1)
                {
                    return;
                }

                p1.X++; p2.X--;
                p1.Z++; p2.Z--;
                wallOp.Min = p1; wallOp.Max = p2;
                baseOp.Min = p1; baseOp.Max = p2;

                baseOp.Perform(marks, airBrush, output);
                p1.Y       = (ushort)(p1.Y + yDir); p2.Y = p1.Y;
                wallOp.Min = p1; wallOp.Max = p2;
                baseOp.Min = p1; baseOp.Max = p2;
            }
        }
        public override void Perform(Vec3S32[] marks, Brush brush, DrawOpOutput output)
        {
            Vec3U16 p1 = Clamp(Min), p2 = Clamp(Max);

            baseOp.Setup(Player, Level, marks);
            wallOp.Setup(Player, Level, marks);

            while (true)
            {
                wallOp.Perform(marks, brush, output);
                if (p1.Y >= Level.Height || Math.Abs(p2.X - p1.X) <= 1 || Math.Abs(p2.Z - p1.Z) <= 1)
                {
                    return;
                }

                p1.X++; p2.X--;
                p1.Z++; p2.Z--;
                wallOp.Min = p1; wallOp.Max = p2;
                baseOp.Min = p1; baseOp.Max = p2;

                baseOp.Perform(marks, airBrush, output);
                p1.Y       = (ushort)(p1.Y + yDir); p2.Y = p1.Y;
                wallOp.Min = p1; wallOp.Max = p2;
                baseOp.Min = p1; baseOp.Max = p2;
            }
        }
        public override void Perform(Vec3S32[] marks, Brush brush, DrawOpOutput output)
        {
            Vec3S32 p1 = Min, p2 = Max;

            baseOp.Setup(Player, Level, marks);

            while (p1.Y >= 0 && p1.Y < Level.Height && p1.X <= p2.X && p1.Z <= p2.Z)
            {
                baseOp.Min = p1; baseOp.Max = p2;
                baseOp.Perform(marks, brush, output);

                p1.X++; p2.X--;
                p1.Z++; p2.Z--;
                p1.Y += yDir; p2.Y = p1.Y;
            }
        }
Beispiel #6
0
        public override void Perform(Vec3U16[] marks, Player p, Level lvl, Brush brush)
        {
            Vec3U16 p1 = marks[0], p2 = marks[1];

            while (true)
            {
                baseOp.Perform(marks, p, lvl, brush);
                if (p1.Y >= lvl.Height || Math.Abs(p2.X - p1.X) <= 1 || Math.Abs(p2.Z - p1.Z) <= 1)
                {
                    break;
                }
                p1.X++; p2.X--;
                p1.Z++; p2.Z--;
                p1.Y     = (ushort)(p1.Y + yDir); p2.Y = p1.Y;
                marks[0] = p1; marks[1] = p2;
            }
        }
Beispiel #7
0
        public override void Perform(Vec3S32[] marks, Brush brush, DrawOpOutput output)
        {
            Vec3S32 p1 = Min, p2 = Max;

            baseOp.SetLevel(Level);
            baseOp.Player = Player;

            while (true)
            {
                baseOp.Perform(marks, brush, output);
                if (p1.Y >= Level.Height || Math.Abs(p2.X - p1.X) <= 1 || Math.Abs(p2.Z - p1.Z) <= 1)
                {
                    return;
                }

                p1.X++; p2.X--;
                p1.Z++; p2.Z--;
                p1.Y       = (ushort)(p1.Y + yDir); p2.Y = p1.Y;
                baseOp.Min = p1; baseOp.Max = p2;
            }
        }