From f576adabd18b5a1743aee3f6553f30be3d0e66f1 Mon Sep 17 00:00:00 2001 From: Goodlyay Date: Sat, 23 Aug 2025 17:47:42 -0700 Subject: [PATCH] add left/right/front/back modes to /outline --- MCGalaxy/Commands/building/CmdOutline.cs | 39 ++++++++++++++--------- MCGalaxy/Drawing/DrawOps/CuboidDrawOps.cs | 28 ++++++++++++---- 2 files changed, 45 insertions(+), 22 deletions(-) diff --git a/MCGalaxy/Commands/building/CmdOutline.cs b/MCGalaxy/Commands/building/CmdOutline.cs index 01bd2df01..309944cda 100644 --- a/MCGalaxy/Commands/building/CmdOutline.cs +++ b/MCGalaxy/Commands/building/CmdOutline.cs @@ -38,24 +38,33 @@ namespace MCGalaxy.Commands.Building { if (!CommandParser.GetBlock(p, parts[0], out target)) return null; OutlineDrawOp op = new OutlineDrawOp(); - // e.g. testing air 'above' grass - therefore op.Above needs to be false for 'up mode' - if (dArgs.Mode == DrawMode.up) { op.Layer = false; op.Above = false; } - if (dArgs.Mode == DrawMode.down) { op.Layer = false; op.Below = false; } - if (dArgs.Mode == DrawMode.layer) { op.Above = false; op.Below = false; } + op.side = GetSides(dArgs.Message.SplitSpaces()); + if (op.side == OutlineDrawOp.Side.Unspecified) op.side = OutlineDrawOp.Side.All; op.Target = target; return op; } - - - protected override DrawMode GetMode(string[] parts) { - if (parts.Length == 1) return DrawMode.normal; - + + OutlineDrawOp.Side GetSides(string[] parts) { + if (parts.Length == 1) return OutlineDrawOp.Side.Unspecified; + string type = parts[1]; - if (type == "down") return DrawMode.down; - if (type == "up") return DrawMode.up; - if (type == "layer") return DrawMode.layer; - if (type == "all") return DrawMode.solid; - return DrawMode.normal; + if (type == "left") return OutlineDrawOp.Side.Left; + if (type == "right") return OutlineDrawOp.Side.Right; + if (type == "front") return OutlineDrawOp.Side.Front; + if (type == "back") return OutlineDrawOp.Side.Back; + if (type == "down") return OutlineDrawOp.Side.Down; + if (type == "up") return OutlineDrawOp.Side.Up; + + if (type == "layer") return OutlineDrawOp.Side.Layer; + if (type == "all") return OutlineDrawOp.Side.All; + + return OutlineDrawOp.Side.Unspecified; + } + + // Parts is just Command.Use's message.SplitSpaces() + protected override DrawMode GetMode(string[] parts) { + // Need to return "normal" if a unique side was typed, otherwise "not normal". This tells the ModeArgsCount how to work correctly + return GetSides(parts) == OutlineDrawOp.Side.Unspecified ? DrawMode.normal : DrawMode.solid; } protected override void GetBrush(DrawArgs dArgs) { @@ -66,7 +75,7 @@ namespace MCGalaxy.Commands.Building { p.Message("&T/Outline [block] "); p.Message("&HOutlines [block] with output of your current brush."); p.Message("&T/Outline [block] [mode] "); - p.Message("&HModes: &fall/up/layer/down (default all)"); + p.Message("&HModes: &fall/up/layer/down/left/right/front/back (default all)"); p.Message(BrushHelpLine); } } diff --git a/MCGalaxy/Drawing/DrawOps/CuboidDrawOps.cs b/MCGalaxy/Drawing/DrawOps/CuboidDrawOps.cs index 97d9fc6b1..3744aa1d2 100644 --- a/MCGalaxy/Drawing/DrawOps/CuboidDrawOps.cs +++ b/MCGalaxy/Drawing/DrawOps/CuboidDrawOps.cs @@ -65,9 +65,23 @@ namespace MCGalaxy.Drawing.Ops public class OutlineDrawOp : CuboidDrawOp { + [Flags] + public enum Side : byte { + Unspecified = 0, + Left = 1 << 0, + Right = 1 << 1, + Front = 1 << 2, + Back = 1 << 3, + Up = 1 << 4, + Down = 1 << 5, + + Layer = Left | Right | Front | Back, + All = Layer | Up | Down, + } + public override string Name { get { return "Outline"; } } public BlockID Target; - public bool Above = true, Layer = true, Below = true; + public Side side; public override void Perform(Vec3S32[] marks, Brush brush, DrawOpOutput output) { Vec3U16 p1 = Clamp(Min), p2 = Clamp(Max); @@ -76,12 +90,12 @@ namespace MCGalaxy.Drawing.Ops for (ushort x = p1.X; x <= p2.X; x++) { bool outline = false; - outline |= Layer && Level.GetBlock((ushort)(x - 1), y, z) == Target; - outline |= Layer && Level.GetBlock((ushort)(x + 1), y, z) == Target; - outline |= Layer && Level.GetBlock(x, y, (ushort)(z - 1)) == Target; - outline |= Layer && Level.GetBlock(x, y, (ushort)(z + 1)) == Target; - outline |= Below && Level.GetBlock(x, (ushort)(y - 1), z) == Target; - outline |= Above && Level.GetBlock(x, (ushort)(y + 1), z) == Target; + outline |= (side & Side.Left ) > 0 && Level.GetBlock((ushort)(x + 1), y, z) == Target; + outline |= (side & Side.Right) > 0 && Level.GetBlock((ushort)(x - 1), y, z) == Target; + outline |= (side & Side.Front) > 0 && Level.GetBlock(x, y, (ushort)(z + 1)) == Target; + outline |= (side & Side.Back ) > 0 && Level.GetBlock(x, y, (ushort)(z - 1)) == Target; + outline |= (side & Side.Down ) > 0 && Level.GetBlock(x, (ushort)(y + 1), z) == Target; + outline |= (side & Side.Up ) > 0 && Level.GetBlock(x, (ushort)(y - 1), z) == Target; if (outline && Level.GetBlock(x, y, z) != Target) output(Place(x, y, z, brush));