Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.06 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. using Ched.Core.Notes;
  8.  
  9. namespace Ched.Plugins
  10. {
  11. public class ScoreSplitter : IScorePlugin
  12. {
  13. public string DisplayName => "割るぜぇ~超割るぜぇ~";
  14.  
  15. public void Run(IScorePluginArgs args)
  16. {
  17. var score = args.GetCurrentScore();
  18. var airDic = score.Notes.Airs.ToDictionary(p => p.ParentNote, p => p);
  19. var airActionDic = score.Notes.AirActions.ToDictionary(p => p.ParentNote, p => p);
  20. Action<IAirable, IAirable> duplicateAir = (orig, dup) =>
  21. {
  22. if (airDic.ContainsKey(orig))
  23. {
  24. var air = new Air(dup)
  25. {
  26. VerticalDirection = airDic[orig].VerticalDirection,
  27. HorizontalDirection = airDic[orig].HorizontalDirection
  28. };
  29. score.Notes.Airs.Add(air);
  30. }
  31. if (airActionDic.ContainsKey(orig))
  32. {
  33. var airAction = new AirAction(dup);
  34. airAction.ActionNotes.AddRange(airActionDic[orig].ActionNotes.Select(p => new AirAction.ActionNote(airAction) { Offset = p.Offset }));
  35. score.Notes.AirActions.Add(airAction);
  36. }
  37. };
  38.  
  39. foreach (var tap in score.Notes.Taps.ToList())
  40. {
  41. foreach (var sp in Enumerable.Range(1, tap.Width - 1).Select(p => new Tap() { Tick = tap.Tick, LaneIndex = tap.LaneIndex + p, Width = 1 }))
  42. {
  43. score.Notes.Taps.Add(sp);
  44. duplicateAir(tap, sp);
  45. }
  46. tap.Width = 1;
  47. }
  48.  
  49. foreach (var tap in score.Notes.ExTaps.ToList())
  50. {
  51. foreach (var sp in Enumerable.Range(1, tap.Width - 1).Select(p => new ExTap() { Tick = tap.Tick, LaneIndex = tap.LaneIndex + p, Width = 1 }))
  52. {
  53. score.Notes.ExTaps.Add(sp);
  54. duplicateAir(tap, sp);
  55. }
  56. tap.Width = 1;
  57. }
  58.  
  59. foreach (var flick in score.Notes.Flicks.Where(p => p.Width >= 2).ToList())
  60. {
  61. foreach (var sp in Enumerable.Range(1, flick.Width / 2 - 1).Select(p => new Flick() { Tick = flick.Tick, LaneIndex = flick.LaneIndex + 2 * p, Width = 2 }))
  62. {
  63. score.Notes.Flicks.Add(sp);
  64. duplicateAir(flick, sp);
  65. }
  66. flick.Width = 2;
  67. }
  68.  
  69. foreach (var hold in score.Notes.Holds.ToList())
  70. {
  71. foreach (var sp in Enumerable.Range(1, hold.Width - 1).Select(p => new Hold() { StartTick = hold.StartTick, Duration = hold.Duration, LaneIndex = hold.LaneIndex + p, Width = 1 }))
  72. {
  73. score.Notes.Holds.Add(sp);
  74. duplicateAir(hold.EndNote, sp.EndNote);
  75. }
  76. hold.Width = 1;
  77. }
  78.  
  79. foreach (var slide in score.Notes.Slides.Where(p => p.StepNotes.All(q => q.WidthChange == 0)).ToList())
  80. {
  81. var slides = Enumerable.Range(1, slide.StartWidth - 1)
  82. .Select(p =>
  83. {
  84. var s = new Slide() { StartTick = slide.StartTick, StartLaneIndex = slide.StartLaneIndex + p, StartWidth = 1 };
  85. s.StepNotes.AddRange(slide.StepNotes.OrderBy(q => q.TickOffset).Select(q => new Slide.StepTap(s) { IsVisible = q.IsVisible, TickOffset = q.TickOffset, LaneIndexOffset = q.LaneIndexOffset }));
  86. return s;
  87. });
  88. foreach (var sp in slides)
  89. {
  90. score.Notes.Slides.Add(sp);
  91. duplicateAir(slide.StepNotes.OrderByDescending(p => p.TickOffset).First(), sp.StepNotes[sp.StepNotes.Count - 1]);
  92. }
  93. slide.StartWidth = 1;
  94. }
  95.  
  96. args.UpdateScore(score);
  97. }
  98. }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement