public void Redo(int numberOfRedo = 1) { for (int i = 0; i < numberOfRedo; i++) { if (RedoBuffer.Count == 0) { return; } var last = RedoBuffer.OrderByDescending(kvp => kvp.Key).Last(); RedoBuffer.Remove(last.Key); var level = last.Value.Level; var undoRecorder = new UndoRecorder(level, false); var editSession = new EditHelper(level, undoRecorder: undoRecorder); // Redo var restore = last.Value.Postsnapshot; foreach (Block block in restore) { editSession.SetBlock(block); } var history = undoRecorder.CreateHistory(); AddHistory(history, true); } }
public override bool Animate(Level world, Player player) { player.Inventory.SendSetSlot(player.Inventory.InHandSlot); var selector = RegionSelector.GetSelector(player); var undoRecorder = new UndoRecorder(player.Level); var editSession = new EditHelper(player.Level, Mask, undoRecorder: undoRecorder); var target = new EditHelper(world).GetBlockInLineOfSight(player.Level, player.KnownPosition, returnLastAir: true); if (target == null) { player.SendMessage("No block in range"); return(false); } try { switch (BrushType) { case 0: editSession.MakeSphere(target.Coordinates, Pattern, Radius, Radius, Radius, Filled); break; case 1: editSession.MakeCylinder(target.Coordinates, Pattern, Radius, Radius, Height, Filled); break; case 3: // public ErosionParameters(final int erosionFaces, final int erosionRecursion, final int fillFaces, final int fillRecursion) { //MELT(new ErosionParameters(2, 1, 5, 1)), //FILL(new ErosionParameters(5, 1, 2, 1)), //SMOOTH(new ErosionParameters(3, 1, 3, 1)), //LIFT(new ErosionParameters(6, 0, 1, 1)), //FLOATCLEAN(new ErosionParameters(6, 1, 6, 1)); Erosion(editSession, Radius, 2, 1, 5, 1, world, target.Coordinates); // melt break; case 2: Erosion(editSession, Radius, 5, 1, 2, 1, world, target.Coordinates); // fill break; } } catch (Exception e) { Log.Error("Brush use item", e); } var history = undoRecorder.CreateHistory(); selector.AddHistory(history); return(true); }