static void RestoreCallback([NotNull] Player player, [NotNull] Vector3I[] marks, [NotNull] object tag) {
if (player == null) throw new ArgumentNullException("player");
if (marks == null) throw new ArgumentNullException("marks");
if (tag == null) throw new ArgumentNullException("tag");
BoundingBox selection = new BoundingBox(marks[0], marks[1]);
Map map = (Map)tag;
if (!player.CanDraw(selection.Volume)) {
player.MessageNow(
"You are only allowed to restore up to {0} blocks at a time. This would affect {1} blocks.",
player.Info.Rank.DrawLimit,
selection.Volume);
return;
}
int blocksDrawn = 0,
blocksSkipped = 0;
UndoState undoState = player.DrawBegin(null);
World playerWorld = player.World;
if (playerWorld == null) PlayerOpException.ThrowNoWorld(player);
Map playerMap = player.WorldMap;
Vector3I coord = new Vector3I();
for (coord.X = selection.XMin; coord.X <= selection.XMax; coord.X++) {
for (coord.Y = selection.YMin; coord.Y <= selection.YMax; coord.Y++) {
for (coord.Z = selection.ZMin; coord.Z <= selection.ZMax; coord.Z++) {
DrawOneBlock(player,
playerMap,
map.GetBlock(coord),
coord,
RestoreContext,
ref blocksDrawn,
ref blocksSkipped,
undoState);
}
}
}
Logger.Log(LogType.UserActivity,
"{0} restored {1} blocks on world {2} (@{3},{4},{5} - {6},{7},{8}) from file {9}.",
player.Name,
blocksDrawn,
playerWorld.Name,
selection.XMin,
selection.YMin,
selection.ZMin,
selection.XMax,
selection.YMax,
selection.ZMax,
map.Metadata["fCraft.Temp", "FileName"]);
DrawingFinished(player, "Restored", blocksDrawn, blocksSkipped);
}