public BeatMap GenerateBeatMapEvents(string jsonFileName) { // Load the beatmap data from the JSON file BeatMap beatMap = LoadBeatMap(jsonFileName); if (beatMap == null) { return(null); } // Perform magic to generate beatmap events List <BeatMapEvent> beatMapEvents = GenerateBeatMapEvents(beatMap); beatMap.Events = beatMapEvents.ToArray(); // Do some filename wrangling long epoch = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; string folderName = Path.GetDirectoryName(jsonFileName); string baseName = Path.GetFileNameWithoutExtension(jsonFileName); string extension = Path.GetExtension(jsonFileName); string backupFileName = Path.Combine(folderName, baseName + "_" + epoch + extension); // Backup the old file and write the updated beatmap to the original filename File.Move(jsonFileName, backupFileName); string json = JsonConvert.SerializeObject(beatMap, Formatting.Indented); File.WriteAllText(jsonFileName, json); return(beatMap); }
private void CreateBigLights(BeatMap beatMap, List <BeatMapEvent> outputEvents) { double songLength = beatMap.Notes.Max(note => note.Time); double?marker = FindMarker(beatMap.Events); if (!marker.HasValue) { return; } bool flipFlop = true; for (double songIndex = marker.Value; songIndex <= songLength; songIndex += settings.spawnSpeed) { if (songLength - songIndex < settings.spawnSpeed) { // End of song, fade out lights if (flipFlop) { outputEvents.Add(new BeatMapEvent(songIndex, 1, 7)); } else { outputEvents.Add(new BeatMapEvent(songIndex, 1, 3)); } } else { if (flipFlop) { outputEvents.Add(new BeatMapEvent(songIndex, 1, 5)); if (settings.bigLightFade && songIndex >= 1) { outputEvents.Add(new BeatMapEvent(songIndex - 2, 1, 3)); } } else { outputEvents.Add(new BeatMapEvent(songIndex, 1, 1)); if (settings.bigLightFade && songIndex >= 1) { outputEvents.Add(new BeatMapEvent(songIndex - 2, 1, 7)); } } } flipFlop = !flipFlop; //if (settings.ringSpins) // outputEvents.Add(new BeatMapEvent(songIndex, 8, 0)); } }
private void ConvertNotes(BeatMap beatMap, List <BeatMapEvent> outputEvents) { var notes = beatMap.Notes; if (settings.noteConvertPrecise) { notes = FilterPreciseNotes(beatMap.Notes); } foreach (var note in notes) { var tuple = CreateEvent(note.CutDirection, note.LineIndex); outputEvents.Add(new BeatMapEvent(note.Time, tuple.Item1, tuple.Item2)); } }
private void CreateRingSpins(BeatMap beatMap, List <BeatMapEvent> outputEvents) { double songLength = beatMap.Notes.Max(note => note.Time); double?marker = FindMarker(beatMap.Events); if (!marker.HasValue) { return; } for (double songIndex = marker.Value; songIndex <= songLength; songIndex += settings.spawnSpeed) { outputEvents.Add(new BeatMapEvent(songIndex, 8, 0)); } }
public List <BeatMapEvent> GenerateBeatMapEvents(BeatMap beatMap) { List <BeatMapEvent> beatMapEvents = new List <BeatMapEvent>(); if (settings.bigLights) { CreateBigLights(beatMap, beatMapEvents); } if (settings.ringSpins) { CreateRingSpins(beatMap, beatMapEvents); } if (settings.noteConvert) { ConvertNotes(beatMap, beatMapEvents); } SetLaserSpeed(beatMapEvents); return(beatMapEvents); }