Example #1
0
    /// <summary>
    /// Undoes the most recent action.
    /// </summary>
    public void UndoAction()
    {
        while (m_deltaHistory.Count > 0 && !m_deltaHistory.Peek().Valid)
        {
            m_deltaHistory.Pop();
        }

        if (m_deltaHistory.Count == 0 ||
            (m_currentDelta != null && m_currentIsUndo) ||
            !m_deltaHistory.Peek().CanUndo())
        {
            Dispatcher <Sfx> .Broadcast(AudioManager.kPlaySfx, Sfx.Invalid);

            return;
        }

        Dispatcher <Sfx> .Broadcast(AudioManager.kPlaySfx, Sfx.Select);

        m_currentIsUndo = true;
        m_currentDelta  = m_deltaHistory.Pop();
        m_deltaFuture.Push(m_currentDelta);
        m_currentDelta.UndoAction(this, OnDeltaDone);
    }