mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 12:05:51 -04:00
The great drawop rewrite. (Part 1)
This commit is contained in:
parent
a3ee120e61
commit
c02e2d96d9
@ -16,9 +16,8 @@
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
using System;
|
||||
using MCGalaxy.Drawing;
|
||||
using MCGalaxy.Drawing.Ops;
|
||||
using MCGalaxy.Drawing.Brushes;
|
||||
using MCGalaxy.Drawing.Ops;
|
||||
|
||||
namespace MCGalaxy.Commands.Building {
|
||||
public sealed class CmdCuboid : DrawCmd {
|
||||
@ -29,40 +28,9 @@ namespace MCGalaxy.Commands.Building {
|
||||
new CommandAlias("ch", null, "hollow"), new CommandAlias("walls", null, "walls"),
|
||||
new CommandAlias("box"), new CommandAlias("hbox", null, "hollow") }; }
|
||||
}
|
||||
|
||||
protected override bool DoDraw(Player p, Vec3S32[] marks, object state, byte type, byte extType) {
|
||||
DrawArgs cpos = (DrawArgs)state;
|
||||
cpos.block = type; cpos.extBlock = extType;
|
||||
DrawOp op = null;
|
||||
BrushFactory factory = null;
|
||||
|
||||
switch (cpos.mode) {
|
||||
case DrawMode.solid:
|
||||
op = new CuboidDrawOp();
|
||||
factory = BrushFactory.Find("normal"); break;
|
||||
case DrawMode.normal:
|
||||
op = new CuboidDrawOp(); break;
|
||||
case DrawMode.hollow:
|
||||
op = new CuboidHollowsDrawOp(); break;
|
||||
case DrawMode.walls:
|
||||
op = new CuboidWallsDrawOp(); break;
|
||||
case DrawMode.holes:
|
||||
op = new CuboidDrawOp();
|
||||
factory = BrushFactory.Find("checkered"); break;
|
||||
case DrawMode.wire:
|
||||
op = new CuboidWireframeDrawOp(); break;
|
||||
case DrawMode.random:
|
||||
op = new CuboidDrawOp();
|
||||
factory = BrushFactory.Find("random"); break;
|
||||
}
|
||||
|
||||
int brushOffset = cpos.mode == DrawMode.normal ? 0 : 1;
|
||||
Brush brush = GetBrush(p, cpos, brushOffset, factory);
|
||||
if (brush == null) return false;
|
||||
return DrawOp.DoDrawOp(op, brush, p, marks);
|
||||
}
|
||||
|
||||
protected override DrawMode ParseMode(string msg) {
|
||||
protected override DrawMode GetMode(string[] parts) {
|
||||
string msg = parts[parts.Length - 1];
|
||||
if (msg == "solid") return DrawMode.solid;
|
||||
else if (msg == "hollow") return DrawMode.hollow;
|
||||
else if (msg == "walls") return DrawMode.walls;
|
||||
@ -72,6 +40,25 @@ namespace MCGalaxy.Commands.Building {
|
||||
return DrawMode.normal;
|
||||
}
|
||||
|
||||
protected override BrushFactory GetBrush(Player p, DrawArgs dArgs, ref int brushOffset) {
|
||||
brushOffset = dArgs.mode == DrawMode.normal ? 0 : 1;
|
||||
if (dArgs.mode == DrawMode.solid) return BrushFactory.Find("normal");
|
||||
if (dArgs.mode == DrawMode.holes) return BrushFactory.Find("checkered");
|
||||
if (dArgs.mode == DrawMode.random) return BrushFactory.Find("random");
|
||||
return BrushFactory.Find(p.BrushName);
|
||||
}
|
||||
|
||||
protected override DrawOp GetDrawOp(DrawArgs dArgs, Vec3S32[] m) {
|
||||
switch (dArgs.mode) {
|
||||
case DrawMode.hollow: return new CuboidHollowsDrawOp();
|
||||
case DrawMode.walls: return new CuboidWallsDrawOp();
|
||||
case DrawMode.holes: return new CuboidDrawOp();
|
||||
case DrawMode.wire: return new CuboidWireframeDrawOp();
|
||||
case DrawMode.random: return new CuboidDrawOp();
|
||||
}
|
||||
return new CuboidDrawOp();
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
Player.Message(p, "%T/cuboid [brush args] <mode>");
|
||||
Player.Message(p, "%HDraws a cuboid between two points.");
|
||||
|
@ -16,7 +16,6 @@
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
using System;
|
||||
using MCGalaxy.Drawing;
|
||||
using MCGalaxy.Drawing.Brushes;
|
||||
using MCGalaxy.Drawing.Ops;
|
||||
|
||||
@ -27,7 +26,8 @@ namespace MCGalaxy.Commands.Building {
|
||||
protected override string PlaceMessage { get { return "Place a block to determine the origin."; } }
|
||||
public override int MarksCount { get { return 1; } }
|
||||
|
||||
protected override DrawMode ParseMode(string msg) {
|
||||
protected override DrawMode GetMode(string[] parts) {
|
||||
string msg = parts[parts.Length - 1];
|
||||
if (msg == "cone") return DrawMode.cone;
|
||||
else if (msg == "hcone") return DrawMode.hcone;
|
||||
else if (msg == "icone") return DrawMode.icone;
|
||||
@ -78,7 +78,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
(!op.UsesHeight && !CheckOneArg(p, ref radius, args))) return false;
|
||||
|
||||
int brushOffset = op.UsesHeight ? 3 : 2;
|
||||
Brush brush = GetBrush(p, cpos, brushOffset);
|
||||
Brush brush = ParseBrush(p, cpos, brushOffset);
|
||||
if (brush == null) return false;
|
||||
|
||||
Vec3S32[] marks = {
|
||||
|
@ -20,15 +20,16 @@ using System.Collections.Generic;
|
||||
using MCGalaxy.Drawing.Brushes;
|
||||
using MCGalaxy.Drawing.Ops;
|
||||
|
||||
namespace MCGalaxy.Commands.Building {
|
||||
public sealed class CmdFill : DrawCmd {
|
||||
namespace MCGalaxy.Commands.Building {
|
||||
public sealed class CmdFill : DrawCmd {
|
||||
public override string name { get { return "fill"; } }
|
||||
public override string shortcut { get { return "f"; } }
|
||||
public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } }
|
||||
protected override string PlaceMessage { get { return "Destroy the block you wish to fill."; } }
|
||||
public override int MarksCount { get { return 1; } }
|
||||
|
||||
protected override DrawMode ParseMode(string msg) {
|
||||
protected override DrawMode GetMode(string[] parts) {
|
||||
string msg = parts[parts.Length - 1];
|
||||
if (msg == "normal") return DrawMode.solid;
|
||||
else if (msg == "up") return DrawMode.up;
|
||||
else if (msg == "down") return DrawMode.down;
|
||||
@ -65,7 +66,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
FillDrawOp op = new FillDrawOp();
|
||||
op.Positions = buffer;
|
||||
int brushOffset = cpos.mode == DrawMode.normal ? 0 : 1;
|
||||
Brush brush = GetBrush(p, cpos, brushOffset);
|
||||
Brush brush = ParseBrush(p, cpos, brushOffset);
|
||||
if (brush == null || !DrawOp.DoDrawOp(op, brush, p, marks)) return false;
|
||||
bits.Clear();
|
||||
op.Positions = null;
|
||||
|
@ -25,12 +25,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
public override string shortcut { get { return "l"; } }
|
||||
protected override string PlaceMessage { get { return "Place two blocks to determine the endpoints."; } }
|
||||
|
||||
protected override DrawMode ParseMode(string msg) {
|
||||
if (msg == "normal") return DrawMode.solid;
|
||||
else if (msg == "walls") return DrawMode.walls;
|
||||
else if (msg == "straight") return DrawMode.straight;
|
||||
return DrawMode.normal;
|
||||
}
|
||||
|
||||
|
||||
protected override void OnUse(Player p, string msg, string[] parts, ref DrawArgs cpos) {
|
||||
if (parts.Length < 2 || cpos.mode == DrawMode.normal) return;
|
||||
@ -40,17 +35,25 @@ namespace MCGalaxy.Commands.Building {
|
||||
cpos.data = len;
|
||||
}
|
||||
|
||||
protected override DrawMode GetMode(string message, string[] parts) {
|
||||
if (message == "") return DrawMode.normal;
|
||||
DrawMode mode = ParseMode(parts[parts.Length - 1]);
|
||||
if (mode != DrawMode.normal) return mode;
|
||||
protected override DrawMode GetMode(string[] parts) {
|
||||
string mode = parts[parts.Length - 1];
|
||||
if (mode == "") return DrawMode.normal;
|
||||
DrawMode dMode = ParseMode(mode);
|
||||
if (dMode != DrawMode.normal) return dMode;
|
||||
|
||||
// May be in the format <brush args> <mode> <max_length>
|
||||
ushort len;
|
||||
if (parts.Length == 1 || !ushort.TryParse(parts[parts.Length - 1], out len))
|
||||
if (parts.Length == 1 || !ushort.TryParse(mode, out len))
|
||||
return DrawMode.normal;
|
||||
return ParseMode(parts[parts.Length - 2]);
|
||||
}
|
||||
|
||||
static DrawMode ParseMode(string msg) {
|
||||
if (msg == "normal") return DrawMode.solid;
|
||||
else if (msg == "walls") return DrawMode.walls;
|
||||
else if (msg == "straight") return DrawMode.straight;
|
||||
return DrawMode.normal;
|
||||
}
|
||||
|
||||
protected override bool DoDraw(Player p, Vec3S32[] m, object state, byte type, byte extType) {
|
||||
DrawArgs cpos = (DrawArgs)state;
|
||||
@ -74,7 +77,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
if (cpos.data != null) {
|
||||
drawOp.MaxLength = (ushort)cpos.data; brushOffset++;
|
||||
}
|
||||
Brush brush = GetBrush(p, cpos, brushOffset);
|
||||
Brush brush = ParseBrush(p, cpos, brushOffset);
|
||||
if (brush == null) return false;
|
||||
return DrawOp.DoDrawOp(drawOp, brush, p, m);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
Copyright 2010 MCSharp team (Modified for use with MCZall/MCLawl/MCGalaxy)
|
||||
|
||||
Dual-licensed under the Educational Community License, Version 2.0 and
|
||||
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
|
||||
@ -16,46 +16,33 @@
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
using System;
|
||||
using MCGalaxy.Drawing;
|
||||
using MCGalaxy.Drawing.Ops;
|
||||
using MCGalaxy.Drawing.Brushes;
|
||||
|
||||
namespace MCGalaxy.Commands.Building {
|
||||
public sealed class CmdPyramid : DrawCmd {
|
||||
public override string name { get { return "pyramid"; } }
|
||||
public override string shortcut { get { return "pd"; } }
|
||||
|
||||
protected override bool DoDraw(Player p, Vec3S32[] marks, object state, byte type, byte extType) {
|
||||
DrawArgs cpos = (DrawArgs)state;
|
||||
cpos.block = type; cpos.extBlock = extType;
|
||||
DrawOp op = null;
|
||||
int brushOffset = cpos.mode == DrawMode.normal ? 0 : 1;
|
||||
Brush brush = GetBrush(p, cpos, brushOffset);
|
||||
if (brush == null) return false;
|
||||
|
||||
if (marks[0].Y != marks[1].Y) {
|
||||
Player.Message(p, "The two edges of the pyramid must be on the same level"); return false;
|
||||
}
|
||||
|
||||
switch (cpos.mode) {
|
||||
case DrawMode.solid:
|
||||
case DrawMode.normal:
|
||||
op = new PyramidSolidDrawOp(); break;
|
||||
case DrawMode.hollow:
|
||||
op = new PyramidHollowDrawOp(); break;
|
||||
case DrawMode.reverse:
|
||||
op = new PyramidReverseDrawOp(); break;
|
||||
}
|
||||
return DrawOp.DoDrawOp(op, brush, p, marks);
|
||||
}
|
||||
|
||||
protected override DrawMode ParseMode(string msg) {
|
||||
if (msg == "solid") return DrawMode.solid;
|
||||
else if (msg == "hollow") return DrawMode.hollow;
|
||||
else if (msg == "reverse") return DrawMode.reverse;
|
||||
protected override DrawMode GetMode(string[] parts) {
|
||||
string mode = parts[parts.Length - 1];
|
||||
if (mode == "solid") return DrawMode.solid;
|
||||
else if (mode == "hollow") return DrawMode.hollow;
|
||||
else if (mode == "reverse") return DrawMode.reverse;
|
||||
return DrawMode.normal;
|
||||
}
|
||||
|
||||
protected override DrawOp GetDrawOp(DrawArgs dArgs, Vec3S32[] m) {
|
||||
if (m[0].Y != m[1].Y) {
|
||||
Player.Message(p, "The two edges of the pyramid must be on the same level"); return null;
|
||||
}
|
||||
|
||||
switch (dArgs.mode) {
|
||||
case DrawMode.hollow: return new PyramidHollowDrawOp();
|
||||
case DrawMode.reverse: return new PyramidReverseDrawOp();
|
||||
}
|
||||
return new PyramidSolidDrawOp();
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
Player.Message(p, "%T/pyramid [brush args] <mode>");
|
||||
Player.Message(p, "%HDraws a square pyramid, using two points for the base.");
|
||||
|
@ -25,43 +25,39 @@ namespace MCGalaxy.Commands.Building {
|
||||
public override string shortcut { get { return "sp"; } }
|
||||
public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } }
|
||||
public override CommandAlias[] Aliases {
|
||||
get { return new[] { new CommandAlias("sphereh", null, "hollow"), new CommandAlias("sph", null, "hollow"),
|
||||
new CommandAlias("circle", null, "circle" ) }; }
|
||||
get { return new[] { new CommandAlias("sphereh", null, "hollow"),
|
||||
new CommandAlias("sph", null, "hollow"), new CommandAlias("circle", null, "circle" ) }; }
|
||||
}
|
||||
protected override string PlaceMessage {
|
||||
get { return "Place a block for the centre, then another for the radius."; }
|
||||
}
|
||||
protected override string PlaceMessage { get { return "Place a block for the centre, then another for the radius."; } }
|
||||
|
||||
protected override DrawMode ParseMode(string msg) {
|
||||
protected override DrawMode GetMode(string[] parts) {
|
||||
string msg = parts[parts.Length - 1];
|
||||
if (msg == "solid") return DrawMode.solid;
|
||||
else if (msg == "hollow") return DrawMode.hollow;
|
||||
else if (msg == "circle") return DrawMode.circle;
|
||||
return DrawMode.normal;
|
||||
}
|
||||
|
||||
protected override bool DoDraw(Player p, Vec3S32[] m, object state, byte type, byte extType) {
|
||||
DrawArgs cpos = (DrawArgs)state;
|
||||
cpos.block = type; cpos.extBlock = extType;
|
||||
|
||||
DrawOp op = null;
|
||||
BrushFactory factory = null;
|
||||
switch (cpos.mode) {
|
||||
case DrawMode.solid:
|
||||
op = new AdvSphereDrawOp();
|
||||
factory = BrushFactory.Find("normal"); break;
|
||||
case DrawMode.hollow:
|
||||
op = new AdvHollowSphereDrawOp(); break;
|
||||
case DrawMode.circle:
|
||||
op = new EllipsoidDrawOp(); break;
|
||||
default:
|
||||
op = new AdvSphereDrawOp(); break;
|
||||
}
|
||||
int brushOffset = cpos.mode == DrawMode.normal ? 0 : 1;
|
||||
Brush brush = GetBrush(p, cpos, brushOffset, factory);
|
||||
if (brush == null) return false;
|
||||
|
||||
|
||||
protected override void GetMarks(DrawArgs dArgs, Vec3S32[] m) {
|
||||
Vec3S32 p0 = m[0];
|
||||
Vec3S32 radius = GetRadius(cpos.mode, m);
|
||||
m[0] = p0 - radius; m[1] = p0 + radius;
|
||||
return DrawOp.DoDrawOp(op, brush, p, m);
|
||||
}
|
||||
|
||||
protected override BrushFactory GetBrush(Player p, DrawArgs dArgs, ref int brushOffset) {
|
||||
brushOffset = dArgs.mode == DrawMode.normal ? 0 : 1;
|
||||
if (dArgs.mode == DrawMode.solid) return BrushFactory.Find("normal");
|
||||
return BrushFactory.Find(p.BrushName);
|
||||
}
|
||||
|
||||
protected override DrawOp GetDrawOp(DrawArgs dArg, Vec3S32[] m) {
|
||||
switch (dArgs.mode) {
|
||||
case DrawMode.hollow: return new AdvHollowSphereDrawOp();
|
||||
case DrawMode.circle: return new EllipsoidDrawOp();
|
||||
}
|
||||
return new AdvSphereDrawOp();
|
||||
}
|
||||
|
||||
static Vec3S32 GetRadius(DrawMode mode, Vec3S32[] m) {
|
||||
|
@ -24,34 +24,21 @@ namespace MCGalaxy.Commands.Building {
|
||||
public override string name { get { return "spheroid"; } }
|
||||
public override string shortcut { get { return "e"; } }
|
||||
public override CommandAlias[] Aliases {
|
||||
get { return new[] { new CommandAlias("eh", null, "hollow"), new CommandAlias("cylinder", null, "vertical") }; }
|
||||
}
|
||||
|
||||
protected override bool DoDraw(Player p, Vec3S32[] marks, object state, byte type, byte extType) {
|
||||
DrawArgs cpos = (DrawArgs)state;
|
||||
cpos.block = type; cpos.extBlock = extType;
|
||||
DrawOp op = null;
|
||||
int brushOffset = cpos.mode == DrawMode.normal ? 0 : 1;
|
||||
Brush brush = GetBrush(p, cpos, brushOffset);
|
||||
if (brush == null) return false;
|
||||
|
||||
switch (cpos.mode) {
|
||||
case DrawMode.solid:
|
||||
case DrawMode.normal:
|
||||
op = new EllipsoidDrawOp(); break;
|
||||
case DrawMode.hollow:
|
||||
op = new EllipsoidHollowDrawOp(); break;
|
||||
case DrawMode.vertical:
|
||||
op = new CylinderDrawOp(); break;
|
||||
}
|
||||
return DrawOp.DoDrawOp(op, brush, p, marks);
|
||||
get { return new[] { new CommandAlias("eh", null, "hollow"), new CommandAlias("cylinder", null, "vertical") }; }
|
||||
}
|
||||
|
||||
protected override DrawMode ParseMode(string msg) {
|
||||
if (msg == "solid") return DrawMode.solid;
|
||||
else if (msg == "hollow") return DrawMode.hollow;
|
||||
else if (msg == "vertical") return DrawMode.vertical;
|
||||
return DrawMode.normal;
|
||||
protected override BrushFactory GetBrush(Player p, DrawArgs dArgs, ref int brushOffset) {
|
||||
brushOffset = dArgs.mode == DrawMode.normal ? 0 : 1;
|
||||
if (dArgs.mode == DrawMode.solid) return BrushFactory.Find("normal");
|
||||
return BrushFactory.Find(p.BrushName);
|
||||
}
|
||||
|
||||
protected override DrawOp GetDrawOp(DrawArgs dArgs, Vec3S32[] m) {
|
||||
switch (dArgs.mode) {
|
||||
case DrawMode.hollow: return new EllipsoidHollowDrawOp();
|
||||
case DrawMode.vertical: return new CylinderDrawOp();
|
||||
}
|
||||
return new EllipsoidDrawOp();
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
@ -61,5 +48,4 @@ namespace MCGalaxy.Commands.Building {
|
||||
Player.Message(p, " %HModes: &fsolid/hollow/vertical(a vertical tube)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -16,7 +16,6 @@
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
using System;
|
||||
using MCGalaxy.Drawing.Brushes;
|
||||
using MCGalaxy.Drawing.Ops;
|
||||
|
||||
namespace MCGalaxy.Commands.Building {
|
||||
@ -27,26 +26,22 @@ namespace MCGalaxy.Commands.Building {
|
||||
public override CommandAlias[] Aliases {
|
||||
get { return new[] { new CommandAlias("donut"), new CommandAlias("bagel") }; }
|
||||
}
|
||||
protected override string PlaceMessage { get { return "Place a block for the centre, then another for the radius."; } }
|
||||
|
||||
protected override bool DoDraw(Player p, Vec3S32[] m, object state, byte type, byte extType) {
|
||||
DrawArgs cpos = (DrawArgs)state;
|
||||
cpos.block = type; cpos.extBlock = extType;
|
||||
|
||||
DrawOp drawOp = new TorusDrawOp();
|
||||
Brush brush = GetBrush(p, cpos, 0);
|
||||
if (brush == null) return false;
|
||||
|
||||
int dx = m[0].X - m[1].X, dy = m[0].Y - m[1].Y, dz = m[0].Z - m[1].Z;
|
||||
int horR = (int)Math.Sqrt(dx * dx + dz * dz), verR = Math.Abs(dy);
|
||||
Vec3S32 p0 = m[0];
|
||||
m = new [] { new Vec3S32(p0.X - horR, p0.Y - verR, p0.Z - horR),
|
||||
new Vec3S32(p0.X + horR, p0.Y + verR, p0.Z + horR) };
|
||||
|
||||
return DrawOp.DoDrawOp(drawOp, brush, p, m);
|
||||
protected override string PlaceMessage {
|
||||
get { return "Place a block for the centre, then another for the radius."; }
|
||||
}
|
||||
|
||||
protected override DrawMode ParseMode(string msg) { return DrawMode.normal; }
|
||||
protected override void GetMarks(DrawArgs dArgs, Vec3S32[] m) {
|
||||
int dx = m[0].X - m[1].X, dy = m[0].Y - m[1].Y, dz = m[0].Z - m[1].Z;
|
||||
int horR = (int)Math.Sqrt(dx * dx + dz * dz), verR = Math.Abs(dy);
|
||||
|
||||
Vec3S32 p0 = m[0];
|
||||
m[0] = new Vec3S32(p0.X - horR, p0.Y - verR, p0.Z - horR);
|
||||
m[1] = new Vec3S32(p0.X + horR, p0.Y + verR, p0.Z + horR);
|
||||
}
|
||||
|
||||
protected override DrawOp GetDrawOp(DrawArgs dArgs, Vec3S32[] m) {
|
||||
return new TorusDrawOp();
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
Player.Message(p, "%T/torus [brush args]");
|
||||
|
@ -16,28 +16,21 @@
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
using System;
|
||||
using MCGalaxy.Drawing.Brushes;
|
||||
using MCGalaxy.Drawing.Ops;
|
||||
|
||||
namespace MCGalaxy.Commands.Building {
|
||||
namespace MCGalaxy.Commands.Building {
|
||||
public sealed class CmdTriangle : DrawCmd {
|
||||
public override string name { get { return "triangle"; } }
|
||||
public override string shortcut { get { return "tri"; } }
|
||||
public override int MarksCount { get { return 3; } }
|
||||
|
||||
protected override string PlaceMessage {
|
||||
get { return "Place three blocks to determine the edges."; }
|
||||
}
|
||||
|
||||
protected override bool DoDraw(Player p, Vec3S32[] marks, object state, byte type, byte extType) {
|
||||
DrawArgs cpos = (DrawArgs)state;
|
||||
cpos.block = type; cpos.extBlock = extType;
|
||||
|
||||
Brush brush = GetBrush(p, cpos, 0, null);
|
||||
if (brush == null) return false;
|
||||
return DrawOp.DoDrawOp(new TriangleDrawOp(), brush, p, marks);
|
||||
}
|
||||
|
||||
protected override DrawMode ParseMode(string msg) { return DrawMode.normal; }
|
||||
protected override DrawOp GetDrawOp(DrawArgs dArgs, Vec3S32[] m) {
|
||||
return new TriangleDrawOp();
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
Player.Message(p, "%T/triangle [brush args]");
|
||||
@ -45,4 +38,4 @@ namespace MCGalaxy.Commands.Building {
|
||||
Player.Message(p, " %HFor help about brushes, type %T/help brush%H.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
using MCGalaxy.Drawing.Brushes;
|
||||
using MCGalaxy.Drawing.Ops;
|
||||
using System;
|
||||
|
||||
namespace MCGalaxy.Commands.Building {
|
||||
@ -38,18 +39,38 @@ namespace MCGalaxy.Commands.Building {
|
||||
p.MakeSelection(MarksCount, cpos, DoDraw);
|
||||
}
|
||||
|
||||
protected abstract bool DoDraw(Player p, Vec3S32[] marks, object state, byte type, byte extType);
|
||||
protected virtual bool DoDraw(Player p, Vec3S32[] marks,
|
||||
object state, byte block, byte extBlock) {
|
||||
DrawArgs dArgs = (DrawArgs)state;
|
||||
dArgs.block = block; dArgs.extBlock = extBlock;
|
||||
marks = GetMarks(dArgs, marks);
|
||||
DrawOp op = GetDrawOp(dArgs);
|
||||
|
||||
int offset = 0;
|
||||
BrushFactory factory = GetBrush(p, dArgs, ref offset);
|
||||
Brush brush = ParseBrush(p, dArgs, offset, factory);
|
||||
return brush != null && DrawOp.DoDrawOp(op, brush, p, marks);
|
||||
}
|
||||
|
||||
protected virtual string PlaceMessage { get { return "Place two blocks to determine the edges."; } }
|
||||
|
||||
protected abstract DrawMode ParseMode(string mode);
|
||||
protected virtual string PlaceMessage {
|
||||
get { return "Place two blocks to determine the edges."; }
|
||||
}
|
||||
|
||||
protected virtual void OnUse(Player p, string msg, string[] parts, ref DrawArgs cpos) { }
|
||||
|
||||
protected virtual DrawMode GetMode(string message, string[] parts) {
|
||||
return message == "" ? DrawMode.normal : ParseMode(parts[parts.Length - 1]);
|
||||
|
||||
protected virtual DrawMode GetMode(string[] parts) { return DrawMode.Normal; }
|
||||
|
||||
protected virtual void GetMarks(DrawArgs dArgs, Vec3S32[] m) { return m; }
|
||||
|
||||
protected virtual BrushFactory GetBrush(Player p, DrawArgs dArgs, ref int brushOffset) {
|
||||
brushOffset = dArgs.mode == DrawMode.normal ? 0 : 1;
|
||||
return BrushFactory.Find(p.BrushName);
|
||||
}
|
||||
|
||||
protected abstract DrawOp GetDrawOp(DrawArgs dArgs, Vec3S32[] m);
|
||||
|
||||
|
||||
internal static int GetBlock(Player p, string msg, out byte extBlock, bool checkPlacePerm = true) {
|
||||
byte block = Block.Byte(msg);
|
||||
extBlock = 0;
|
||||
@ -72,7 +93,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
return block;
|
||||
}
|
||||
|
||||
protected static Brush GetBrush(Player p, DrawArgs dArgs,
|
||||
protected static Brush ParseBrush(Player p, DrawArgs dArgs,
|
||||
int usedFromEnd, BrushFactory factory = null) {
|
||||
int end = dArgs.message.Length;
|
||||
string brushMsg = "";
|
||||
|
@ -125,8 +125,8 @@ namespace MCGalaxy.Drawing.Ops {
|
||||
if (ctile != 0) continue;
|
||||
|
||||
bool layer = dist >= (curRadius - 1) * (curRadius - 1);
|
||||
byte type = layer ? Block.grass : Block.lavastill;
|
||||
yield return Place(x, y, z, type, 0);
|
||||
byte block = layer ? Block.grass : Block.lavastill;
|
||||
yield return Place(x, y, z, block, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user