Esempio n. 1
0
 public UndoDrawOperation( Player player, UndoState state, bool redo )
     : base( player ) {
     State = state;
     Redo = redo;
     if( Redo ) {
         undoContext |= BlockChangeContext.Redone;
     }
 }
Esempio n. 2
0
 internal static void RaisePlayerPlacedBlockEvent(Player player, Map map, Vector3I coords,
                                                   Block oldBlock, Block newBlock, BlockChangeContext context)
 {
     var handler = PlacedBlock;
     if (handler != null)
     {
         handler(null, new PlayerPlacedBlockEventArgs(player, map, coords, oldBlock, newBlock, context));
     }
 }
Esempio n. 3
0
 /// <summary> Initializes a new instance of UndoDrawOperation. </summary>
 /// <param name="player"> Player initiating this draw operation. May not be null. </param>
 /// <param name="state"> UndoState to work with. May not be null. </param>
 /// <param name="redo"> Whether state should be undone (false) or redone (true). </param>
 /// <exception cref="ArgumentNullException"> player or state is null </exception>
 public UndoDrawOperation([NotNull] Player player, [NotNull] UndoState state, bool redo)
     : base(player) {
     if (state == null) throw new ArgumentNullException("state");
     State = state;
     Redo = redo;
     if (Redo) {
         undoContext |= BlockChangeContext.Redone;
     }
 }
 internal PlayerPlacedBlockEventArgs([NotNull] Player player, [NotNull] Map map, Vector3I coords,
                                     Block oldBlock, Block newBlock, BlockChangeContext context)
 {
     Player   = player;
     Map      = map ?? throw new ArgumentNullException(nameof(map));
     Coords   = coords;
     OldBlock = oldBlock;
     NewBlock = newBlock;
     Context  = context;
 }
Esempio n. 5
0
 public UndoDrawOperation(Player player, UndoState state, bool redo)
     : base(player)
 {
     State = state;
     Redo  = redo;
     if (Redo)
     {
         undoContext |= BlockChangeContext.Redone;
     }
 }
Esempio n. 6
0
 public BlockDBEntry( int timestamp, int playerID, short x, short y, short z,
                      Block oldBlock, Block newBlock, BlockChangeContext flags ) {
     Timestamp = timestamp;
     PlayerID = playerID;
     X = x;
     Y = y;
     Z = z;
     OldBlock = oldBlock;
     NewBlock = newBlock;
     Context = flags;
 }
Esempio n. 7
0
 public BlockDBEntry(int timestamp, int playerId, Vector3I coords,
                     Block oldBlock, Block newBlock, BlockChangeContext flags) {
     Timestamp = timestamp;
     PlayerId = playerId;
     X = (short)coords.X;
     Y = (short)coords.Y;
     Z = (short)coords.Z;
     OldBlock = oldBlock;
     NewBlock = newBlock;
     Context = flags;
 }
Esempio n. 8
0
 public BlockDBEntry(int timestamp, int playerID, short x, short y, short z,
                     Block oldBlock, Block newBlock, BlockChangeContext flags)
 {
     Timestamp = timestamp;
     PlayerID  = playerID;
     X         = x;
     Y         = y;
     Z         = z;
     OldBlock  = oldBlock;
     NewBlock  = newBlock;
     Context   = flags;
 }
Esempio n. 9
0
 public BlockDBEntry(int timestamp, int playerID, Vector3I coords,
                     Block oldBlock, Block newBlock, BlockChangeContext flags)
 {
     Timestamp = timestamp;
     PlayerID  = playerID;
     X         = (short)coords.X;
     Y         = (short)coords.Y;
     Z         = (short)coords.Z;
     OldBlock  = oldBlock;
     NewBlock  = newBlock;
     Context   = flags;
 }
Esempio n. 10
0
 /// <summary> Initializes a new instance of UndoDrawOperation. </summary>
 /// <param name="player"> Player initiating this draw operation. May not be null. </param>
 /// <param name="state"> UndoState to work with. May not be null. </param>
 /// <param name="redo"> Whether state should be undone (false) or redone (true). </param>
 /// <exception cref="ArgumentNullException"> player or state is null </exception>
 public UndoDrawOperation([NotNull] Player player, [NotNull] UndoState state, bool redo)
     : base(player)
 {
     if (state == null)
     {
         throw new ArgumentNullException("state");
     }
     State = state;
     Redo  = redo;
     if (Redo)
     {
         undoContext |= BlockChangeContext.Redone;
     }
 }
