Object used to store
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
 public UndoDrawOperation(Player player, UndoState state, bool redo)
     : base(player)
 {
     State = state;
     Redo  = redo;
     if (Redo)
     {
         undoContext |= BlockChangeContext.Redone;
     }
 }
Esempio n. 3
0
 /// <summary> Begins the execution of this DrawOperation.
 /// Raises DrawOperation.Beginning (cancelable) and DrawOperation.Began events. </summary>
 /// <returns> True if operation started successfully.
 /// False if operation was cancelled by an event callback. </returns>
 public virtual bool Begin() {
     if (!RaiseBeginningEvent(this))
         return false;
     UndoState = Player.DrawBegin(this);
     StartTime = DateTime.UtcNow;
     HasBegun = true;
     Map.QueueDrawOp(this);
     RaiseBeganEvent(this);
     return true;
 }
Esempio n. 4
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. 5
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. 6
0
 /// <summary> Begins the execution of this DrawOperation.
 /// Raises DrawOperation.Beginning (cancelable) and DrawOperation.Began events. </summary>
 /// <returns> True if operation started succesfully.
 /// False if operation was canceled by an event callback. </returns>
 public virtual bool Begin() {
     if( !RaiseBeginningEvent( this ) ) return false;
     UndoState = Player.DrawBegin( this );
     StartTime = DateTime.UtcNow;
     HasBegun = true;
     Map.QueueDrawOp( this );
     RaiseBeganEvent( this );
     return true;
 }
Esempio n. 7
0
 public UndoDrawOperation( Player player, UndoState state, bool redo )
     : base(player)
 {
     State = state;
     Redo = redo;
 }
Esempio n. 8
0
 public UndoDrawOperation(Player player, UndoState state, bool redo)
     : base(player)
 {
     State = state;
     Redo  = redo;
 }