public virtual bool Prepare([NotNull] Vector3I[] marks) { if (marks == null) { throw new ArgumentNullException("marks"); } if (marks.Length != ExpectedMarks) { string msg = String.Format("Wrong number of marks ({0}), expecting {1}.", marks.Length, ExpectedMarks); throw new ArgumentException(msg, "marks"); } Marks = marks; if (marks.Length == 2) { Bounds = new BoundingBox(Marks[0], Marks[1]); } if (Brush == null) { throw new NullReferenceException(Name + ": Brush not set"); } return(Brush.Begin(Player, this)); }
public override bool Prepare(Vector3I[] marks) { if (marks == null) { throw new ArgumentNullException("marks"); } if (marks.Length < 1) { throw new ArgumentException("At least one mark needed.", "marks"); } Marks = marks; Origin = marks[0]; SourceBlock = Map.GetBlock(Origin); if (Player.Info.Rank.DrawLimit == 0) { // Unlimited! Bounds = Map.Bounds; } else { // Our fill limit is cube root of DrawLimit double pow = Math.Pow(Player.Info.Rank.DrawLimit, 1 / 3d); int maxLimit = (int)Math.Ceiling(pow / 2); // Compute the largest possible extent if (maxLimit < 1 || maxLimit > 2048) { maxLimit = 2048; } Vector3I maxDelta = new Vector3I(maxLimit, maxLimit, maxLimit); Bounds = new BoundingBox(Origin - maxDelta, Origin + maxDelta); // Clip bounds to the map, used to limit fill extent Bounds = Bounds.GetIntersection(Map.Bounds); } // Set everything up for filling Coords = Origin; width = Map.Width; length = Map.Length; height = Map.Height; StartTime = DateTime.UtcNow; Context = BlockChangeContext.Drawn | BlockChangeContext.Filled; BlocksTotalEstimate = Bounds.Volume; coordEnumerator = BlockEnumerator().GetEnumerator(); if (Brush == null) { throw new NullReferenceException(Name + ": Brush not set"); } return(Brush.Begin(Player, this)); }
public override bool Prepare(Vector3I[] marks) { if (marks == null) { throw new ArgumentNullException("marks"); } if (marks.Length < 1) { throw new ArgumentException("At least one mark needed.", "marks"); } Marks = marks; Origin = marks[0]; SourceBlock = Map.GetBlock(Origin); Vector3I playerCoords = Player.Position.ToBlockCoords(); Vector3I lookVector = (Origin - playerCoords); Axis = lookVector.LongestAxis; Vector3I maxDelta; maxFillExtent = Player.Info.Rank.FillLimit; if (maxFillExtent < 1 || maxFillExtent > 2048) { maxFillExtent = 2048; } switch (Axis) { case Axis.X: maxDelta = new Vector3I(0, maxFillExtent, maxFillExtent); coordEnumerator = BlockEnumeratorX().GetEnumerator(); break; case Axis.Y: maxDelta = new Vector3I(maxFillExtent, 0, maxFillExtent); coordEnumerator = BlockEnumeratorY().GetEnumerator(); break; default: // Z maxDelta = new Vector3I(maxFillExtent, maxFillExtent, 0); coordEnumerator = BlockEnumeratorZ().GetEnumerator(); break; } Bounds = new BoundingBox(Origin - maxDelta, Origin + maxDelta); // Clip bounds to the map, used to limit fill extent Bounds = Bounds.GetIntersection(Map.Bounds); // Set everything up for filling Coords = Origin; StartTime = DateTime.UtcNow; Context = BlockChangeContext.Drawn | BlockChangeContext.Filled; BlocksTotalEstimate = Bounds.Volume; if (Brush == null) { throw new NullReferenceException(Name + ": Brush not set"); } return(Brush.Begin(Player, this)); }