Esempio n. 11
0
 internal PlayerPlacingBlockEventArgs([NotNull] Player player, [NotNull] Map map, Vector3I coords,
                                      Block oldBlock, Block newBlock, BlockChangeContext context,
                                      CanPlaceResult result)
 {
     if (map == null)
     {
         throw new ArgumentNullException("map");
     }
     Player   = player;
     Map      = map;
     Coords   = coords;
     OldBlock = oldBlock;
     NewBlock = newBlock;
     Context  = context;
     Result   = result;
 }
Esempio n. 12
0
        private static void DrawOneBlock(Player player, Map map, Block drawBlock, Vector3I coord,
                                         BlockChangeContext context, ref int blocks, ref int blocksDenied, fCraft.Drawing.UndoState undoState)
        {
            if (map == null)
            {
                return;
            }
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }

            if (!map.InBounds(coord))
            {
                return;
            }
            Block block = map.GetBlock(coord);

            if (block == drawBlock)
            {
                return;
            }

            if (player.CanPlace(map, coord, drawBlock, context) != CanPlaceResult.Allowed)
            {
                blocksDenied++;
                return;
            }

            map.QueueUpdate(new BlockUpdate(null, coord, drawBlock));
            Player.RaisePlayerPlacedBlockEvent(player, map, coord, block, drawBlock, context);

            if (!undoState.IsTooLargeToUndo)
            {
                if (!undoState.Add(coord, block))
                {
                    player.Message("NOTE: This draw command is too massive to undo.");
                    player.LastDrawOp = null;
                }
            }
            blocks++;
        }
Esempio n. 13
0
        static void DrawOneBlock( [NotNull] Player player, [NotNull] Map map, Block drawBlock, Vector3I coord,
                                  BlockChangeContext context, ref int blocks, ref int blocksDenied, UndoState undoState ) {
            if( player == null ) throw new ArgumentNullException( "player" );

            if( !map.InBounds( coord ) ) return;
            Block block = map.GetBlock( coord );
            if( block == drawBlock ) return;

            if( player.CanPlace( map, coord, drawBlock, context ) != CanPlaceResult.Allowed ) {
                blocksDenied++;
                return;
            }

            map.QueueUpdate( new BlockUpdate( null, coord, drawBlock ) );
            Player.RaisePlayerPlacedBlockEvent( player, map, coord, block, drawBlock, context );

            if( !undoState.IsTooLargeToUndo ) {
                if( !undoState.Add( coord, block ) ) {
                    player.MessageNow( "NOTE: This draw command is too massive to undo." );
                    player.LastDrawOp = null;
                }
            }
            blocks++;
        }
Esempio n. 14
0
 internal PlayerPlacingBlockEventArgs([NotNull] Player player, [NotNull] Map map, Vector3I coords,
                                      Block oldBlock, Block newBlock, BlockChangeContext context, CanPlaceResult result)
     : base(player, map, coords, oldBlock, newBlock, context)
 {
     Result = result;
 }
Esempio n. 15
0
        public static void RaisePlayerPlacedBlockEvent(Player player, Map map, Vector3I coords,
                                                       Block oldBlock, Block newBlock, BlockChangeContext context)
        {
            var handler = PlacedBlock;

            if (handler != null)
            {
                handler(null, new PlayerPlacedBlockEventArgs(player, map, coords, oldBlock, newBlock, context));
            }
        }
Esempio n. 16
0
 internal static void RaisePlayerPlacedBlockEvent( Player player, Map map, Vector3I coords,
                                                   Block oldBlock, Block newBlock, BlockChangeContext context ) {
     var e = new PlayerPlacedBlockEventArgs( player, map, coords, oldBlock, newBlock, context );
     PlacedBlockEvent.Raise( e );
 }
Esempio n. 17
0
 internal PlayerPlacingBlockEventArgs( [NotNull] Player player, [NotNull] Map map, Vector3I coords,
                                       Block oldBlock, Block newBlock, BlockChangeContext context, CanPlaceResult result )
     : base( player, map, coords, oldBlock, newBlock, context ) {
     Result = result;
 }
Esempio n. 18
0
 internal PlayerPlacedBlockEventArgs( [NotNull] Player player, [NotNull] Map map, Vector3I coords,
                                      Block oldBlock, Block newBlock, BlockChangeContext context ) {
     if( map == null ) throw new ArgumentNullException( "map" );
     Player = player;
     Map = map;
     Coords = coords;
     OldBlock = oldBlock;
     NewBlock = newBlock;
     Context = context;
 }
Esempio n. 19
0
        internal static void RaisePlayerPlacedBlockEvent(Player player, Map map, Vector3I coords,
                                                         Block oldBlock, Block newBlock, BlockChangeContext context)
        {
            var e = new PlayerPlacedBlockEventArgs(player, map, coords, oldBlock, newBlock, context);

            PlacedBlockEvent.Raise(e);
        }