//instance public FontHandler(Block block, Vector3I[] marks, Player p, Direction dir) { direction = dir; blockCount = 0; player = p; origin = marks[0]; blockColor = block; undoState = player.DrawBegin(null); }
Direction direction; //direction of the blocks (x++-- ect) //instance public FontHandler ( Block textColor, Vector3I[] Marks, Player p, Direction dir ) { direction = dir; blockCount = 0; player = p; PixelData.X = Marks[0].X; PixelData.Y = Marks[0].Y; PixelData.Z = Marks[0].Z; PixelData.BlockColor = textColor; undoState = player.DrawBegin( null ); }
private fCraft.Drawing.UndoState undoState; //undostate //instance public FontHandler(Block textColor, Vector3I[] Marks, Player p, Direction dir) { direction = dir; blockCount = 0; player = p; PixelData.X = Marks[0].X; PixelData.Y = Marks[0].Y; PixelData.Z = Marks[0].Z; PixelData.BlockColor = textColor; undoState = player.DrawBegin(null); }
public ShapesLib(Block block, Vector3I[] marks, Player p, int radius, Direction dir) { this.marks = marks; direction = dir; blockCount = 0; player = p; origin = marks[0]; blockColor = block; undoState = player.DrawBegin(null); Radius = radius; }
//instance public ShapesLib ( Block BlockColor, Vector3I[] Marks, Player p, int radius, Direction dir ) { marks = Marks; direction = dir; blockCount = 0; player = p; PixelData.X = Marks[0].X; PixelData.Y = Marks[0].Y; PixelData.Z = Marks[0].Z; PixelData.BlockColor = BlockColor; undoState = player.DrawBegin( null ); Radius = radius; }
private fCraft.Drawing.UndoState undoState; //undostate //instance public ShapesLib(Block BlockColor, Vector3I[] Marks, Player p, int radius, Direction dir) { marks = Marks; direction = dir; blockCount = 0; player = p; PixelData.X = Marks[0].X; PixelData.Y = Marks[0].Y; PixelData.Z = Marks[0].Z; PixelData.BlockColor = BlockColor; undoState = player.DrawBegin(null); Radius = radius; }
static void RestoreCallback( Player player, Vector3I[] marks, object 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 ); }
static void CenterCallback(Player player, Vector3I[] marks, object tag) { if (player.LastUsedBlockType != Block.Undefined) { int sx = Math.Min(marks[0].X, marks[1].X), ex = Math.Max(marks[0].X, marks[1].X), sy = Math.Min(marks[0].Y, marks[1].Y), ey = Math.Max(marks[0].Y, marks[1].Y), sz = Math.Min(marks[0].Z, marks[1].Z), ez = Math.Max(marks[0].Z, marks[1].Z); BoundingBox bounds = new BoundingBox(sx, sy, sz, ex, ey, ez); Vector3I cPos = new Vector3I((bounds.XMin + bounds.XMax) / 2, (bounds.YMin + bounds.YMax) / 2, (bounds.ZMin + bounds.ZMax) / 2); int blocksDrawn = 0, blocksSkipped = 0; UndoState undoState = player.DrawBegin(null); World playerWorld = player.World; if (playerWorld == null) PlayerOpException.ThrowNoWorld(player); Map map = player.WorldMap; DrawOneBlock(player, player.World.Map, player.LastUsedBlockType, cPos, BlockChangeContext.Drawn, ref blocksDrawn, ref blocksSkipped, undoState); DrawingFinished(player, "Placed", blocksDrawn, blocksSkipped); }else{ player.Message("&WCannot deduce desired block. Click a block or type out the block name."); } }
static void UndoPlayerHandler2(Player player, Command cmd) { if (player.World == null) PlayerOpException.ThrowNoWorld(player); if (!BlockDB.IsEnabledGlobally) { player.Message("&WBlockDB is disabled on this server.\nThe undo of the player's blocks failed."); return; } World world = player.World; if (!world.BlockDB.IsEnabled) { player.Message("&WBlockDB is disabled in this world.\nThe undo of the player's blocks failed."); return; } string name = cmd.Next(); string range = cmd.Next(); if (name == null || range == null) { CdUndoPlayer.PrintUsage(player); return; } PlayerInfo target = PlayerDB.FindPlayerInfoOrPrintMatches(player, name); if (target == null) return; if (player.Info != target && !player.Can(Permission.UndoOthersActions, target.Rank)) { player.Message("You may only undo actions of players ranked {0}&S or lower.", player.Info.Rank.GetLimit(Permission.UndoOthersActions).ClassyName); player.Message("Player {0}&S is ranked {1}", target.ClassyName, target.Rank.ClassyName); return; } int count; TimeSpan span; BlockDBEntry[] changes; if (Int32.TryParse(range, out count)) { changes = world.BlockDB.Lookup(target, count); if (changes.Length > 0) { player.Confirm(cmd, "Undo last {0} changes made by player {1}&S?", changes.Length, target.ClassyName); return; } } else if (range.TryParseMiniTimespan(out span)) { changes = world.BlockDB.Lookup(target, span); if (changes.Length > 0) { player.Confirm(cmd, "Undo changes ({0}) made by {1}&S in the last {2}?", changes.Length, target.ClassyName, span.ToMiniString()); return; } } else { CdBanx.PrintUsage(player); return; } if (changes.Length == 0) { player.Message("BanX: Found nothing to undo."); return; } BlockChangeContext context = BlockChangeContext.Drawn; if (player.Info == target) { context |= BlockChangeContext.UndoneSelf; } else { context |= BlockChangeContext.UndoneOther; } int blocks = 0, blocksDenied = 0; UndoState undoState = player.DrawBegin(null); Map map = player.World.Map; for (int i = 0; i < changes.Length; i++) { DrawOneBlock(player, map, changes[i].OldBlock, changes[i].Coord, context, ref blocks, ref blocksDenied, undoState); } Logger.Log(LogType.UserActivity, "{0} undid {1} blocks changed by player {2} (on world {3})", player.Name, blocks, target.Name, player.World.Name); DrawingFinished(player, "UndoPlayer'ed", blocks, blocksDenied); }
static void UndoAreaTimeConfirmCallback( Player player, object tag, bool fromConsole ) { UndoAreaTimeArgs args = (UndoAreaTimeArgs)tag; BlockDBEntry[] changes = args.World.BlockDB.Lookup( args.Target, args.Area, args.Time ); BlockChangeContext context = BlockChangeContext.Drawn; if( player.Info == args.Target ) { context |= BlockChangeContext.UndoneSelf; } else { context |= BlockChangeContext.UndoneOther; } int blocks = 0, blocksDenied = 0; UndoState undoState = player.DrawBegin( null ); Map map = player.WorldMap; for( int i = 0; i < changes.Length; i++ ) { DrawOneBlock( player, map, changes[i].OldBlock, changes[i].Coord, context, ref blocks, ref blocksDenied, undoState ); } Logger.Log( LogType.UserActivity, "{0} undid {1} blocks changed by player {2} (in a selection on world {3})", player.Name, blocks, args.Target.Name, args.World.Name ); DrawingFinished( player, "UndoArea'd", blocks, blocksDenied ); }
static void TreeCallback(Player player, Vector3I[] marks, object tag) { ForesterArgs args = (ForesterArgs)tag; int blocksPlaced = 0, blocksDenied = 0; UndoState undoState = player.DrawBegin(null); args.BlockPlacing += (sender, e) => DrawOneBlock(player, player.World.Map, e.Block, new Vector3I(e.Coordinate.X, e.Coordinate.Y, e.Coordinate.Z), BlockChangeContext.Drawn, ref blocksPlaced, ref blocksDenied, undoState); Forester.SexyPlant(args, marks[0]); DrawingFinished(player, "/Tree: Planted", blocksPlaced, blocksDenied); }
private static void SnakeHandler(Player player, CommandReader cmd) { string slength = cmd.Next(); int length; if (slength == null) { player.Message(CdSnake.Usage); return; } if (!int.TryParse(slength, out length)) { player.Message("Invalid Integer: ({0})", slength); return; } string sblock = cmd.Next(); Block newBlock; if (sblock == null) { if (player.LastUsedBlockType != Block.None) { player.Message("No block specified, Using last used block ({0})", player.LastUsedBlockType.ToString()); newBlock = player.LastUsedBlockType; } else { player.Message("&WCannot deduce desired block. Click a block or type out the block name."); return; } } else { if (!Map.GetBlockByName(sblock, false, out newBlock)) { if (player.LastUsedBlockType != Block.None) { player.Message("No block specified, Using last used block ({0})", player.LastUsedBlockType.ToString()); newBlock = player.LastUsedBlockType; } else { player.Message("&WCannot deduce desired block. Click a block or type out the block name."); return; } } } Random dir = new Random(); Vector3I posStart = new Vector3I(player.Position.X / 32, player.Position.Y / 32, player.Position.Z / 32); if (player.World != null && player.World.Map != null) { int blocksDrawn = 0, blocksSkipped = 0; UndoState undoState = player.DrawBegin(null); for (int i = 1; i <= length; i++) { Vector3I posx = new Vector3I(posStart.X + dir.Next(0, 2) * 2 - 1, posStart.Y, posStart.Z); Vector3I posy = new Vector3I(posStart.X, posStart.Y + dir.Next(0, 2) * 2 - 1, posStart.Z); Vector3I posz = new Vector3I(posStart.X, posStart.Y, posStart.Z + dir.Next(0, 2) * 2 - 1); posStart = new Vector3I(posx.X, posy.Y, posz.Z); DrawOneBlock(player, player.World.Map, newBlock, posx, BlockChangeContext.Drawn, ref blocksDrawn, ref blocksSkipped, undoState); DrawOneBlock(player, player.World.Map, newBlock, posy, BlockChangeContext.Drawn, ref blocksDrawn, ref blocksSkipped, undoState); DrawOneBlock(player, player.World.Map, newBlock, posz, BlockChangeContext.Drawn, ref blocksDrawn, ref blocksSkipped, undoState); } DrawingFinished(player, "Placed", blocksDrawn, blocksSkipped); } }