Indexes available brushes. Provides /Brush command, a way to register new brushes, a way to look up existing brushes by name.
Пример #1
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));
        }
Пример #2
0
        public IBrush MakeBrush([NotNull] Player player, [NotNull] Command cmd)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }
            if (cmd == null)
            {
                throw new ArgumentNullException("cmd");
            }

            if (!cmd.HasNext)
            {
                player.Message("ReplaceBrush usage: &H/Brush rb <Block> <BrushName>");
                return(null);
            }

            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 newBrush = brushFactory.MakeBrush(player, cmd);

            if (newBrush == null)
            {
                return(null);
            }

            return(new ReplaceBrushBrush(block, newBrush));
        }