Cuboid modes holes and random should read given arguments. (Thanks goodlyay)

This commit is contained in:
UnknownShadow200 2016-03-11 19:21:12 +11:00
parent ded5647e6d
commit 7d22d75111
5 changed files with 19 additions and 10 deletions

View File

@ -32,7 +32,7 @@ namespace MCGalaxy.Commands
CatchPos cpos = (CatchPos)p.blockchangeObject; CatchPos cpos = (CatchPos)p.blockchangeObject;
GetRealBlock(type, extType, p, ref cpos); GetRealBlock(type, extType, p, ref cpos);
DrawOp drawOp = null; DrawOp drawOp = null;
Brush brush = null; Func<BrushArgs, Brush> constructor = null;
switch (cpos.mode) { switch (cpos.mode) {
case DrawMode.solid: case DrawMode.solid:
@ -44,16 +44,16 @@ namespace MCGalaxy.Commands
drawOp = new CuboidWallsDrawOp(); break; drawOp = new CuboidWallsDrawOp(); break;
case DrawMode.holes: case DrawMode.holes:
drawOp = new CuboidDrawOp(); drawOp = new CuboidDrawOp();
brush = new CheckeredBrush(cpos.type, cpos.extType, 0, 0); break; constructor = CheckeredBrush.Process; break;
case DrawMode.wire: case DrawMode.wire:
drawOp = new CuboidWireframeDrawOp(); break; drawOp = new CuboidWireframeDrawOp(); break;
case DrawMode.random: case DrawMode.random:
drawOp = new CuboidDrawOp(); drawOp = new CuboidDrawOp();
brush = new RandomBrush(cpos.type, cpos.extType); break; constructor = RandomBrush.Process; break;
} }
int brushOffset = cpos.mode == DrawMode.normal ? 0 : 1; int brushOffset = cpos.mode == DrawMode.normal ? 0 : 1;
if (brush == null) brush = GetBrush(p, cpos, brushOffset); Brush brush = GetBrush(p, cpos, brushOffset, constructor);
if (brush == null) return; if (brush == null) return;
if (!DrawOp.DoDrawOp(drawOp, brush, p, cpos.x, cpos.y, cpos.z, x, y, z)) if (!DrawOp.DoDrawOp(drawOp, brush, p, cpos.x, cpos.y, cpos.z, x, y, z))
return; return;

View File

@ -86,7 +86,8 @@ namespace MCGalaxy.Commands {
return type; return type;
} }
protected static Brush GetBrush(Player p, CatchPos cpos, int usedFromEnd) { protected static Brush GetBrush(Player p, CatchPos cpos,
int usedFromEnd, Func<BrushArgs, Brush> constructor = null) {
int end = cpos.message.Length; int end = cpos.message.Length;
string brushMsg = ""; string brushMsg = "";
for (int i = 0; i < usedFromEnd; i++) { for (int i = 0; i < usedFromEnd; i++) {
@ -95,7 +96,7 @@ namespace MCGalaxy.Commands {
} }
if (end >= 0) brushMsg = cpos.message.Substring(0, end); if (end >= 0) brushMsg = cpos.message.Substring(0, end);
var constructor = Brush.Brushes[p.BrushName]; if (constructor == null) constructor = Brush.Brushes[p.BrushName];
BrushArgs args = new BrushArgs(p, brushMsg, cpos.type, cpos.extType); BrushArgs args = new BrushArgs(p, brushMsg, cpos.type, cpos.extType);
return constructor(args); return constructor(args);
} }

View File

@ -75,6 +75,15 @@ namespace MCGalaxy.Drawing.Brushes {
public override string[] Help { get { return new string[0]; } } public override string[] Help { get { return new string[0]; } }
public static Brush Process(BrushArgs args) {
if (args.Message == "")
return new RandomBrush(args.Type, args.ExtType);
byte extType;
byte type = DrawCmd.GetBlock(args.Player, args.Message, out extType);
if (type == Block.Zero) return null;
return new RandomBrush(type, extType);
}
public override byte NextBlock(DrawOp op) { public override byte NextBlock(DrawOp op) {
return (byte)rnd.Next(1, 11) <= 5 ? type : Block.Zero; return (byte)rnd.Next(1, 11) <= 5 ? type : Block.Zero;
} }

View File

@ -1082,9 +1082,8 @@ return;
overallDeath++; overallDeath++;
} }
if ( Server.deathcount ) if (Server.deathcount && (overallDeath > 0 && overallDeath % 10 == 0))
if ( overallDeath > 0 && overallDeath % 10 == 0 ) Chat.GlobalChatLevel(this, FullName + " %Shas died &3" + overallDeath + " times", false);
SendChatFrom(this, this.FullName + Server.DefaultColor + " has died &3" + overallDeath + " times", false);
} }
lastDeath = DateTime.Now; lastDeath = DateTime.Now;