public void OnInitiateClickandDragatTime(InputAction.CallbackContext context) { if (usePrecisionPlacement) { return; } if (context.performed && CanClickAndDrag) { Ray dragRay = mainCamera.ScreenPointToRay(mousePosition); if (Physics.Raycast(dragRay, out RaycastHit dragHit, 999f, 1 << 9)) { BeatmapObjectContainer con = dragHit.transform.gameObject.GetComponentInParent <BeatmapObjectContainer>(); if (StartDrag(con)) { isDraggingObjectAtTime = true; float newZ = (con.objectData._time - atsc.CurrentBeat) * EditorScaleController.EditorScale; noteGridTransform.localPosition = new Vector3(noteGridTransform.localPosition.x, noteGridTransform.localPosition.y, newZ); } } } else if (context.canceled && isDraggingObjectAtTime && instantiatedContainer != null) { noteGridTransform.localPosition = new Vector3(noteGridTransform.localPosition.x, noteGridTransform.localPosition.y, 0); FinishDrag(); } }
/// <summary> /// Pastes any copied objects into the map, selecting them immediately. /// </summary> public void Paste(bool triggersAction = true) { DeselectAll(); CopiedObjects = CopiedObjects.OrderBy((x) => x._time).ToList(); List <BeatmapObjectContainer> pasted = new List <BeatmapObjectContainer>(); foreach (BeatmapObject data in CopiedObjects) { if (data == null) { continue; } float newTime = data._time + atsc.CurrentBeat; BeatmapObject newData = BeatmapObject.GenerateCopy(data); newData._time = newTime; BeatmapObjectContainer pastedContainer = collections.Where(x => x.ContainerType == newData.beatmapType).FirstOrDefault()?.SpawnObject(newData, out _); pasted.Add(pastedContainer); } if (triggersAction) { BeatmapActionContainer.AddAction(new SelectionPastedAction(pasted, CopiedObjects, atsc.CurrentBeat)); } foreach (BeatmapObjectContainer obj in pasted) { Select(obj, true, false); } RefreshSelectionMaterial(false); RefreshMap(); Debug.Log("Pasted!"); }
internal override void ApplyToMap() { if (!IsSelecting) { IsSelecting = true; startTime = (instantiatedContainer.transform.localPosition.z / EditorScaleController.EditorScale) + atsc.offsetBeat; originPos = instantiatedContainer.transform.localPosition; } else { StartCoroutine(WaitABitFuckOffOtherPlacementControllers()); List <BeatmapObjectContainer> toSelect = new List <BeatmapObjectContainer>(); //Big brain boye does big brain things with big brain box BoxCollider boxyBoy = instantiatedContainer.GetComponent <BoxCollider>(); Bounds bounds = new Bounds(); bounds.center = boxyBoy.bounds.center; bounds.size = instantiatedContainer.transform.lossyScale / 2f; Collider[] boxyBoyHitsStuffTM = Physics.OverlapBox(bounds.center, bounds.extents, instantiatedContainer.transform.rotation, 1 << 9); foreach (Collider collider in boxyBoyHitsStuffTM) { BeatmapObjectContainer containerBoye = collider.gameObject.GetComponent <BeatmapObjectContainer>(); if (containerBoye != null && SelectedTypes.Contains(containerBoye.objectData.beatmapType)) { toSelect.Add(containerBoye); } } foreach (BeatmapObjectContainer obj in toSelect) { SelectionController.Select(obj, true, false); } SelectionController.RefreshSelectionMaterial(toSelect.Any()); } }
public void triggerArm(BeatmapNote note, NotesContainer container) { //Ignore bombs here to improve performance. if (!Settings.Instance.BongoBoye || note._type == BeatmapNote.NOTE_TYPE_BOMB) { return; } BeatmapObjectContainer next = container.LoadedContainers.FirstOrDefault(x => x.objectData._time > note._time && ((BeatmapNote)x.objectData)._type == note._type); float timer = 0.125f; if (!(next is null)) { float half = container.AudioTimeSyncController.GetSecondsFromBeat((next.objectData._time - note._time) / 2f); timer = next ? Mathf.Clamp(half, 0.05f, 0.2f) : 0.125f; // clamp to accommodate sliders and long gaps between notes } switch (note._type) { case BeatmapNote.NOTE_TYPE_A: Larm = true; LarmTimeout = timer; break; case BeatmapNote.NOTE_TYPE_B: Rarm = true; RarmTimeout = timer; break; } }
/// <summary> /// Pastes any copied objects into the map, selecting them immediately. /// </summary> public void Paste(bool triggersAction = true) { DeselectAll(); CopiedObjects = new HashSet <BeatmapObject>(CopiedObjects.OrderBy(x => x._time)); HashSet <BeatmapObjectContainer> pasted = new HashSet <BeatmapObjectContainer>(); foreach (BeatmapObject data in CopiedObjects) { if (data == null) { continue; } float newTime = data._time + atsc.CurrentBeat; BeatmapObject newData = BeatmapObject.GenerateCopy(data); newData._time = newTime; BeatmapObjectContainer pastedContainer = collections.Where(x => x.ContainerType == newData.beatmapType).FirstOrDefault()?.SpawnObject(newData, out _); pastedContainer.UpdateGridPosition(); Select(pastedContainer, true, false, false); pasted.Add(pastedContainer); } if (triggersAction) { BeatmapActionContainer.AddAction(new SelectionPastedAction(pasted, CopiedObjects, atsc.CurrentBeat)); } RefreshSelectionMaterial(false); RefreshMap(); tracksManager.RefreshTracks(); if (eventPlacement.objectContainerCollection.RingPropagationEditing) { eventPlacement.objectContainerCollection.RingPropagationEditing = eventPlacement.objectContainerCollection.RingPropagationEditing; } Debug.Log("Pasted!"); }
internal override void ApplyToMap() { if (!IsSelecting) { IsSelecting = true; startTime = RoundedTime; } else { StartCoroutine(WaitABitFuckOffOtherPlacementControllers()); List <BeatmapObjectContainer> toSelect = new List <BeatmapObjectContainer>(); //Big brain boye does big brain things with big brain box BoxCollider boxyBoy = instantiatedContainer.GetComponent <BoxCollider>(); Collider[] boxyBoyHitsStuffTM = Physics.OverlapBox(boxyBoy.bounds.center, boxyBoy.bounds.extents, boxyBoy.transform.rotation, 1 << 9); foreach (Collider collider in boxyBoyHitsStuffTM) { BeatmapObjectContainer containerBoye = collider.gameObject.GetComponent <BeatmapObjectContainer>(); if (containerBoye != null) { toSelect.Add(containerBoye); } } if (!KeybindsController.ShiftHeld) { SelectionController.DeselectAll(); } foreach (BeatmapObjectContainer obj in toSelect) { SelectionController.Select(obj, true, false); } SelectionController.RefreshSelectionMaterial(toSelect.Any()); } }
private void OverlapBox(Action <BeatmapObjectContainer> action) { //Big brain boye does big brain things with big brain box BoxCollider boxyBoy = instantiatedContainer.GetComponent <BoxCollider>(); Bounds bounds = new Bounds(); bounds.center = boxyBoy.bounds.center; Vector3 absoluteLossyScale = new Vector3( Mathf.Abs(instantiatedContainer.transform.lossyScale.x), Mathf.Abs(instantiatedContainer.transform.lossyScale.y), Mathf.Abs(instantiatedContainer.transform.lossyScale.z) ); bounds.size = absoluteLossyScale / 2f; Collider[] boxyBoyHitsStuffTM = Physics.OverlapBox(bounds.center, bounds.size, instantiatedContainer.transform.rotation, 1 << 9); foreach (Collider collider in boxyBoyHitsStuffTM) { BeatmapObjectContainer containerBoye = collider.gameObject.GetComponent <BeatmapObjectContainer>(); if (!SelectedTypes.Contains(containerBoye.objectData.beatmapType)) { continue; } action?.Invoke(containerBoye); } }
/// <summary> /// Deselects a container if it is currently selected /// </summary> /// <param name="container">The container to deselect, if it has been selected.</param> public static void Deselect(BeatmapObjectContainer container) { SelectedObjects.RemoveAll(x => x == null); SelectedObjects.Remove(container); container.OutlineVisible = false; container.OnMouseUp(); }
protected override void UpdateContainerData(BeatmapObjectContainer con, BeatmapObject obj) { BeatmapObstacleContainer obstacle = con as BeatmapObstacleContainer; if (!obstacle.IsRotatedByNoodleExtensions) { Track track = tracksManager.GetTrackAtTime(obj._time); track.AttachContainer(con); } foreach (Material mat in obstacle.ModelMaterials) { mat.SetFloat("_CircleRadius", EditorScaleController.EditorScale * 2); if (!mat.HasProperty("_OutsideAlpha")) { continue; } if (AudioTimeSyncController.IsPlaying) { mat.SetFloat("_OutsideAlpha", 0); } else { mat.SetFloat("_OutsideAlpha", mat.GetFloat("_MainAlpha")); } } obstacleAppearanceSO.SetObstacleAppearance(obstacle); }
public override BeatmapObjectContainer SpawnObject(BeatmapObject obj, out BeatmapObjectContainer conflicting, bool removeConflicting = true, bool refreshMap = true) { UseChunkLoading = false; conflicting = null; if (removeConflicting) { conflicting = LoadedContainers.FirstOrDefault(x => x.objectData._time == obj._time && (obj as MapEvent)._type == (x.objectData as MapEvent)._type && (obj as MapEvent)._customData == (x.objectData as MapEvent)._customData ); if (conflicting != null) { DeleteObject(conflicting, true, $"Conflicted with a newer object at time {obj._time}"); } } BeatmapEventContainer beatmapEvent = BeatmapEventContainer.SpawnEvent(this, obj as MapEvent, ref eventPrefab, ref eventAppearanceSO, ref tracksManager); beatmapEvent.transform.SetParent(GridTransform); beatmapEvent.UpdateGridPosition(); LoadedContainers.Add(beatmapEvent); if (refreshMap) { SelectionController.RefreshMap(); } if (PropagationEditing) { UpdatePropagationMode(); } return(beatmapEvent); }
public override BeatmapObjectContainer SpawnObject(BeatmapObject obj, out BeatmapObjectContainer conflicting, bool removeConflicting = true, bool refreshMap = true) { conflicting = null; if (removeConflicting) { conflicting = LoadedContainers.FirstOrDefault(x => x.objectData._time == obj._time && ((BeatmapObstacle)obj)._lineIndex == ((BeatmapObstacle)x.objectData)._lineIndex && ((BeatmapObstacle)obj)._type == ((BeatmapObstacle)x.objectData)._type && ConflictingByTrackIDs(obj, x.objectData) ); if (conflicting != null) { DeleteObject(conflicting, true, $"Conflicted with a newer object at time {obj._time}"); } } BeatmapObstacleContainer beatmapObstacle = BeatmapObstacleContainer.SpawnObstacle(obj as BeatmapObstacle, AudioTimeSyncController, ref obstaclePrefab, ref obstacleAppearanceSO); beatmapObstacle.transform.SetParent(GridTransform); beatmapObstacle.UpdateGridPosition(); LoadedContainers.Add(beatmapObstacle); if (refreshMap) { SelectionController.RefreshMap(); } return(beatmapObstacle); }
public override BeatmapObjectContainer SpawnObject(BeatmapObject obj, out BeatmapObjectContainer conflicting, bool removeConflicting = true) { UseChunkLoading = false; conflicting = LoadedContainers.FirstOrDefault(x => x.objectData._time == obj._time && (obj as MapEvent)._type == (x.objectData as MapEvent)._type && (obj as MapEvent)._customData == (x.objectData as MapEvent)._customData ); if (conflicting != null && removeConflicting) { DeleteObject(conflicting); } BeatmapEventContainer beatmapEvent = BeatmapEventContainer.SpawnEvent(obj as MapEvent, ref eventPrefab, ref eventAppearanceSO); beatmapEvent.transform.SetParent(GridTransform); beatmapEvent.UpdateGridPosition(); if (RingPropagationEditing && (obj as MapEvent)._type == MapEvent.EVENT_TYPE_RING_LIGHTS) { int pos = 0; if (!(obj._customData is null)) { pos = obj._customData["_propID"].AsInt + 1; } Debug.Log(pos); beatmapEvent.transform.localPosition = new Vector3(pos + 0.5f, 0.5f, beatmapEvent.transform.localPosition.z); } LoadedContainers.Add(beatmapEvent); SelectionController.RefreshMap(); return(beatmapEvent); }
public void ObjectWasSelected(BeatmapObjectContainer container) { if (SelectionController.SelectedObjects.Count > 1 || !AdvancedSetting) { StopAllCoroutines(); StartCoroutine(UpdateGroup(false, transform as RectTransform)); return; } ; StopAllCoroutines(); StartCoroutine(UpdateGroup(true, transform as RectTransform)); if (firstActive) { firstActive = false; PersistentUI.Instance.DisplayMessage("Node Editor is very powerful - Be careful!", PersistentUI.DisplayMessageType.BOTTOM); } editingContainer = container; //Set node to what we are editing. editingNode = container.objectData.ConvertToJSON(); string formattedName = container.objectData.beatmapType.ToString().Substring(0, 1); //Create a formatted string with the first character formattedName += container.objectData.beatmapType.ToString().ToLower().Substring(1); //capitalized, and the rest in lowercase. labelTextMesh.text = "Editing " + formattedName; nodeEditorInputField.text = editingNode.ToString(2); }
private void Update() { /* * While this may be a copy of PlacementController code and BeatmapObjectContainer selecting, this is actually to help * select objects that are under the placement grid (such as walls) */ Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out RaycastHit hit, 999f, 1 << 11)) { if (Physics.Raycast(ray, out _, hit.distance, 1 << 9)) { return; //Do not select under grid if something is already selected. } Ray gridRay = new Ray(hit.point, ray.direction); if (Physics.Raycast(gridRay, out RaycastHit gridHit, 999f, 1 << 9)) { BeatmapObjectContainer con = gridHit.transform.gameObject.GetComponent <BeatmapObjectContainer>(); if (con is null) { return; } //con.OnMouseOver(); } } }
public override BeatmapObjectContainer SpawnObject(BeatmapObject obj, out BeatmapObjectContainer conflicting, bool removeConflicting = true, bool refreshMap = true) { conflicting = null; if (removeConflicting) { conflicting = LoadedContainers.FirstOrDefault(x => x.objectData._time == obj._time && ((BeatmapNote)obj)._lineLayer == ((BeatmapNote)x.objectData)._lineLayer && ((BeatmapNote)obj)._lineIndex == ((BeatmapNote)x.objectData)._lineIndex && ((BeatmapNote)obj)._type == ((BeatmapNote)x.objectData)._type && ConflictingByTrackIDs(obj, x.objectData) ); if (conflicting != null) { DeleteObject(conflicting, true, $"Conflicted with a newer object at time {obj._time}"); } } BeatmapNoteContainer beatmapNote = BeatmapNoteContainer.SpawnBeatmapNote(obj as BeatmapNote, ref notePrefab, ref bombPrefab, ref noteAppearanceSO); beatmapNote.transform.SetParent(GridTransform); beatmapNote.UpdateGridPosition(); LoadedContainers.Add(beatmapNote); if (Settings.Instance.HighlightLastPlacedNotes) { beatmapNote.SetOutlineColor(Color.magenta); } if (refreshMap) { SelectionController.RefreshMap(); } return(beatmapNote); }
public void triggerArm(BeatmapNote note, NotesContainer container) { if (!Settings.Instance.BongoBoye) { return; } BeatmapObjectContainer next = container.LoadedContainers.Where(x => x.objectData._time > note._time && (x.objectData as BeatmapNote)._type == note._type).OrderBy(x => x.objectData._time).FirstOrDefault(); if (next is null) { return; } float half = note._type != BeatmapNote.NOTE_TYPE_BOMB ? container.AudioTimeSyncController.GetSecondsFromBeat((next.objectData._time - note._time) / 2f) : 0f; // ignore bombs float timer = next ? Mathf.Clamp(half, 0.05f, 0.2f) : 0.125f; // clamp to accommodate sliders and long gaps between notes switch (note._type) { case BeatmapNote.NOTE_TYPE_A: Larm = true; LarmTimeout = timer; break; case BeatmapNote.NOTE_TYPE_B: Rarm = true; RarmTimeout = timer; break; } }
void ObjectSelected(BeatmapObjectContainer container) { if (!KeybindsController.CtrlHeld || Settings.Instance.BoxSelect) { return; //Only do mass selection on ctrl } if (SelectionController.SelectedObjects.Count() < 2 && !KeybindsController.AltHeld) { return; } if (KeybindsController.AltHeld && KeybindsController.ShiftHeld) { return; } List <BeatmapObjectContainer> containers = new List <BeatmapObjectContainer>(SelectionController.SelectedObjects); List <BeatmapEventContainer> events = containers.Where(x => x is BeatmapEventContainer).Cast <BeatmapEventContainer>().ToList(); //Filter containers List <BeatmapNoteContainer> notes = containers.Where(x => x is BeatmapNoteContainer).Cast <BeatmapNoteContainer>().ToList(); Debug.Log("MASS SELECT TIME"); if (events.Count > 0) { events = events.OrderBy(x => x.eventData._type).ThenByDescending(x => x.objectData._time).ToList(); for (var i = 0; i < 15; i++) { List <BeatmapEventContainer> eventsAtType = events.Where(x => x.eventData._type == i).ToList(); if (eventsAtType.Count >= 2) { List <BeatmapObjectContainer> inBetween = eventsContainer.LoadedContainers.Where(x => x.objectData._time >= eventsAtType.Last().objectData._time&& x.objectData._time <= eventsAtType.First().objectData._time&& (x.objectData as MapEvent)._type == i).ToList(); foreach (BeatmapObjectContainer con in inBetween) { SelectionController.Select(con, true, false); } } } } if (notes.Count > 0) { notes = notes.OrderBy(x => x.mapNoteData._lineIndex).ThenByDescending(x => x.objectData._time).ToList(); for (var i = notes.First().mapNoteData._lineIndex; i <= notes.Last().mapNoteData._lineIndex; i++) { List <BeatmapNoteContainer> notesAtIndex = notes.Where(x => x.mapNoteData._lineIndex == i).ToList(); if (notesAtIndex.Count >= 2) { List <BeatmapObjectContainer> inBetween = notesContainer.LoadedContainers.Where(x => x.objectData._time >= notesAtIndex.Last().objectData._time&& x.objectData._time <= notesAtIndex.First().objectData._time&& ((BeatmapNote)x.objectData)._lineIndex == i).ToList(); foreach (BeatmapObjectContainer con in inBetween) { SelectionController.Select(con, true, false); } } } } SelectionController.RefreshSelectionMaterial(); }
private void FlaggedForDeletion(BeatmapObjectContainer obj, bool _, string __) { //Refresh the tracks if we delete any rotation event if (obj is BeatmapEventContainer e && e.eventData.IsRotationEvent) { StartCoroutine(WaitThenRefreshTracks()); } }
public void DeleteObject(BeatmapObjectContainer obj) { if (LoadedContainers.Contains(obj)) { LoadedContainers.Remove(obj); Destroy(obj.gameObject); SelectionController.RefreshMap(); } }
public BeatmapAction(BeatmapObjectContainer obj) { if (obj == null) { return; } data = obj.objectData; container = obj; }
//We don't need to check index as that's already done further up the chain void DespawnCallback(bool initial, int index, BeatmapObject objectData) { try //"Index was out of range. Must be non-negative and less than the size of the collection." Huh? { BeatmapObjectContainer e = LoadedContainers[index]; e.SafeSetActive(false); } catch { } }
void SpawnCallback(bool initial, int index, BeatmapObject objectData) { try { BeatmapObjectContainer e = LoadedContainers[index]; e.SafeSetActive(true); } catch { } }
//We don't need to check index as that's already done further up the chain void SpawnCallback(bool initial, int index, BeatmapObject objectData) { BeatmapObjectContainer e = LoadedContainers[index]; if (e.PreviousActiveState != true) { e.gameObject.SetActive(true); e.SafeSetActive(true); } }
public override void Undo(BeatmapActionContainer.BeatmapActionParams param) { foreach (BeatmapObject data in deletedData) { BeatmapObject copy = BeatmapObject.GenerateCopy(data); BeatmapObjectContainer recovered = param.collections.Where(x => x.ContainerType == copy.beatmapType).FirstOrDefault()?.SpawnObject(copy, out _); SelectionController.Select(recovered, true, false); } SelectionController.RefreshSelectionMaterial(false); }
private void CreateNewObject() { BeatmapObjectContainer baseContainer = CreateContainer(); baseContainer.gameObject.SetActive(false); baseContainer.Setup(); //baseContainer.transform.SetParent(PoolTransform); baseContainer.transform.SetParent(GridTransform); PooledContainers.Enqueue(baseContainer); }
public void AttachContainer(BeatmapObjectContainer obj) { UpdateMaterialRotation(obj); if (obj.transform.parent == ObjectParentTransform) { return; } obj.transform.SetParent(ObjectParentTransform, false); obj.AssignTrack(this); }
public override void Undo(BeatmapActionContainer.BeatmapActionParams param) { foreach (BeatmapObject data in deletedData) { BeatmapObject copy = BeatmapObject.GenerateCopy(data); BeatmapObjectContainer recovered = BeatmapObjectContainerCollection.GetCollectionForType(copy.beatmapType)?.SpawnObject(copy); SelectionController.Select(recovered, true, false); } SelectionController.RefreshSelectionMaterial(false); param.tracksManager.RefreshTracks(); }
public override BeatmapObjectContainer SpawnObject(BeatmapObject obj, out BeatmapObjectContainer conflicting, bool removeConflicting = true) { conflicting = null; BeatmapBPMChangeContainer beatmapBPMChange = BeatmapBPMChangeContainer.SpawnBPMChange(obj as BeatmapBPMChange, ref bpmPrefab); beatmapBPMChange.transform.SetParent(GridTransform); beatmapBPMChange.UpdateGridPosition(); LoadedContainers.Add(beatmapBPMChange); SelectionController.RefreshMap(); return(beatmapBPMChange); }
public void UpdateMaterialRotation(BeatmapObjectContainer obj) { if (obj is BeatmapObstacleContainer || obj is BeatmapNoteContainer) { foreach (Material mat in obj.ModelMaterials) { if (mat.HasProperty("_Rotation")) { mat.SetFloat("_Rotation", RotationValue.y); } } } }
public void DeleteObject(BeatmapObjectContainer obj, bool triggersAction = true, string comment = "No comment.") { if (LoadedContainers.Contains(obj)) { if (triggersAction) { BeatmapActionContainer.AddAction(new BeatmapObjectDeletionAction(obj, comment)); } LoadedContainers.Remove(obj); Destroy(obj.gameObject); SelectionController.RefreshMap(); } }