/// <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!"); }
public void UpdateAppearance(BeatmapObjectContainer obj) { if (obj is BeatmapNoteContainer note) { note.Directionalize(note.mapNoteData._cutDirection); noteAppearance.SetNoteAppearance(note); } else if (obj is BeatmapEventContainer e) { eventAppearance.SetEventAppearance(e); } else if (obj is BeatmapObstacleContainer o) { obstacleAppearance.SetObstacleAppearance(o); } obj.UpdateGridPosition(); SelectionController.RefreshMap(); }
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(); }
/// <summary> /// Dequeues a container from the pool and attaches it to a provided <see cref="BeatmapObject"/> /// </summary> /// <param name="obj">Object to store within the container.</param> protected void CreateContainerFromPool(BeatmapObject obj) { if (obj.HasAttachedContainer) { return; } //Debug.Log($"Creating container with hash code {obj.GetHashCode()}"); if (!PooledContainers.Any()) { CreateNewObject(); } BeatmapObjectContainer dequeued = PooledContainers.Dequeue(); dequeued.objectData = obj; dequeued.transform.localEulerAngles = Vector3.zero; dequeued.UpdateGridPosition(); dequeued.SafeSetActive(true); UpdateContainerData(dequeued, obj); dequeued.OutlineVisible = SelectionController.IsObjectSelected(obj); PluginLoader.BroadcastEvent <ObjectLoadedAttribute, BeatmapObjectContainer>(dequeued); LoadedContainers.Add(obj, dequeued); obj.HasAttachedContainer = true; OnContainerSpawn(dequeued, obj); }