public static bool Do(DrawOp op, Brush brush, Player p, Vec3S32[] marks, bool checkLimit = true) { Level lvl = p.level; op.Setup(p, lvl, marks); if (lvl != null && !lvl.Config.Drawing && !op.AlwaysUsable) { p.Message("Drawing commands are turned off on this map."); return(false); } if (lvl != null && CannotBuildIn(p, lvl)) { return(false); } long affected = op.BlocksAffected(lvl, marks); if (op.AffectedByTransform) { p.Transform.GetBlocksAffected(ref affected); } if (checkLimit && !op.CanDraw(marks, p, affected)) { return(false); } if (brush != null && affected != -1) { const string format = "{0}({1}): affecting up to {2} blocks"; if (!p.Ignores.DrawOutput) { p.Message(format, op.Name, brush.Name, affected); } } else if (affected != -1) { const string format = "{0}: affecting up to {1} blocks"; if (!p.Ignores.DrawOutput) { p.Message(format, op.Name, affected); } } DoQueuedDrawOp(p, op, brush, marks); return(true); }
public override long BlocksAffected(Level lvl, Vec3S32[] marks) { Vec3S32 p1 = Min, p2 = Max; long total = 0; while (p1.Y >= 0 && p1.Y < lvl.Height && p1.X <= p2.X && p1.Z <= p2.Z) { baseOp.Min = p1; baseOp.Max = p2; total += baseOp.BlocksAffected(lvl, marks); p1.X++; p2.X--; p1.Z++; p2.Z--; p1.Y += yDir; p2.Y = p1.Y; } return(total); }
public static bool Do(DrawOp op, Brush brush, Player p, Vec3S32[] marks, bool checkLimit = true) { Level lvl = Setup(op, p, marks); if (lvl != null && !lvl.Config.DrawingAllowed) { Player.Message(p, "Drawing commands are turned off on this map."); return(false); } if (lvl != null && !lvl.BuildAccess.CheckDetailed(p)) { Player.Message(p, "Hence you cannot use draw commands on this map."); return(false); } long affected = op.BlocksAffected(lvl, marks); if (p != null && op.AffectedByTransform) { p.Transform.GetBlocksAffected(ref affected); } if (checkLimit && !op.CanDraw(marks, p, affected)) { return(false); } if (brush != null && affected != -1) { const string format = "{0}({1}): affecting up to {2} blocks"; if (p == null || !p.Ignores.DrawOutput) { Player.Message(p, format, op.Name, brush.Name, affected); } } else if (affected != -1) { const string format = "{0}: affecting up to {1} blocks"; if (p == null || !p.Ignores.DrawOutput) { Player.Message(p, format, op.Name, affected); } } DoQueuedDrawOp(p, op, brush, marks); return(true); }
public static bool DoDrawOp(DrawOp op, Brush brush, Player p, Vec3S32[] marks, bool checkLimit = true) { op.SetMarks(marks); op.Level = p == null ? null : p.level; op.Player = p; if (op.Level != null && !op.Level.DrawingAllowed) { Player.Message(p, "Drawing commands are turned off on this map."); return(false); } if (op.Level != null && op.Level.BuildAccess.Check(p) == LevelAccess.Blacklisted) { Player.Message(p, "You are blacklisted from building in this map, " + "hence you cannot draw in this map"); return(false); } long affected = op.BlocksAffected(op.Level, marks); if (p != null && op.AffectedByTransform) { p.Transform.GetBlocksAffected(ref affected); } if (checkLimit && !op.CanDraw(marks, p, affected)) { return(false); } if (brush != null && affected != -1) { const string format = "{0}({1}): affecting up to {2} blocks"; Player.Message(p, format, op.Name, brush.Name, affected); } else if (affected != -1) { const string format = "{0}: affecting up to {1} blocks"; Player.Message(p, format, op.Name, affected); } AppendDrawOp(p, op, brush, marks, affected); return(true); }
public override long BlocksAffected(Level lvl, Vec3S32[] marks) { Vec3S32 oMin = Min, oMax = Max; baseOp.Min = oMin; baseOp.Max = oMax; Vec3S32 p1 = Min, p2 = Max; long total = 0; while (true) { total += baseOp.BlocksAffected(lvl, marks); if (p1.Y >= lvl.Height || Math.Abs(p2.X - p1.X) <= 1 || Math.Abs(p2.Z - p1.Z) <= 1) { break; } p1.X++; p2.X--; p1.Z++; p2.Z--; p1.Y = (ushort)(p1.Y + yDir); p2.Y = p1.Y; baseOp.Min = p1; baseOp.Max = p2; } baseOp.Min = oMin; baseOp.Max = oMax; return(total); }