public IEnumerator HardRefresh() { if (Settings.Instance.Load_Notes) { yield return(StartCoroutine(LoadObjects(map._notes))); } if (Settings.Instance.Load_Obstacles) { yield return(StartCoroutine(LoadObjects(map._obstacles))); } if (Settings.Instance.Load_Events) { yield return(StartCoroutine(LoadObjects(map._events))); } if (Settings.Instance.Load_Others) { yield return(StartCoroutine(LoadObjects(map._BPMChanges))); yield return(StartCoroutine(LoadObjects(map._customEvents))); } PersistentUI.Instance.LevelLoadSliderLabel.text = "Finishing up..."; manager.RefreshTracks(); SelectionController.RefreshMap(); PersistentUI.Instance.LevelLoadSlider.gameObject.SetActive(false); }
private IEnumerator RefreshMap(bool notes, bool obstacles, bool events, bool others, bool full) { yield return(PersistentUI.Instance.FadeInLoadingScreen()); map = song.GetMapFromDifficultyBeatmap(diff); loader.UpdateMapData(map); float currentBeat = atsc.CurrentBeat; atsc.MoveToTimeInBeats(0); if (notes || full) { yield return(StartCoroutine(loader.LoadObjects(map._notes))); } if (obstacles || full) { yield return(StartCoroutine(loader.LoadObjects(map._obstacles))); } if (events || full) { yield return(StartCoroutine(loader.LoadObjects(map._events))); } if (others || full) { yield return(StartCoroutine(loader.LoadObjects(map._BPMChanges))); } if (others || full) { yield return(StartCoroutine(loader.LoadObjects(map._customEvents))); } tracksManager.RefreshTracks(); SelectionController.RefreshMap(); atsc.MoveToTimeInBeats(currentBeat); yield return(PersistentUI.Instance.FadeOutLoadingScreen()); }
/// <summary> /// Deletes and clears the current selection. /// </summary> public void Delete(bool triggersAction = true) { if (triggersAction) { BeatmapActionContainer.AddAction(new SelectionDeletedAction(SelectedObjects)); } foreach (BeatmapObjectContainer con in SelectedObjects) { foreach (BeatmapObjectContainerCollection container in collections) { container.DeleteObject(con, false); } } SelectedObjects.Clear(); RefreshMap(); tracksManager.RefreshTracks(); }
public void OnInvertEventValue(InputAction.CallbackContext context) { if (customStandaloneInputModule.IsPointerOverGameObject <GraphicRaycaster>(-1, true)) { return; } if (KeybindsController.AnyCriticalKeys) { return; } RaycastFirstObject(out BeatmapEventContainer e); if (e != null) { if (e.eventData.IsRotationEvent) { int?rotation = e.eventData.GetRotationDegreeFromValue(); if (rotation != null) { if (e.eventData._value >= 0 && e.eventData._value < MapEvent.LIGHT_VALUE_TO_ROTATION_DEGREES.Length) { e.eventData._value = MapEvent.LIGHT_VALUE_TO_ROTATION_DEGREES.ToList().IndexOf((rotation ?? 0) * -1); } else if (e.eventData._value >= 1000 && e.eventData._value <= 1720) //Invert Mapping Extensions rotation { e.eventData._value = 1720 - (e.eventData._value - 1000); } } eventAppearanceSO?.SetEventAppearance(e); tracksManager?.RefreshTracks(); return; } if (e.eventData.IsUtilityEvent) { return; } if (e.eventData._value > 4 && e.eventData._value < 8) { e.eventData._value -= 4; } else if (e.eventData._value > 0 && e.eventData._value <= 4) { e.eventData._value += 4; } eventAppearanceSO?.SetEventAppearance(e); } }
public IEnumerator HardRefresh() { if (Settings.Instance.Load_Notes) { yield return(StartCoroutine(LoadObjects(map._notes))); } if (Settings.Instance.Load_Obstacles) { yield return(StartCoroutine(LoadObjects(map._obstacles))); } if (Settings.Instance.Load_Events) { yield return(StartCoroutine(LoadObjects(map._events))); } if (Settings.Instance.Load_Others) { yield return(StartCoroutine(LoadObjects(map._customEvents))); } manager.RefreshTracks(); }
public void InvertEvent(BeatmapEventContainer e) { BeatmapObject original = BeatmapObject.GenerateCopy(e.objectData); if (e.eventData.IsRotationEvent) { int?rotation = e.eventData.GetRotationDegreeFromValue(); if (rotation != null) { if (e.eventData._value >= 0 && e.eventData._value < MapEvent.LIGHT_VALUE_TO_ROTATION_DEGREES.Length) { e.eventData._value = MapEvent.LIGHT_VALUE_TO_ROTATION_DEGREES.ToList().IndexOf((rotation ?? 0) * -1); } else if (e.eventData._value >= 1000 && e.eventData._value <= 1720) //Invert Mapping Extensions rotation { e.eventData._value = 1720 - (e.eventData._value - 1000); } tracksManager?.RefreshTracks(); } } else if (e.eventData.IsUtilityEvent) { return; } else { if (e.eventData._value > 4 && e.eventData._value < 8) { e.eventData._value -= 4; } else if (e.eventData._value > 0 && e.eventData._value <= 4) { e.eventData._value += 4; } } eventAppearanceSO?.SetEventAppearance(e); BeatmapActionContainer.AddAction(new BeatmapObjectModifiedAction(e.objectData, e.objectData, original)); }
internal virtual void ApplyToMap() { objectData = BeatmapObject.GenerateCopy(queuedData); objectData._time = RoundedTime; BOC spawned = objectContainerCollection.SpawnObject(objectData, out BeatmapObjectContainer conflicting) as BOC; BeatmapActionContainer.AddAction(GenerateAction(spawned, conflicting)); queuedData = BeatmapObject.GenerateCopy(queuedData); if (AssignTo360Tracks) { Vector3 localRotation = spawned.transform.localEulerAngles; Track track = tracksManager.GetTrackForRotationValue(gridRotation.Rotation); track?.AttachContainer(spawned); spawned.UpdateGridPosition(); spawned.transform.localEulerAngles = localRotation; tracksManager.RefreshTracks(); } }
public void UpdateAppearance(BeatmapObjectContainer obj) { switch (obj) { case BeatmapNoteContainer note: note.Directionalize(note.mapNoteData._cutDirection); noteAppearance.SetNoteAppearance(note); break; case BeatmapEventContainer e: eventAppearance.SetEventAppearance(e); break; case BeatmapObstacleContainer o: obstacleAppearance.SetObstacleAppearance(o); break; } tracksManager.RefreshTracks(); obj.UpdateGridPosition(); SelectionController.RefreshMap(); }
public void Mirror() { if (!SelectionController.HasSelectedObjects()) { PersistentUI.Instance.DisplayMessage("Select stuff first!", PersistentUI.DisplayMessageType.BOTTOM); return; } foreach (BeatmapObjectContainer con in SelectionController.SelectedObjects) { if (con is BeatmapObstacleContainer obstacle) { bool precisionWidth = obstacle.obstacleData._width >= 1000; int __state = obstacle.obstacleData._lineIndex; if (__state >= 1000 || __state <= -1000 || precisionWidth) // precision lineIndex { int newIndex = __state; if (newIndex <= -1000) // normalize index values, we'll fix them later { newIndex += 1000; } else if (newIndex >= 1000) { newIndex -= 1000; } else { newIndex = newIndex * 1000; //convert lineIndex to precision if not already } newIndex = (((newIndex - 2000) * -1) + 2000); //flip lineIndex int newWidth = obstacle.obstacleData._width; //normalize wall width if (newWidth < 1000) { newWidth = newWidth * 1000; } else { newWidth -= 1000; } newIndex = newIndex - newWidth; if (newIndex < 0) { //this is where we fix them newIndex -= 1000; } else { newIndex += 1000; } obstacle.obstacleData._lineIndex = newIndex; } else // state > -1000 || state < 1000 assumes no precision width { int mirrorLane = (((__state - 2) * -1) + 2); //flip lineIndex obstacle.obstacleData._lineIndex = mirrorLane - obstacle.obstacleData._width; //adjust for wall width } con.UpdateGridPosition(); } else if (con is BeatmapNoteContainer note) { int __state = note.mapNoteData._lineIndex; // flip line index if (__state > 3 || __state < 0) // precision case { int newIndex = __state; if (newIndex <= -1000) // normalize index values, we'll fix them later { newIndex += 1000; } else if (newIndex >= 1000) { newIndex -= 1000; } newIndex = (((newIndex - 1500) * -1) + 1500); //flip lineIndex if (newIndex < 0) //this is where we fix them { newIndex -= 1000; } else { newIndex += 1000; } note.mapNoteData._lineIndex = newIndex; } else { int mirrorLane = (int)(((__state - 1.5f) * -1) + 1.5f); note.mapNoteData._lineIndex = mirrorLane; } con.UpdateGridPosition(); //flip colors if (note.mapNoteData is BeatmapChromaNote chroma) { note.mapNoteData = chroma.originalNote; //Revert Chroma status, then invert types } if (note.mapNoteData._type != BeatmapNote.NOTE_TYPE_BOMB) { note.mapNoteData._type = note.mapNoteData._type == BeatmapNote.NOTE_TYPE_A ? BeatmapNote.NOTE_TYPE_B : BeatmapNote.NOTE_TYPE_A; //flip cut direction horizontally if (CutDirectionToMirrored.ContainsKey(note.mapNoteData._cutDirection)) { note.mapNoteData._cutDirection = CutDirectionToMirrored[note.mapNoteData._cutDirection]; note.Directionalize(note.mapNoteData._cutDirection); } } noteAppearance.SetNoteAppearance(note); } else if (con is BeatmapEventContainer e) { if (e.eventData.IsRotationEvent) { int?rotation = e.eventData.GetRotationDegreeFromValue(); if (rotation != null) { if (e.eventData._value >= 0 && e.eventData._value < MapEvent.LIGHT_VALUE_TO_ROTATION_DEGREES.Length) { e.eventData._value = MapEvent.LIGHT_VALUE_TO_ROTATION_DEGREES.ToList().IndexOf((rotation ?? 0) * -1); } else if (e.eventData._value >= 1000 && e.eventData._value <= 1720) //Invert Mapping Extensions rotation { e.eventData._value = 1720 - (e.eventData._value - 1000); } } eventAppearance?.SetEventAppearance(e); tracksManager?.RefreshTracks(); return; } if (e.eventData.IsUtilityEvent) { return; } if (e.eventData._value > 4 && e.eventData._value < 8) { e.eventData._value -= 4; } else if (e.eventData._value > 0 && e.eventData._value <= 4) { e.eventData._value += 4; } eventAppearance?.SetEventAppearance(e); } } SelectionController.RefreshMap(); }
/// <summary> /// Pastes any copied objects into the map, selecting them immediately. /// </summary> public void Paste(bool triggersAction = true, bool overwriteSection = false) { DeselectAll(); // Set up stuff that we need List <BeatmapObject> pasted = new List <BeatmapObject>(); Dictionary <BeatmapObject.Type, BeatmapObjectContainerCollection> collections = new Dictionary <BeatmapObject.Type, BeatmapObjectContainerCollection>(); // Grab the last BPM Change to warp distances between copied objects and maintain BPM. var bpmChanges = BeatmapObjectContainerCollection.GetCollectionForType <BPMChangesContainer>(BeatmapObject.Type.BPM_CHANGE); var lowerValue = new BeatmapBPMChange(420, atsc.CurrentBeat - 0.01f); var upperValue = new BeatmapBPMChange(69, atsc.CurrentBeat); var lastBPMChangeBeforePaste = bpmChanges.FindLastBPM(atsc.CurrentBeat, true); // This first loop creates copy of the data to be pasted. foreach (BeatmapObject data in CopiedObjects) { if (data == null) { continue; } upperValue._time = atsc.CurrentBeat + data._time; var bpmChangeView = bpmChanges.LoadedObjects.GetViewBetween(lowerValue, upperValue); float bpmTime = data._time * (copiedBPM / (lastBPMChangeBeforePaste?._BPM ?? copiedBPM)); if (bpmChangeView.Any()) { var firstBPMChange = bpmChangeView.First() as BeatmapBPMChange; bpmTime = firstBPMChange._time - atsc.CurrentBeat; for (var i = 0; i < bpmChangeView.Count - 1; i++) { var leftBPM = bpmChangeView.ElementAt(i) as BeatmapBPMChange; var rightBPM = bpmChangeView.ElementAt(i + 1) as BeatmapBPMChange; bpmTime += (rightBPM._time - leftBPM._time) * (copiedBPM / leftBPM._BPM); } var lastBPMChange = bpmChangeView.Last() as BeatmapBPMChange; bpmTime += (atsc.CurrentBeat + data._time - lastBPMChange._time) * (copiedBPM / lastBPMChange._BPM); } float newTime = bpmTime + atsc.CurrentBeat; BeatmapObject newData = BeatmapObject.GenerateCopy(data); newData._time = newTime; if (!collections.TryGetValue(newData.beatmapType, out BeatmapObjectContainerCollection collection)) { collection = BeatmapObjectContainerCollection.GetCollectionForType(newData.beatmapType); collections.Add(newData.beatmapType, collection); } pasted.Add(newData); } List <BeatmapObject> totalRemoved = new List <BeatmapObject>(); // We remove conflicting objects with our to-be-pasted objects. foreach (var kvp in collections) { kvp.Value.RemoveConflictingObjects(pasted.Where(x => x.beatmapType == kvp.Key), out var conflicting); totalRemoved.AddRange(conflicting); } // While we're at it, we will also overwrite the entire section if we have to. if (overwriteSection) { float start = pasted.First()._time; float end = pasted.First()._time; foreach (BeatmapObject beatmapObject in pasted) { if (start > beatmapObject._time) { start = beatmapObject._time; } if (end < beatmapObject._time) { end = beatmapObject._time; } } GetObjectTypes(pasted, out bool hasNoteOrObstacle, out bool hasEvent, out bool hasBpmChange); List <(BeatmapObjectContainerCollection, BeatmapObject)> toRemove = new List <(BeatmapObjectContainerCollection, BeatmapObject)>(); ForEachObjectBetweenTimeByGroup(start, end, hasNoteOrObstacle, hasEvent, hasBpmChange, (collection, beatmapObject) => { if (pasted.Contains(beatmapObject)) { return; } toRemove.Add((collection, beatmapObject)); }); foreach ((BeatmapObjectContainerCollection, BeatmapObject)pair in toRemove) { BeatmapObjectContainerCollection collection = pair.Item1; BeatmapObject beatmapObject = pair.Item2; collection.DeleteObject(beatmapObject, false); totalRemoved.Add(beatmapObject); } } // We then spawn our pasted objects into the map and select them. foreach (BeatmapObject data in pasted) { collections[data.beatmapType].SpawnObject(data, false, false); Select(data, true, false, false); } foreach (BeatmapObjectContainerCollection collection in collections.Values) { collection.RefreshPool(); if (collection is BPMChangesContainer con) { con.RefreshGridShaders(); } } if (CopiedObjects.Any(x => (x is MapEvent e) && e.IsRotationEvent)) { tracksManager.RefreshTracks(); } if (triggersAction) { BeatmapActionContainer.AddAction(new SelectionPastedAction(pasted, totalRemoved)); } SelectionPastedEvent?.Invoke(pasted); SelectionChangedEvent?.Invoke(); RefreshSelectionMaterial(false); if (eventPlacement.objectContainerCollection.PropagationEditing != EventsContainer.PropMode.Off) { eventPlacement.objectContainerCollection.PropagationEditing = eventPlacement.objectContainerCollection.PropagationEditing; } Debug.Log("Pasted!"); }
public void RefreshRotations() { tracksManager.RefreshTracks(); }