Example #1
0
 public void PressDown()
 {
     if (command != null)
     {
         command.Undo();
     }
 }
Example #2
0
 //Выполняет введенную команду
 public void ExecuteCommand(string input)
 {
     if (input.Length == 1)
     {
         char commandDirection = input[0];
         //Отмена последней команды
         if (commandDirection == 'c')
         {
             //Если стек команд не пуст
             if (rover._commands.Count != 0)
             {
                 //Взять и удалить последнюю команду из стека
                 ICommand c = rover._commands.Pop();
                 //Отменить эту команду
                 c.Undo();
             }
         }
         else
         {
             //Создать новую команду на передвижение
             var command = new RoverCommand(commandDirection, rover);
             //Выполнить ее
             command.Execute();
         }
     }
 }
        /// <summary>
        /// Rollback the commands that have been executed already.
        /// </summary>
        public void Rollback()
        {
            if (!_contextRolledback)
            {
                ProcessorContext.Rollback();
                _contextRolledback = true;
            }

            while (_stack.Count > 0)
            {
                ICommand command = _stack.Pop();

                try
                {
                    command.Undo();
                }
                catch (Exception e)
                {
                    Platform.Log(LogLevel.Error, e, "Unexpected exception rolling back command {0}", command.Description);
                }

                var aggregateCommand = command as IAggregateCommand;
                if (aggregateCommand != null)
                {
                    RollbackAggregateCommand(aggregateCommand);
                }
            }
        }
Example #4
0
            void SetHideFlags()
            {
                SyncColliderWithRectTransform scwrt = target as SyncColliderWithRectTransform;

                if (!scwrt.SyncedCollider)
                {
                    return;
                }

                if (SHF != null)
                {
                    SHF.Undo();
                }
                SHF = new UnityCommands.SetHideFlags(scwrt.SyncedCollider, HideFlags.NotEditable);
                SHF.Execute();
            }
Example #5
0
        public void Undo()
        {
            // Undo is not supported for player units.
            // We may want to consider splitting this command in two: Spawn initial unit / Spawn unit
            if (_data.unitCommandData.UnitType == UnitType.Player)
            {
                _logger.Log(LoggedFeature.Replays, "Not undoing command since unit type is player.");
                return;
            }

            // Despawn pets first.
            // We need to directly run the command since these are children of the parent spawn unit command,
            // and should never be ran as standalone
            for (var i = 0; i < _data.unitCommandData.pets.Length; i++)
            {
                ICommand petSpawnCommand =
                    _commandFactory.Create(typeof(SpawnUnitCommand),
                                           typeof(SpawnUnitData),
                                           new SpawnUnitData(_data.unitCommandData.pets[i],
                                                             _data.tileCoords,
                                                             _data.isInitialSpawn));
                petSpawnCommand.Undo();
            }

            // Now the unit itself.
            IUnit unit = _unitRegistry.GetUnit(_data.unitCommandData.unitId);

            _unitPool.Despawn(unit.UnitId);
            _gridUnitManager.RemoveUnit(unit);
        }
Example #6
0
        public void Undo()
        {
            ICommand cmd = StackRedo.Pop();

            cmd.Undo();
            StackRedo.Push(cmd);
        }
        public void Undo()
        {
            if (history.Count > 0)
            {
                ICommand recent = history.Pop();
                recent.Undo();
                redos.Push(recent);

                if (history.PeekTop() is Move topAsMove)
                {
                    //After we undo, lets re-collect items or get killed by lasers or whatever, if that was where we were.
                    if (topAsMove.executedValidAndComplete)
                    {
                        _puzzleManager.preMoveComplete?.Invoke(topAsMove);
                        _puzzleManager.postMoveComplete?.Invoke(topAsMove);
                    }
                }

                if (!recent.HistoryPoint)
                {
                    Undo();                    //recursive loop!
                }
            }
            _puzzleManager.TurnCounter.RemoveTurn();
            _puzzleManager.TriggerMachine();
            OnUndo?.Invoke();
        }
Example #8
0
 public override void Undo()
 {
     if (_command != null)
     {
         _command.Undo();
     }
 }
Example #9
0
        private void UndoMostRecentCommand()
        {
            ICommand command = _history.PopCommand();

            command.Undo();
            Refresh();
        }
