forked from zeph-yr/Chirality
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MirrorTransforms_Pre120.cs
292 lines (226 loc) · 12.1 KB
/
MirrorTransforms_Pre120.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
// BS <=1.19.1
using System.Collections.Generic;
namespace Chirality
{
class MirrorTransforms
{
internal static System.Random rand;
internal static List<NoteCutDirection> directions = new List<NoteCutDirection> {NoteCutDirection.Up, NoteCutDirection.Down, NoteCutDirection.Left , NoteCutDirection.Right,
NoteCutDirection.UpLeft, NoteCutDirection.UpRight, NoteCutDirection.DownLeft, NoteCutDirection.DownRight,
NoteCutDirection.Any, NoteCutDirection.None};
internal static Dictionary<NoteCutDirection, NoteCutDirection> horizontal_cut_transform;
internal static Dictionary<NoteCutDirection, NoteCutDirection> vertical_cut_transform;
internal static BeatmapData Mirror_Horizontal(BeatmapData beatmapData, bool flip_lines, bool remove_walls, bool is_ME)
{
//Plugin.Log.Debug("Mirror Horizontal");
int numberOfLines = beatmapData.numberOfLines;
BeatmapData h_beatmapData = new BeatmapData(numberOfLines);
foreach (BeatmapObjectData beatmapObjectData in beatmapData.beatmapObjectsData)
{
NoteData noteData;
if ((noteData = (beatmapObjectData as NoteData)) != null)
{
h_beatmapData.AddBeatmapObjectData(Mirror_Horizontal_Note(noteData, numberOfLines, flip_lines, is_ME));
}
if (remove_walls == false)
{
ObstacleData obstacleData;
if ((obstacleData = (beatmapObjectData as ObstacleData)) != null)
{
h_beatmapData.AddBeatmapObjectData(Mirror_Horizontal_Obstacle(obstacleData, numberOfLines, flip_lines));
}
}
}
foreach (BeatmapEventData beatmapEventData in beatmapData.beatmapEventsData)
{
h_beatmapData.AddBeatmapEventData(beatmapEventData);
}
foreach (KeyValuePair<string, HashSet<BeatmapEventType>> keyValuePair in beatmapData.availableSpecialEventsPerKeywordDictionary)
{
h_beatmapData.AddAvailableSpecialEventsPerKeyword(keyValuePair.Key, keyValuePair.Value);
}
return h_beatmapData;
}
internal static BeatmapData Mirror_Vertical(BeatmapData beatmapData, bool flip_rows, bool remove_walls, bool is_ME)
{
//Plugin.Log.Debug("Mirror Vertical");
int numberOfLines = beatmapData.numberOfLines;
BeatmapData v_beatmapData = new BeatmapData(numberOfLines);
foreach (BeatmapObjectData beatmapObjectData in beatmapData.beatmapObjectsData)
{
NoteData noteData;
if ((noteData = (beatmapObjectData as NoteData)) != null)
{
v_beatmapData.AddBeatmapObjectData(Mirror_Vertical_Note(noteData, flip_rows, is_ME));
}
if (remove_walls == false)
{
ObstacleData obstacleData;
if ((obstacleData = (beatmapObjectData as ObstacleData)) != null)
{
v_beatmapData.AddBeatmapObjectData(Mirror_Vertical_Obstacle(obstacleData, flip_rows));
}
}
}
foreach (BeatmapEventData beatmapEventData in beatmapData.beatmapEventsData)
{
v_beatmapData.AddBeatmapEventData(beatmapEventData);
}
foreach (KeyValuePair<string, HashSet<BeatmapEventType>> keyValuePair in beatmapData.availableSpecialEventsPerKeywordDictionary)
{
v_beatmapData.AddAvailableSpecialEventsPerKeyword(keyValuePair.Key, keyValuePair.Value);
}
return v_beatmapData;
}
internal static BeatmapData Mirror_Inverse(BeatmapData beatmapData, bool flip_lines, bool flip_rows, bool remove_walls, bool is_ME)
{
//Plugin.Log.Debug("Mirror Inverse");
return Mirror_Vertical(Mirror_Horizontal(beatmapData, flip_lines, remove_walls, is_ME), flip_rows, remove_walls, is_ME);
}
internal static NoteCutDirection Get_Random_Direction()
{
int index = rand.Next(directions.Count);
return directions[index];
}
#region "Horizontal Transform Functions"
internal static void Create_Horizontal_Transforms()
{
Plugin.Log.Debug("Create Horizontal Transforms");
horizontal_cut_transform = new Dictionary<NoteCutDirection, NoteCutDirection>();
horizontal_cut_transform.Add(NoteCutDirection.Up, NoteCutDirection.Up);
horizontal_cut_transform.Add(NoteCutDirection.Down, NoteCutDirection.Down);
horizontal_cut_transform.Add(NoteCutDirection.UpLeft, NoteCutDirection.UpRight);
horizontal_cut_transform.Add(NoteCutDirection.DownLeft, NoteCutDirection.DownRight);
horizontal_cut_transform.Add(NoteCutDirection.UpRight, NoteCutDirection.UpLeft);
horizontal_cut_transform.Add(NoteCutDirection.DownRight, NoteCutDirection.DownLeft);
horizontal_cut_transform.Add(NoteCutDirection.Left, NoteCutDirection.Right);
horizontal_cut_transform.Add(NoteCutDirection.Right, NoteCutDirection.Left);
horizontal_cut_transform.Add(NoteCutDirection.Any, NoteCutDirection.Any);
horizontal_cut_transform.Add(NoteCutDirection.None, NoteCutDirection.None);
}
private static NoteData Mirror_Horizontal_Note(NoteData noteData, int numberOfLines, bool flip_lines, bool is_ME)
{
int h_lineIndex;
ColorType color = noteData.colorType.Opposite();
// Precision maps will not have indexes flipped (complicated math) but their colors will
// Yes, it will be weird like streams will zigzag in the wrong direction...hence introducing chaos mode. Might as well make use of the weirdness!
// Other option is to just not support ME and NE maps
// Also Note: Not worth reusing check function because non-extended map block will become unnecessarily complicated
if (noteData.lineIndex >= 1000 || noteData.lineIndex <= -1000)
{
h_lineIndex = noteData.lineIndex / 1000 - 1; // Definition from ME
}
// Keep This Note: This isn't a robust way to check for extended maps
/*if (noteData.lineIndex > 10 || noteData.lineIndex < 0)
{
h_lineIndex = rand.Next(4); // ME chaos mode kekeke turns out this is too chaotic, not that fun
}*/
// Only non-precision-placement maps can have the option to be index flipped
// Maps with extended non-precision-placement indexes are handled properly by numberOfLines
else if (flip_lines)
{
h_lineIndex = numberOfLines - 1 - noteData.lineIndex;
}
else
{
h_lineIndex = noteData.lineIndex;
color = noteData.colorType;
}
NoteCutDirection h_cutDirection; // Yes, this is support for precision placement and ME LOL
if (horizontal_cut_transform.TryGetValue(noteData.cutDirection, out h_cutDirection) == false || is_ME)
{
h_cutDirection = Get_Random_Direction();
}
NoteData h_noteData = NoteData.CreateBasicNoteData(noteData.time, h_lineIndex, Check_Layer(noteData.noteLineLayer), color, h_cutDirection);
return h_noteData;
}
private static ObstacleData Mirror_Horizontal_Obstacle(ObstacleData obstacleData, int numberOfLines, bool flip_lines)
{
ObstacleData h_obstacleData;
if (flip_lines && obstacleData.obstacleType == ObstacleType.FullHeight)
{
h_obstacleData = new ObstacleData(obstacleData.time, numberOfLines - obstacleData.width - obstacleData.lineIndex, ObstacleType.FullHeight, obstacleData.duration, obstacleData.width);
return h_obstacleData;
}
return obstacleData;
}
#endregion
#region "Vertical Transform Functions"
internal static void Create_Vertical_Transforms()
{
Plugin.Log.Debug("Create Vertical Transforms");
vertical_cut_transform = new Dictionary<NoteCutDirection, NoteCutDirection>();
vertical_cut_transform.Add(NoteCutDirection.Up, NoteCutDirection.Down);
vertical_cut_transform.Add(NoteCutDirection.Down, NoteCutDirection.Up);
vertical_cut_transform.Add(NoteCutDirection.UpLeft, NoteCutDirection.DownLeft);
vertical_cut_transform.Add(NoteCutDirection.DownLeft, NoteCutDirection.UpLeft);
vertical_cut_transform.Add(NoteCutDirection.UpRight, NoteCutDirection.DownRight);
vertical_cut_transform.Add(NoteCutDirection.DownRight, NoteCutDirection.UpRight);
vertical_cut_transform.Add(NoteCutDirection.Left, NoteCutDirection.Left);
vertical_cut_transform.Add(NoteCutDirection.Right, NoteCutDirection.Right);
vertical_cut_transform.Add(NoteCutDirection.Any, NoteCutDirection.Any);
vertical_cut_transform.Add(NoteCutDirection.None, NoteCutDirection.None);
}
private static NoteData Mirror_Vertical_Note(NoteData noteData, bool flip_rows, bool has_ME)
{
NoteLineLayer v_noteLineLayer;
// All precision placements will not be layer-flipped (complicated math)
// This could be weird, consider it part of chaos mode KEK
if ((int)noteData.noteLineLayer >= 1000 || (int)noteData.noteLineLayer <= -1000)
{
v_noteLineLayer = (NoteLineLayer)((int)noteData.noteLineLayer / 1000) - 1; // Definition from ME
}
// Keep This Note: This is not a robust way to check for extended maps (see above)
/*if ((int)noteData.noteLineLayer > 2)
{
v_noteLineLayer = (NoteLineLayer)rand.Next(3); // ME chaos mode
}*/
// Only non-precision-placement maps can have the option to be layer flipped
// Maps with extended layers but non-precision-placement (eg: noteLineLayer is 5) may have odd results. Consider that part of chaos mode lol
else if (flip_rows)
{
v_noteLineLayer = (NoteLineLayer)(3 - 1 - (int)noteData.noteLineLayer);
}
else
{
v_noteLineLayer = noteData.noteLineLayer;
}
NoteCutDirection v_cutDirection;
if (vertical_cut_transform.TryGetValue(noteData.cutDirection, out v_cutDirection) == false || has_ME)
{
v_cutDirection = Get_Random_Direction();
}
NoteData v_noteData = NoteData.CreateBasicNoteData(noteData.time, Check_Index(noteData.lineIndex), v_noteLineLayer, noteData.colorType, v_cutDirection);
return v_noteData;
}
private static ObstacleData Mirror_Vertical_Obstacle(ObstacleData obstacleData, bool flip_rows)
{
if (flip_rows && obstacleData.obstacleType == ObstacleType.Top)
{
obstacleData.MoveTime(-1); // To keep the number of walls the same
}
return obstacleData;
}
#endregion
#region "Check Functions"
internal static int Check_Index(int lineIndex)
{
if (lineIndex >= 500 || lineIndex <= -500)
{
return lineIndex / 1000;
//return rand.Next(4); // ME chaos mode
}
return lineIndex;
}
internal static NoteLineLayer Check_Layer(NoteLineLayer lineLayer)
{
if ((int)lineLayer >= 500 || (int)lineLayer <= -500)
{
return (NoteLineLayer)((int)lineLayer / 1000);
//return (NoteLineLayer)rand.Next(3); // ME chaos mode
}
return lineLayer;
}
#endregion
}
}