public void MirrorWallNE() { var container = BeatmapObjectContainerCollection.GetCollectionForType(BeatmapObject.Type.OBSTACLE); if (container is ObstaclesContainer wallsContainer) { var root = wallsContainer.transform.root; var wallPlacement = root.GetComponentInChildren <ObstaclePlacement>(); wallPlacement.RefreshVisuals(); var wallA = new BeatmapObstacle(2, BeatmapNote.LINE_INDEX_FAR_LEFT, BeatmapObstacle.VALUE_FULL_BARRIER, 1, 2, JSON.Parse("{\"_position\": [-1.5, 0]}")); wallPlacement.queuedData = wallA; wallPlacement.RoundedTime = wallPlacement.queuedData._time; wallPlacement.instantiatedContainer.transform.localScale = new Vector3(0, 0, wallPlacement.queuedData._duration * EditorScaleController.EditorScale); wallPlacement.ApplyToMap(); // Starts placement wallPlacement.ApplyToMap(); // Completes placement SelectionController.Select(wallA); _mirror.Mirror(); WallTest.CheckWall(wallsContainer, 0, 2, BeatmapNote.LINE_INDEX_MID_RIGHT, BeatmapObstacle.VALUE_FULL_BARRIER, 1, 2, JSON.Parse("{\"_position\": [-0.5, 0]}")); // Undo mirror _actionContainer.Undo(); WallTest.CheckWall(wallsContainer, 0, 2, BeatmapNote.LINE_INDEX_FAR_LEFT, BeatmapObstacle.VALUE_FULL_BARRIER, 1, 2, JSON.Parse("{\"_position\": [-1.5, 0]}")); } }
/// <summary> /// Copies the current selection for later Pasting. /// </summary> /// <param name="cut">Whether or not to delete the original selection after copying them.</param> public void Copy(bool cut = false) { Debug.Log("Copied!"); CopiedObjects.Clear(); SelectedObjects = SelectedObjects.OrderBy(x => x.objectData._time).ToList(); float firstTime = SelectedObjects.First().objectData._time; foreach (BeatmapObjectContainer con in SelectedObjects) { BeatmapObject data = null; if (con.objectData is BeatmapNote) { data = new BeatmapNote(con.objectData.ConvertToJSON()); } if (con.objectData is BeatmapObstacle) { data = new BeatmapObstacle(con.objectData.ConvertToJSON()); } if (con.objectData is MapEvent) { data = new MapEvent(con.objectData.ConvertToJSON()); } data._time = con.objectData._time - firstTime; CopiedObjects.Add(data); List <Material> containerMaterials = con.gameObject.GetComponentInChildren <MeshRenderer>().materials.ToList(); containerMaterials.Last().SetColor("_OutlineColor", instance.copiedColor); } if (cut) { Delete(); } }
public void MirrorWallME() { var container = BeatmapObjectContainerCollection.GetCollectionForType(BeatmapObject.Type.OBSTACLE); if (container is ObstaclesContainer wallsContainer) { var root = wallsContainer.transform.root; var wallPlacement = root.GetComponentInChildren <ObstaclePlacement>(); wallPlacement.RefreshVisuals(); // What the actual f**k - example from mirroring in MMA2 //{"_time":1.5,"_lineIndex":1446,"_type":595141,"_duration":0.051851850003004074,"_width":2596} //{"_time":1.5,"_lineIndex":2958,"_type":595141,"_duration":0.051851850003004074,"_width":2596} var wallA = new BeatmapObstacle(2, 1446, 595141, 1, 2596); wallPlacement.queuedData = wallA; wallPlacement.RoundedTime = wallPlacement.queuedData._time; wallPlacement.instantiatedContainer.transform.localScale = new Vector3(0, 0, wallPlacement.queuedData._duration * EditorScaleController.EditorScale); wallPlacement.ApplyToMap(); // Starts placement wallPlacement.ApplyToMap(); // Completes placement SelectionController.Select(wallA); _mirror.Mirror(); WallTest.CheckWall(wallsContainer, 0, 2, 2958, 595141, 1, 2596); // Undo mirror _actionContainer.Undo(); WallTest.CheckWall(wallsContainer, 0, 2, 1446, 595141, 1, 2596); } }
public static BeatmapObstacleContainer SpawnObstacle(BeatmapObstacle data, AudioTimeSyncController atsc, ref GameObject prefab, ref ObstacleAppearanceSO appearanceSO) { BeatmapObstacleContainer container = Instantiate(prefab).GetComponent <BeatmapObstacleContainer>(); container.obstacleData = data; container.obstacleAppearance = appearanceSO; container.atsc = atsc; appearanceSO.SetObstacleAppearance(container); return(container); }
/// <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; BeatmapObjectContainer pastedContainer = null; if (data is BeatmapNote) { BeatmapObject newData = new BeatmapNote(data.ConvertToJSON()); newData._time = newTime; NotesContainer notes = collections.Where(x => x is NotesContainer).FirstOrDefault() as NotesContainer; pastedContainer = notes?.SpawnObject(newData); } if (data is BeatmapObstacle) { BeatmapObject newData = new BeatmapObstacle(data.ConvertToJSON()); newData._time = newTime; ObstaclesContainer obstacles = collections.Where(x => x is ObstaclesContainer).FirstOrDefault() as ObstaclesContainer; pastedContainer = obstacles?.SpawnObject(newData); } if (data is MapEvent) { BeatmapObject newData = new MapEvent(data.ConvertToJSON()); newData._time = newTime; EventsContainer events = collections.Where(x => x is EventsContainer).FirstOrDefault() as EventsContainer; pastedContainer = events?.SpawnObject(newData); } pasted.Add(pastedContainer); } if (triggersAction) { BeatmapActionContainer.AddAction(new SelectionPastedAction(pasted, CopiedObjects, atsc.CurrentBeat)); } SelectedObjects.AddRange(pasted); RefreshSelectionMaterial(false); RefreshMap(); Debug.Log("Pasted!"); }
public override void SortObjects() { obstacleRenderer = GridTransform.GetComponentsInChildren <Renderer>(); LoadedContainers = LoadedContainers.OrderBy(x => x.objectData._time).ToList(); uint id = 0; for (int i = 0; i < LoadedContainers.Count; i++) { if (LoadedContainers[i].objectData is BeatmapObstacle) { BeatmapObstacle noteData = (BeatmapObstacle)LoadedContainers[i].objectData; noteData.id = id; LoadedContainers[i].gameObject.name = "Obstacle " + id; id++; } } UseChunkLoading = true; }
public void HyperWall() { var actionContainer = Object.FindObjectOfType <BeatmapActionContainer>(); var collection = BeatmapObjectContainerCollection.GetCollectionForType(BeatmapObject.Type.OBSTACLE); if (collection is ObstaclesContainer obstaclesCollection) { var root = obstaclesCollection.transform.root; var wallPlacement = root.GetComponentInChildren <ObstaclePlacement>(); var inputController = root.GetComponentInChildren <BeatmapObstacleInputController>(); wallPlacement.RefreshVisuals(); var wallA = new BeatmapObstacle(2, BeatmapNote.LINE_INDEX_FAR_LEFT, BeatmapObstacle.VALUE_FULL_BARRIER, 2, 1); wallPlacement.queuedData = wallA; wallPlacement.RoundedTime = wallPlacement.queuedData._time; wallPlacement.instantiatedContainer.transform.localScale = new Vector3(0, 0, wallPlacement.queuedData._duration * EditorScaleController.EditorScale); wallPlacement.ApplyToMap(); // Starts placement wallPlacement.ApplyToMap(); // Completes placement if (obstaclesCollection.LoadedContainers[wallA] is BeatmapObstacleContainer container) { inputController.ToggleHyperWall(container); } var toDelete = obstaclesCollection.LoadedObjects.First(); obstaclesCollection.DeleteObject(toDelete); Assert.AreEqual(0, obstaclesCollection.LoadedObjects.Count); actionContainer.Undo(); Assert.AreEqual(1, obstaclesCollection.LoadedObjects.Count); CheckWall(obstaclesCollection, 0, 4, BeatmapNote.LINE_INDEX_FAR_LEFT, BeatmapObstacle.VALUE_FULL_BARRIER, -2, 1); actionContainer.Undo(); CheckWall(obstaclesCollection, 0, 2, BeatmapNote.LINE_INDEX_FAR_LEFT, BeatmapObstacle.VALUE_FULL_BARRIER, 2, 1); } }
public static T GenerateCopy <T>(T originalData) where T : BeatmapObject { T objectData = null; switch (originalData.beatmapType) { case Type.NOTE: objectData = new BeatmapNote(originalData.ConvertToJSON()) as T; break; case Type.BOMB: objectData = new BeatmapNote(originalData.ConvertToJSON()) as T; break; case Type.CUSTOM_NOTE: objectData = new BeatmapNote(originalData.ConvertToJSON()) as T; break; case Type.OBSTACLE: objectData = new BeatmapObstacle(originalData.ConvertToJSON()) as T; break; case Type.EVENT: objectData = new MapEvent(originalData.ConvertToJSON()) as T; break; case Type.CUSTOM_EVENT: objectData = new MapEvent(originalData.ConvertToJSON()) as T; break; } //The JSONObject somehow stays behind even after this, so we're going to have to parse a new one from the original if (originalData._customData != null) { objectData._customData = JSON.Parse(originalData._customData.ToString()); } return(objectData); }