Example #10
0
        private void Undo()
        {
            if (_commandMemoryList.Count == 0)
            {
                return;
            }

            var command = _commandMemoryList[_commandMemoryList.Count - 1];

            switch (command.Type)
            {
            case CommandType.None:
                break;

            case CommandType.MoveRight:
                _moveRightCommand.Undo(_actor);
                break;

            case CommandType.MoveLeft:
                _moveLeftCommand.Undo(_actor);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            _commandMemoryList.RemoveAt(_commandMemoryList.Count - 1);
        }
        /// <summary>clears queued commands</summary>
        public void Undo()
        {
            _currentCommand.Undo();
            _currentCommand = null;

            _commands.Clear();
        }
 public void StopProject()
 {
     if (command != null)
     {
         command.Undo();
     }
 }
 public void Cancel()
 {
     if (preparing != null)
     {
         preparing.Undo();
         preparing = null;
     }
 }
Example #14
0
        /// <summary>
        /// Executes Undo of the current command from the list.
        /// </summary>
        public void Undo()
        {
            ICommand command = commandsList[currentCommandIndex] as ICommand;

            command.Undo();
            currentCommandIndex -= 1;
            SetUndoRedoMessages();
        }
Example #15
0
 public void Undo()
 {
     if (commandsHistory.Count > 0)
     {
         ICommand undoCommand = commandsHistory.Pop();
         undoCommand.Undo();
     }
 }
Example #16
0
        public void Undo()
        {
            ICommand com = undoStack[undoStack.Count - 1];

            com.Undo();
            undoStack.Remove(com);
            redoStack.Add(com);
        }
Example #17
0
 public void Undo()
 {
     if (commandStack.Count > 0)
     {
         ICommand cmd = (ICommand)commandStack.Pop();
         cmd.Undo();
     }
 }
Example #18
0
            void SetHideFlags()
            {
                PathPosition pathPosition = target as PathPosition;

                //don't hide transform if there is no path yet
                if (!pathPosition.Path)
                {
                    return;
                }

                if (SHF != null)
                {
                    SHF.Undo();
                }
                SHF = new UnityCommands.SetHideFlags(pathPosition.transform, HideFlags.NotEditable);
                SHF.Execute();
            }
Example #19
0
 public void PressUndoButton()
 {
     if (_commandsHistory.Count > 0)
     {
         ICommand command = _commandsHistory.Pop();
         command.Undo();
     }
 }
 public void Undo()
 {
     while (_commands.Count > 0)
     {
         ICommand command = _commands.Pop();
         command.Undo();
     }
 }
Example #21
0
 public void Undo()
 {
     while (_cmdStack.Count > 0)
     {
         ICommand cmd = _cmdStack.Pop();
         cmd.Undo();
     }
 }
 public void Undo()
 {
     if (CanUndo())
     {
         ICommand <TItem> command = Commands.Pop();
         command.Undo(Items);
     }
 }
Example #23
0
 public void PressUndoButton()
 {
     if (commandsHistory.Count > 0)
     {
         ICommand undoCommand = commandsHistory.Pop();
         undoCommand.Undo();
     }
 }
Example #24
0
 public void Undo()
 {
     if (_currentCommandNum > 0)
     {
         _currentCommandNum--;
         ICommand command = commands[_currentCommandNum];
         command.Undo();
     }
 }
Example #25
0
 public void Undo()
 {
     if (historyUndo.Count > 0)
     {
         ICommand command = historyUndo.Pop();
         historyRedo.Push(command);
         command.Undo();
     }
 }
Example #26
0
 public void OnClick(ref Context context)
 {
     if (context.undoStack.Count > 0)
     {
         ICommand c = context.undoStack.Pop();
         context.redoStack.Push(c);
         c.Undo(ref context);
     }
 }
 protected override void OnConditionNotMet()
 {
     if (_wasPassageAllowed)
     {
         _command.Undo();
         NotifyOnNext(new EventPuzzle(PuzzleStatus.NotSolved, outOfPathBlock.name));
     }
     _wasPassageAllowed = false;
 }
Example #28
0
 public void CancelCommand()
 {
     if (_currentcommand != null && _currentcommand.Count > 0)
     {
         _currentcommand.Undo();
     }
     _commandtype    = CommandTypes.None;
     _currentcommand = null;
 }
Example #29
0
        /// <summary>
        /// Executes Undo of the current command from the list.
        /// </summary>
        public void Undo()
        {
            ICommand command
                = this.commandsList[this.currentCommandIndex] as ICommand;

            command.Undo();
            this.currentCommandIndex -= 1;
            this.SetUndoRedoMessages();
        }
Example #30
0
 public string Undo(int number)
 {
     if (commandsHistory.Count > 0)
     {
         ICommand undoCommand = commandsHistory.Pop();
         return(undoCommand.Undo());
     }
     return("No any past state");
 }
Example #31
0
        public void Undo(ICommand command)
        {
            if (CanUndo(command))
            {
                undoStack.Pop();

                command.Undo();

                redoStack.Push(command);
            }
        }
Example #32
0
 protected virtual bool DoUnexecute(ICommand command)
 {
     try
     {
         command.Undo();
         return true;
     }
     catch (CommandExecutionCancelledException)
     {
         return false;
     }
 }
 public void UndoButtonPressed(ICommand command)
 {
     command.Undo();
 }
Example #34
0
		void Undo(ICommand c)
		{
			c.Undo(this);
			redoStack.Push(c);
			UndoCapabilityChanged();
		}