コード例 #1
0
ファイル: CmdReplaceBrush.cs プロジェクト: Benedani/MCGalaxy
        bool DoReplace(Player p, Vec3S32[] marks, object state, byte type, byte extType)
        {
            string[] args     = ((string)state).SplitSpaces(3);
            byte     extBlock = 0;
            int      block    = DrawCmd.GetBlockIfAllowed(p, args[0], out extBlock);

            if (block == -1)
            {
                return(false);
            }

            BrushFactory factory      = BrushFactory.Find(args[1]);
            string       brushMessage = args.Length > 2 ? args[2] : "";
            BrushArgs    bArgs        = new BrushArgs(p, brushMessage, type, extType);
            Brush        brush        = factory.Construct(bArgs);

            if (brush == null)
            {
                return(false);
            }

            DrawOp op = null;

            if (ReplaceNot)
            {
                op = new ReplaceNotDrawOp((byte)block, extBlock);
            }
            else
            {
                op = new ReplaceDrawOp((byte)block, extBlock);
            }
            return(DrawOp.DoDrawOp(op, brush, p, marks));
        }
コード例 #2
0
        static Brush ParseBrush(string raw, Player p, ExtBlock block)
        {
            string[]     parts = raw.SplitSpaces(2);
            BrushFactory brush = BrushFactory.Find(parts[0]);

            if (brush == null)
            {
                Player.Message(p, "No brush found with name \"{0}\".", parts[0]);
                Player.Message(p, "Available brushes: " + BrushFactory.Available);
                return(null);
            }

            string    brushArgs = parts.Length >= 2 ? parts[1].ToLower() : "";
            BrushArgs args      = new BrushArgs(p, brushArgs, block);

            return(brush.Construct(args));
        }
コード例 #3
0
        protected virtual bool DoDraw(Player p, Vec3S32[] marks,
                                      object state, byte block, byte extBlock)
        {
            DrawArgs dArgs = (DrawArgs)state;

            dArgs.Block = block; dArgs.ExtBlock = extBlock;
            GetMarks(dArgs, ref marks);
            if (marks == null)
            {
                return(false);
            }

            int          offset  = 0;
            BrushFactory factory = BrushFactory.Find(GetBrush(p, dArgs, ref offset));
            BrushArgs    bArgs   = GetBrushArgs(dArgs, offset);
            Brush        brush   = factory.Construct(bArgs);

            return(brush != null && DrawOp.DoDrawOp(dArgs.Op, brush, p, marks));
        }
コード例 #4
0
        protected virtual bool DoDraw(Player p, Vec3S32[] marks, object state, BlockID block)
        {
            DrawArgs dArgs = (DrawArgs)state;

            dArgs.Block = block;
            GetMarks(dArgs, ref marks);
            if (marks == null)
            {
                return(false);
            }

            BrushFactory factory = MakeBrush(dArgs);
            BrushArgs    bArgs   = new BrushArgs(p, dArgs.BrushArgs, dArgs.Block);
            Brush        brush   = factory.Construct(bArgs);

            if (brush == null)
            {
                return(false);
            }

            DrawOpPerformer.Do(dArgs.Op, brush, p, marks);
            return(true);
        }