void PushState() { ChestTimeState cts = new ChestTimeState(); cts.isOpen = isOpen; cts.finishedOpening = finishedOpening; cts.openingTimerSecondsLeft = finishedOpeningTimer.SecondsLeft; states.Add(cts); }
void PopState() { int lastIndex = states.Count - 1; if (lastIndex > -1) { ChestTimeState lastState = states[lastIndex]; states.RemoveAt(lastIndex); if (!lastState.isOpen && isOpen) { Close(); } if (lastState.finishedOpening) { reverseAudioManager. CreateReverseAudioSource(AudioClipName.ChestOpen); } finishedOpening = lastState.finishedOpening; finishedOpeningTimer.Duration = lastState.openingTimerSecondsLeft; } }