public override void Undo(BeatmapActionContainer.BeatmapActionParams param)
    {
        if (_originalObject != _editedObject || _editedData._time.CompareTo(_originalData._time) != 0)
        {
            _collection.DeleteObject(_editedObject, false, false);
            SelectionController.Deselect(_editedObject, false);

            _originalObject.Apply(_originalData);
            _collection.SpawnObject(_originalObject, false, !InCollection);
        }
        else
        {
            // This is an optimisation only possible if the object has not changed position in the SortedSet
            _originalObject.Apply(_originalData);
            if (!InCollection)
            {
                RefreshPools(Data);
            }
        }

        SelectionController.Select(_originalObject, _addToSelection, true, !InCollection);
    }
Пример #2
0
    public IEnumerator LoadObjects <T>(IEnumerable <T> objects) where T : BeatmapObject
    {
        if (!objects.Any())
        {
            yield break;
        }
        BeatmapObjectContainerCollection collection = BeatmapObjectContainerCollection.GetCollectionForType((objects.First() as T).beatmapType);

        if (collection == null)
        {
            yield break;
        }
        foreach (BeatmapObjectContainer obj in new List <BeatmapObjectContainer>(collection.LoadedContainers))
        {
            collection.DeleteObject(obj);
        }
        PersistentUI.Instance.LevelLoadSlider.gameObject.SetActive(true);
        Queue <T> queuedData = new Queue <T>(objects);

        batchSize          = Settings.Instance.InitialLoadBatchSize;
        totalObjectsToLoad = queuedData.Count;
        totalObjectsLoaded = 0;
        while (queuedData.Count > 0)
        { //Batch loading is loading a certain amount of objects (Batch Size) every frame, so at least ChroMapper remains active.
            for (int i = 0; i < batchSize; i++)
            {
                if (queuedData.Count == 0)
                {
                    break;
                }
                BeatmapObject          data = queuedData.Dequeue(); //Dequeue and load them into ChroMapper.
                BeatmapObjectContainer obj  = collection.SpawnObject(data, false, false);
                if (data is BeatmapNote noteData)
                {
                    if (noteData._lineIndex >= 1000 || noteData._lineIndex <= -1000 || noteData._lineLayer >= 1000 || noteData._lineLayer <= -1000)
                    {
                        continue;
                    }
                    if (2 - noteData._lineIndex > noteLaneSize)
                    {
                        noteLaneSize = 2 - noteData._lineIndex;
                    }
                    if (noteData._lineIndex - 1 > noteLaneSize)
                    {
                        noteLaneSize = noteData._lineIndex - 1;
                    }
                    if (noteData._lineLayer + 1 > noteLayerSize)
                    {
                        noteLayerSize = noteData._lineLayer + 1;
                    }
                }
                else if (data is BeatmapObstacle obstacleData)
                {
                    if (obstacleData._lineIndex >= 1000 || obstacleData._lineIndex <= -1000)
                    {
                        continue;
                    }
                    if (2 - obstacleData._lineIndex > noteLaneSize)
                    {
                        noteLaneSize = 2 - obstacleData._lineIndex;
                    }
                    if (obstacleData._lineIndex - 1 > noteLaneSize)
                    {
                        noteLaneSize = obstacleData._lineIndex - 1;
                    }
                }
            }
            UpdateSlider <T>(batchSize);
            yield return(new WaitForEndOfFrame());
        }
        collection.RemoveConflictingObjects();
        if (objects.First() is BeatmapNote || objects.First() is BeatmapObstacle)
        {
            if (Settings.NonPersistentSettings.ContainsKey("NoteLanes"))
            {
                Settings.NonPersistentSettings["NoteLanes"] = (noteLaneSize * 2).ToString();
            }
            else
            {
                Settings.NonPersistentSettings.Add("NoteLanes", (noteLaneSize * 2).ToString());
            }
            noteLanesController.UpdateNoteLanes((noteLaneSize * 2).ToString());
        }
        if (objects.First() is MapEvent)
        {
            manager.RefreshTracks();
        }
        PersistentUI.Instance.LevelLoadSlider.gameObject.SetActive(false);
    }