예제 #1
0
        /// <summary>Initializes the correct number of snapshots, allocating memory for them in advance</summary>
        public void InitializeSnapshotsForLevel(Level level)
        {
            for (int i = 0; i < _maxMajorSnapshots; i++)
            {
                var majorSnapshot = level.InitializeSnapshot();
                _majorLevelSnapshots.AddLast(majorSnapshot);
            }

            _tentativeSnapshot         = level.InitializeSnapshot();
            _tentativeSnapshotComparer = level.InitializeSnapshot();
        }
예제 #2
0
        public void FinalizeTentativeSnapshot()
        {
            // Get the oldest snapshot in the list and remove it
            var snapshot = _majorLevelSnapshots.First.Value;

            _majorLevelSnapshots.RemoveFirst();

            // Add the tentive snapshot to the end
            _majorLevelSnapshots.AddLast(_tentativeSnapshot);

            // Reassign the tentative snapshot
            _tentativeSnapshot    = snapshot;
            _hasTentativeSnapshot = false;

            if (++_availableUndos > _maxMajorSnapshots)
            {
                _availableUndos = _maxMajorSnapshots;
            }
        }