mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-27 07:11:04 -04:00
Add striped brush, also show brush name in draw operation output to the player.
This commit is contained in:
parent
672e93ba2a
commit
37cd475398
@ -23,6 +23,9 @@ using MCGalaxy.Drawing.Ops;
|
||||
namespace MCGalaxy.Drawing.Brushes {
|
||||
|
||||
public abstract class Brush {
|
||||
|
||||
/// <summary> Human friendly name of this brush. </summary>
|
||||
public abstract string Name { get; }
|
||||
|
||||
public abstract byte NextBlock(DrawOp op);
|
||||
|
||||
@ -35,6 +38,7 @@ namespace MCGalaxy.Drawing.Brushes {
|
||||
{ "checkered", CheckeredBrush.Process },
|
||||
{ "rainbow", RainbowBrush.Process },
|
||||
{ "bwrainbow", BWRainbowBrush.Process },
|
||||
{ "striped", StripedBrush.Process },
|
||||
};
|
||||
}
|
||||
|
||||
@ -57,6 +61,8 @@ namespace MCGalaxy.Drawing.Brushes {
|
||||
this.extType = extType;
|
||||
}
|
||||
|
||||
public override string Name { get { return "Random"; } }
|
||||
|
||||
public override byte NextBlock(DrawOp op) {
|
||||
return (byte)rnd.Next(1, 11) <= 5 ? type : Block.Zero;
|
||||
}
|
||||
|
@ -30,6 +30,8 @@ namespace MCGalaxy.Drawing.Brushes {
|
||||
this.type2 = type2; this.extType2 = extType2;
|
||||
}
|
||||
|
||||
public override string Name { get { return "Checkered"; } }
|
||||
|
||||
public static Brush Process(BrushArgs args) {
|
||||
if (args.Message == "")
|
||||
return new CheckeredBrush(args.Type, args.ExtType, 0, 0);
|
||||
|
@ -29,6 +29,8 @@ namespace MCGalaxy.Drawing.Brushes {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public override string Name { get { return "Paste"; } }
|
||||
|
||||
public static Brush Process(BrushArgs args) {
|
||||
if (args.Player.CopyBuffer == null) {
|
||||
args.Player.SendMessage("You haven't copied anything yet.");
|
||||
|
@ -24,6 +24,8 @@ namespace MCGalaxy.Drawing.Brushes {
|
||||
|
||||
public sealed class RainbowBrush : Brush {
|
||||
|
||||
public override string Name { get { return "Rainbow"; } }
|
||||
|
||||
public override byte NextBlock(DrawOp op) {
|
||||
int offset = (op.Coords.X + op.Coords.Y + op.Coords.Z) % 13;
|
||||
if (offset < 0) offset += 13;
|
||||
@ -49,6 +51,8 @@ namespace MCGalaxy.Drawing.Brushes {
|
||||
|
||||
public sealed class BWRainbowBrush : Brush {
|
||||
|
||||
public override string Name { get { return "BWRainbow"; } }
|
||||
|
||||
static byte[] blocks = { Block.iron, Block.white, Block.lightgrey,
|
||||
Block.darkgrey, Block.obsidian, Block.darkgrey, Block.lightgrey, Block.white };
|
||||
public override byte NextBlock(DrawOp op) {
|
||||
@ -67,6 +71,8 @@ namespace MCGalaxy.Drawing.Brushes {
|
||||
public sealed class RandomRainbowBrush : Brush {
|
||||
readonly Random rnd;
|
||||
|
||||
public override string Name { get { return "RandomRainbow"; } }
|
||||
|
||||
public RandomRainbowBrush() {
|
||||
rnd = new Random();
|
||||
}
|
||||
|
@ -30,6 +30,8 @@ namespace MCGalaxy.Drawing.Brushes {
|
||||
this.extType = extType;
|
||||
}
|
||||
|
||||
public override string Name { get { return "Normal"; } }
|
||||
|
||||
public static Brush Process(BrushArgs args) {
|
||||
if (args.Message == "")
|
||||
return new SolidBrush(args.Type, args.ExtType);
|
||||
|
59
Drawing/Brushes/StripedBrush.cs
Normal file
59
Drawing/Brushes/StripedBrush.cs
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
Copyright 2015 MCGalaxy
|
||||
|
||||
Dual-licensed under the Educational Community License, Version 2.0 and
|
||||
the GNU General Public License, Version 3 (the "Licenses"); you may
|
||||
not use this file except in compliance with the Licenses. You may
|
||||
obtain a copy of the Licenses at
|
||||
|
||||
http://www.opensource.org/licenses/ecl2.php
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the Licenses are distributed on an "AS IS"
|
||||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
or implied. See the Licenses for the specific language governing
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using MCGalaxy.Commands;
|
||||
using MCGalaxy.Drawing.Ops;
|
||||
|
||||
namespace MCGalaxy.Drawing.Brushes {
|
||||
|
||||
public sealed class StripedBrush : Brush {
|
||||
readonly byte type1, extType1, type2, extType2;
|
||||
|
||||
public StripedBrush(byte type1, byte extType1, byte type2, byte extType2) {
|
||||
this.type1 = type1; this.extType1 = extType1;
|
||||
this.type2 = type2; this.extType2 = extType2;
|
||||
}
|
||||
|
||||
public override string Name { get { return "Striped"; } }
|
||||
|
||||
public static Brush Process(BrushArgs args) {
|
||||
if (args.Message == "")
|
||||
return new StripedBrush(args.Type, args.ExtType, 0, 0);
|
||||
string[] parts = args.Message.Split(' ');
|
||||
byte extType1;
|
||||
byte type1 = DrawCmd.GetBlock(args.Player, parts[0], out extType1);
|
||||
if (type1 == Block.Zero) return null;
|
||||
if (parts.Length == 1)
|
||||
return new StripedBrush(type1, extType1, 0, 0);
|
||||
|
||||
byte extType2;
|
||||
byte type2 = DrawCmd.GetBlock(args.Player, parts[1], out extType2);
|
||||
if (type2 == Block.Zero) return null;
|
||||
return new StripedBrush(type1, extType1, type2, extType2);
|
||||
}
|
||||
|
||||
public override byte NextBlock(DrawOp op) {
|
||||
return ((op.Coords.X + op.Coords.Y + op.Coords.Z) & 3) <= 1 ? type1 : type2;
|
||||
}
|
||||
|
||||
public override byte NextExtBlock(DrawOp op) {
|
||||
return ((op.Coords.X + op.Coords.Y + op.Coords.Z) & 3) <= 1 ? extType1 : extType2;
|
||||
}
|
||||
}
|
||||
}
|
@ -133,7 +133,8 @@ namespace MCGalaxy.Drawing.Ops {
|
||||
|
||||
if (!op.CanDraw(x1, y1, z1, x2, y2, z2, p, out affected))
|
||||
return false;
|
||||
Player.SendMessage(p, op.Name + ": affecting up to an estimated " + affected + " blocks");
|
||||
const string format = "{0}({1}): affecting up to {2} blocks";
|
||||
Player.SendMessage(p, String.Format(format, op.Name, brush.Name, affected));
|
||||
|
||||
bool needReveal = op.DetermineDrawOpMethod(p.level, affected);
|
||||
op.Perform(x1, y1, z1, x2, y2, z2, p, p.level, brush);
|
||||
|
@ -397,6 +397,7 @@
|
||||
<Compile Include="Drawing\Brushes\PasteBrush.cs" />
|
||||
<Compile Include="Drawing\Brushes\RainbowBrush.cs" />
|
||||
<Compile Include="Drawing\Brushes\SolidBrush.cs" />
|
||||
<Compile Include="Drawing\Brushes\StripedBrush.cs" />
|
||||
<Compile Include="Drawing\CopyState.cs" />
|
||||
<Compile Include="Drawing\DrawOps\CuboidDrawOp.cs" />
|
||||
<Compile Include="Drawing\DrawOps\DrawOp.cs" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user