protected override void GetMarks(DrawArgs dArgs, ref Vec3S32[] m) { int radius = 0, height = 0; string[] args = dArgs.Message.SplitSpaces(); AdvDrawOp op = (AdvDrawOp)dArgs.Op; if ((op.UsesHeight && !CheckTwoArgs(dArgs.Player, ref radius, ref height, args)) || (!op.UsesHeight && !CheckOneArg(dArgs.Player, ref radius, args))) { m = null; return; } Vec3S32 P = m[0]; m = new Vec3S32[] { new Vec3S32(P.X - radius, P.Y, P.Z - radius), new Vec3S32(P.X + radius, P.Y, P.Z + radius), }; if (op.UsesHeight) { m[1].Y += height; } else { m[0].Y -= radius; m[1].Y += radius; } }
bool CheckOneArg(Player p, AdvDrawOp op, string[] parts) { if (parts.Length < 2) { Help(p); return(false); } if (!ushort.TryParse(parts[parts.Length - 2], out op.Radius) || op.Radius > 2000) { Player.SendMessage(p, "Radius must be a positive integer less than 2000."); return(false); } return(true); }
bool CheckTwoArgs(Player p, AdvDrawOp op, string[] parts) { if (parts.Length < 3) { Help(p); return(false); } if (!ushort.TryParse(parts[parts.Length - 3], out op.Height) || op.Height > 2000 || !ushort.TryParse(parts[parts.Length - 2], out op.Radius) || op.Radius > 2000) { Player.SendMessage(p, "Radius and height must be positive integers less than 2000."); return(false); } return(true); }
protected override DrawOp GetDrawOp(DrawArgs dArgs) { AdvDrawOp op = null; switch (dArgs.Mode) { case DrawMode.cone: op = new AdvConeDrawOp(); break; case DrawMode.hcone: op = new AdvHollowConeDrawOp(); break; case DrawMode.icone: op = new AdvConeDrawOp(true); break; case DrawMode.hicone: op = new AdvHollowConeDrawOp(true); break; case DrawMode.pyramid: op = new AdvPyramidDrawOp(); break; case DrawMode.hpyramid: op = new AdvHollowPyramidDrawOp(); break; case DrawMode.ipyramid: op = new AdvPyramidDrawOp(true); break; case DrawMode.hipyramid: op = new AdvHollowPyramidDrawOp(true); break; case DrawMode.sphere: op = new AdvSphereDrawOp(); break; case DrawMode.hsphere: op = new AdvHollowSphereDrawOp(); break; case DrawMode.volcano: op = new AdvVolcanoDrawOp(); break; } if (op == null) { Help(dArgs.Player); return(null); } // Validate radius/height when the user first uses the command int radius = 0, height = 0; string[] args = dArgs.Message.SplitSpaces(); if ((op.UsesHeight && !CheckTwoArgs(dArgs.Player, ref radius, ref height, args)) || (!op.UsesHeight && !CheckOneArg(dArgs.Player, ref radius, args))) { return(null); } return(op); }
protected override void GetMarks(DrawArgs dArgs, ref Vec3S32[] m) { AdvDrawOp op = (AdvDrawOp)dArgs.Op; AdvDrawMeta meta = (AdvDrawMeta)dArgs.Meta; int radius = meta.radius; Vec3S32 P = m[0]; m = new Vec3S32[] { new Vec3S32(P.X - radius, P.Y, P.Z - radius), new Vec3S32(P.X + radius, P.Y, P.Z + radius), }; if (op.UsesHeight) { m[1].Y += meta.height; } else { m[0].Y -= radius; m[1].Y += radius; } }
protected override DrawOp GetDrawOp(DrawArgs dArgs) { AdvDrawOp op = null; switch (dArgs.Mode) { case DrawMode.cone: op = new AdvConeDrawOp(); break; case DrawMode.hcone: op = new AdvHollowConeDrawOp(); break; case DrawMode.icone: op = new AdvConeDrawOp(true); break; case DrawMode.hicone: op = new AdvHollowConeDrawOp(true); break; case DrawMode.pyramid: op = new AdvPyramidDrawOp(); break; case DrawMode.hpyramid: op = new AdvHollowPyramidDrawOp(); break; case DrawMode.ipyramid: op = new AdvPyramidDrawOp(true); break; case DrawMode.hipyramid: op = new AdvHollowPyramidDrawOp(true); break; case DrawMode.sphere: op = new AdvSphereDrawOp(); break; case DrawMode.hsphere: op = new AdvHollowSphereDrawOp(); break; case DrawMode.volcano: op = new AdvVolcanoDrawOp(); break; } if (op == null) { Help(dArgs.Player); return(null); } AdvDrawMeta meta = new AdvDrawMeta(); bool success = false; string[] args = dArgs.Message.SplitSpaces(); Player p = dArgs.Player; if (op.UsesHeight) { if (args.Length < 3) { p.Message("You need to provide the radius and the height for the {0}.", args[0]); } else { success = CommandParser.GetInt(p, args[1], "radius", ref meta.radius, 0, 2000) && CommandParser.GetInt(p, args[2], "height", ref meta.height, 0, 2000); } } else { if (args.Length < 2) { p.Message("You need to provide the radius for the {0}.", args[0]); } else { success = CommandParser.GetInt(p, args[1], "radius", ref meta.radius, 0, 2000); } } if (!success) { return(null); } dArgs.Meta = meta; return(op); }
protected override void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { RevertAndClearState(p, x, y, z); CatchPos cpos = (CatchPos)p.blockchangeObject; GetRealBlock(type, extType, p, ref cpos); AdvDrawOp op = null; switch (cpos.mode) { case DrawMode.cone: op = new AdvConeDrawOp(); break; case DrawMode.hcone: op = new AdvHollowConeDrawOp(); break; case DrawMode.icone: op = new AdvConeDrawOp(); op.Invert = true; break; case DrawMode.hicone: op = new AdvHollowConeDrawOp(); op.Invert = true; break; case DrawMode.pyramid: op = new AdvPyramidDrawOp(); break; case DrawMode.hpyramid: op = new AdvHollowPyramidDrawOp(); break; case DrawMode.ipyramid: op = new AdvPyramidDrawOp(); op.Invert = true; break; case DrawMode.hipyramid: op = new AdvHollowPyramidDrawOp(); op.Invert = true; break; case DrawMode.sphere: op = new AdvSphereDrawOp(); op.Invert = true; break; case DrawMode.hsphere: op = new AdvHollowSphereDrawOp(); op.Invert = true; break; case DrawMode.volcano: op = new AdvVolcanoDrawOp(); break; default: Help(p); return; } string[] args = cpos.message.Split(' '); if ((op.UsesHeight && !CheckTwoArgs(p, op, args)) || (!op.UsesHeight && !CheckOneArg(p, op, args))) { return; } int brushOffset = op.UsesHeight ? 3 : 2; Brush brush = GetBrush(p, cpos, brushOffset); if (brush == null) { return; } if (!DrawOp.DoDrawOp(op, brush, p, new [] { new Vec3U16(x, y, z) })) { return; } if (p.staticCommands) { p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1); } }