Пример #1
0
 public bool Begin([NotNull] Player player, [NotNull] DrawOperation state)
 {
     if (player == null)
     {
         throw new ArgumentNullException("player");
     }
     if (state == null)
     {
         throw new ArgumentNullException("state");
     }
     if (Block == Block.Undefined)
     {
         if (player.LastUsedBlockType == Block.Undefined)
         {
             player.Message("Cannot deduce desired block. Click a block or type out the block name.");
             return(false);
         }
         else
         {
             Block = player.GetBind(player.LastUsedBlockType);
         }
     }
     return(true);
 }
Пример #2
0
 public DrawOperationBeginningEventArgs(DrawOperation drawOp)
 {
     DrawOp = drawOp;
 }
Пример #3
0
 public DrawOperationEventArgs(DrawOperation drawOp)
 {
     DrawOp = drawOp;
 }
Пример #4
0
        public IBrushInstance MakeInstance([NotNull] Player player, [NotNull] Command cmd, [NotNull] DrawOperation op)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            if (cmd == null)
            {
                throw new ArgumentNullException("cmd");
            }
            if (op == null)
            {
                throw new ArgumentNullException("op");
            }

            if (cmd.HasNext)
            {
                Block block = cmd.NextBlock(player);
                if (block == Block.Undefined)
                {
                    return(null);
                }
                Block altBlock = cmd.NextBlock(player);
                Block1 = block;
                Block2 = altBlock;
            }
            else if (Block1 == Block.Undefined)
            {
                player.Message("{0}: Please specify at least one block.", Factory.Name);
                return(null);
            }

            return(new CheckeredBrush(this));
        }
Пример #5
0
        public IBrushInstance MakeInstance([NotNull] Player player, [NotNull] Command cmd, [NotNull] DrawOperation state)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            if (cmd == null)
            {
                throw new ArgumentNullException("cmd");
            }
            if (state == null)
            {
                throw new ArgumentNullException("state");
            }
            Block block    = Block.Undefined,
                  altBlock = Block.Undefined;

            if (cmd.HasNext)
            {
                block = cmd.NextBlock(player);
                if (block == Block.Undefined)
                {
                    return(null);
                }

                if (cmd.HasNext)
                {
                    altBlock = cmd.NextBlock(player);
                    if (altBlock == Block.Undefined)
                    {
                        return(null);
                    }
                }
            }

            return(new NormalBrush(block, altBlock));
        }
Пример #6
0
 public DrawOperationBeginningEventArgs( DrawOperation drawOp )
 {
     DrawOp = drawOp;
 }
Пример #7
0
 public DrawOperationEventArgs( DrawOperation drawOp )
 {
     DrawOp = drawOp;
 }
Пример #8
0
        public IBrushInstance MakeInstance([NotNull] Player player, [NotNull] Command cmd, [NotNull] DrawOperation state)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            if (cmd == null)
            {
                throw new ArgumentNullException("cmd");
            }
            if (state == null)
            {
                throw new ArgumentNullException("state");
            }

            List <Block> blocks      = new List <Block>();
            List <int>   blockRatios = new List <int>();

            while (cmd.HasNext)
            {
                int   ratio = 1;
                Block block = cmd.NextBlockWithParam(player, ref ratio);
                if (ratio < 0 || ratio > MaxRatio)
                {
                    player.Message("Invalid block ratio ({0}). Must be between 1 and {1}.",
                                   ratio, MaxRatio);
                    return(null);
                }
                if (block == Block.Undefined)
                {
                    return(null);
                }
                blocks.Add(block);
                blockRatios.Add(ratio);
            }

            if (blocks.Count == 0)
            {
                if (Blocks.Length == 0)
                {
                    player.Message("{0} brush: Please specify at least one block.", Factory.Name);
                    return(null);
                }
                else
                {
                    return(new CloudyBrush(this));
                }
            }
            else if (blocks.Count == 1)
            {
                return(new CloudyBrush(blocks[0], blockRatios[0]));
            }
            else
            {
                return(new CloudyBrush(blocks.ToArray(), blockRatios.ToArray()));
            }
        }
Пример #9
0
        public IBrushInstance MakeInstance([NotNull] Player player, [NotNull] Command cmd, [NotNull] DrawOperation op)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            if (cmd == null)
            {
                throw new ArgumentNullException("cmd");
            }
            if (op == null)
            {
                throw new ArgumentNullException("op");
            }

            Stack <Block> blocks = new Stack <Block>();

            while (cmd.HasNext)
            {
                Block block = cmd.NextBlock(player);
                if (block == Block.Undefined)
                {
                    return(null);
                }
                blocks.Push(block);
            }

            if (blocks.Count == 0 && Blocks == null)
            {
                player.Message("ReplaceNot brush requires at least 1 block.");
                return(null);
            }

            if (blocks.Count > 0)
            {
                if (blocks.Count > 1)
                {
                    Replacement = blocks.Pop();
                }
                Blocks = blocks.ToArray();
            }

            return(new ReplaceNotBrush(this));
        }
Пример #10
0
        public IBrushInstance MakeInstance([NotNull] Player player, [NotNull] Command cmd, [NotNull] DrawOperation op)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            if (cmd == null)
            {
                throw new ArgumentNullException("cmd");
            }
            if (op == null)
            {
                throw new ArgumentNullException("op");
            }
            Stack <Block> temp = new Stack <Block>();

            Block[] b;
            while (cmd.HasNext)
            {
                Block block = cmd.NextBlock(player);
                if (block == Block.Undefined)
                {
                    return(null);
                }
                temp.Push(block);
            }
            if (temp.Count > 0)
            {
                b = temp.ToArray();
            }
            else if (player.LastUsedBlockType != Block.Undefined)
            {
                b = new[] { player.LastUsedBlockType, Block.Air };
            }
            else
            {
                b = new[] { Block.Stone, Block.Air };
            }
            return(new DiagonalBrush(b));
        }
Пример #11
0
        public IBrushInstance MakeInstance([NotNull] Player player, [NotNull] Command cmd, [NotNull] DrawOperation op)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            if (cmd == null)
            {
                throw new ArgumentNullException("cmd");
            }
            if (op == null)
            {
                throw new ArgumentNullException("op");
            }

            if (cmd.HasNext)
            {
                Block block = cmd.NextBlock(player);
                if (block == Block.Undefined)
                {
                    return(null);
                }

                string brushName = cmd.Next();
                if (brushName == null || !CommandManager.IsValidCommandName(brushName))
                {
                    player.Message("ReplaceBrush usage: &H/Brush rb <Block> <BrushName>");
                    return(null);
                }
                IBrushFactory brushFactory = BrushManager.GetBrushFactory(brushName);

                if (brushFactory == null)
                {
                    player.Message("Unrecognized brush \"{0}\"", brushName);
                    return(null);
                }

                IBrush replacement = brushFactory.MakeBrush(player, cmd);
                if (replacement == null)
                {
                    return(null);
                }
                Block       = block;
                Replacement = replacement;
            }

            ReplacementInstance = Replacement.MakeInstance(player, cmd, op);
            if (ReplacementInstance == null)
            {
                return(null);
            }

            return(new ReplaceBrushBrush(this));
        }
Пример #12
0
 public IBrushInstance MakeInstance(Player player, Command cmd, DrawOperation state)
 {
     return(this);
 }