public void Move(RegionSelector selector, int count, BlockCoordinates dir) { var selected = new List <BlockCoordinates>(selector.GetSelectedBlocks()); // Save old blocks with new coordinates so we don't overwrite while traverse List <Block> movedBlocks = new List <Block>(); foreach (var coord in selected.ToArray()) { Block block = _level.GetBlock(coord); block.Coordinates += (dir * count); movedBlocks.Add(block); selected.Remove(block.Coordinates); } // Actually move them foreach (var block in movedBlocks) { SetBlock(block); } // Set the left-overs (gap) to air foreach (var coord in selected) { SetBlock(new Air { Coordinates = coord }); } // Move selection too selector.Select(selector.Position1 + (dir * count), selector.Position2 + (dir * count)); }
public void Stack(RegionSelector selector, int count, BlockCoordinates dir, bool skipAir, bool moveSelection) { BlockCoordinates size = selector.GetMax() - selector.GetMin() + BlockCoordinates.One; var selected = new List <BlockCoordinates>(selector.GetSelectedBlocks()); // Save old blocks with new coordinates so we don't overwrite while traverse List <Block> movedBlocks = new List <Block>(); for (int i = 1; i <= count; i++) { foreach (var coord in selected.ToArray()) { Block block = _level.GetBlock(coord); block.Coordinates += (dir * size * i); movedBlocks.Add(block); } } // Actually stack them foreach (var block in movedBlocks) { if (skipAir && block is Air) { continue; } SetBlock(block); } // Move selection too last stack if (moveSelection) { selector.Select(selector.Position1 + (dir * size * count), selector.Position2 + (dir * size * count)); } }