sonolus-next-rush-engine 2.13.3 → 2.14.0-kizu
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/dist/EngineConfiguration +0 -0
- package/dist/EnginePlayData +0 -0
- package/dist/EnginePreviewData +0 -0
- package/dist/EngineRom +0 -0
- package/dist/EngineTutorialData +0 -0
- package/dist/EngineWatchData +0 -0
- package/dist/bandori/analyze.d.ts +3 -0
- package/dist/bandori/analyze.js +15 -0
- package/dist/bandori/convert.d.ts +3 -0
- package/dist/bandori/convert.js +183 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +18 -2
- package/dist/sirius/analyze.d.ts +3 -0
- package/dist/sirius/analyze.js +3 -0
- package/dist/sirius/convert.d.ts +3 -0
- package/dist/sirius/convert.js +251 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,6 +33,20 @@ Converts USC to Level Data.
|
|
|
33
33
|
- `usc`: usc chart.
|
|
34
34
|
- `offset`: offset (default: `0`).
|
|
35
35
|
|
|
36
|
+
### `bandoriToLeveldata(bandori, offset?)`
|
|
37
|
+
|
|
38
|
+
Converts Bandori engine LevelData to Next Rush LevelData.
|
|
39
|
+
|
|
40
|
+
- `bandori`: decompressed Bandori LevelData object.
|
|
41
|
+
- `offset`: seconds added to the existing `bgmOffset` (default: `0`).
|
|
42
|
+
|
|
43
|
+
### `siriusToLeveldata(sirius, offset?)`
|
|
44
|
+
|
|
45
|
+
Converts Sirius engine LevelData to Next Rush LevelData.
|
|
46
|
+
|
|
47
|
+
- `sirius`: decompressed Sirius LevelData object.
|
|
48
|
+
- `offset`: seconds added to the existing `bgmOffset` (default: `0`).
|
|
49
|
+
|
|
36
50
|
### Assets
|
|
37
51
|
|
|
38
52
|
The following assets are exposed as package entry points:
|
package/dist/EngineConfiguration
CHANGED
|
Binary file
|
package/dist/EnginePlayData
CHANGED
|
Binary file
|
package/dist/EnginePreviewData
CHANGED
|
Binary file
|
package/dist/EngineRom
CHANGED
|
Binary file
|
package/dist/EngineTutorialData
CHANGED
|
Binary file
|
package/dist/EngineWatchData
CHANGED
|
Binary file
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { isLevelData } from '../LevelData/analyze.js';
|
|
2
|
+
const bandoriArchetypes = new Set([
|
|
3
|
+
'TapNote',
|
|
4
|
+
'FlickNote',
|
|
5
|
+
'DirectionalFlickNote',
|
|
6
|
+
'SlideStartNote',
|
|
7
|
+
'SlideTickNote',
|
|
8
|
+
'SlideEndNote',
|
|
9
|
+
'SlideEndFlickNote',
|
|
10
|
+
'IgnoredNote',
|
|
11
|
+
'StraightSlideConnector',
|
|
12
|
+
'CurvedSlideConnector',
|
|
13
|
+
]);
|
|
14
|
+
/** Shared system entities alone cannot identify an empty Bandori chart. */
|
|
15
|
+
export const isBandoriLevelData = (input) => isLevelData(input) && input.entities.some((entity) => bandoriArchetypes.has(entity?.archetype));
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
// Preserve Bandori's seven unit lanes. A matching camera half-width makes this
|
|
2
|
+
// dynamic stage fill the same screen width as Next Rush's static 12-lane stage.
|
|
3
|
+
const STAGE_SIZE = 7 / 2;
|
|
4
|
+
const NOTE_SIZE = 0.5;
|
|
5
|
+
const noteArchetypes = new Map([
|
|
6
|
+
['TapNote', 'NormalTapNote'],
|
|
7
|
+
['FlickNote', 'NormalFlickNote'],
|
|
8
|
+
['DirectionalFlickNote', 'NormalFlickNote'],
|
|
9
|
+
['SlideStartNote', 'NormalHeadTapNote'],
|
|
10
|
+
['SlideTickNote', 'NormalTickNote'],
|
|
11
|
+
['SlideEndNote', 'NormalTailReleaseNote'],
|
|
12
|
+
['SlideEndFlickNote', 'NormalTailFlickNote'],
|
|
13
|
+
['IgnoredNote', 'AnchorNote'],
|
|
14
|
+
]);
|
|
15
|
+
const getValue = (entity, name, fallback = 0) => {
|
|
16
|
+
const field = entity.data.find((field) => field.name === name);
|
|
17
|
+
return field && 'value' in field ? field.value : fallback;
|
|
18
|
+
};
|
|
19
|
+
const setRef = (entity, name, target) => {
|
|
20
|
+
entity.data = entity.data.filter((field) => field.name !== name);
|
|
21
|
+
entity.data.push({ name, ref: target.name });
|
|
22
|
+
};
|
|
23
|
+
/** Convert Bandori engine LevelData (not a Bestdori chart) without mutating it. */
|
|
24
|
+
export const bandoriToLeveldata = (bandori, offset = 0) => {
|
|
25
|
+
const byName = new Map();
|
|
26
|
+
for (const entity of bandori.entities) {
|
|
27
|
+
if (entity.name !== undefined)
|
|
28
|
+
byName.set(entity.name, entity);
|
|
29
|
+
}
|
|
30
|
+
const resolve = (entity, name) => {
|
|
31
|
+
const field = entity.data.find((field) => field.name === name);
|
|
32
|
+
return field && 'ref' in field ? byName.get(field.ref) : undefined;
|
|
33
|
+
};
|
|
34
|
+
const usedNames = new Set(byName.keys());
|
|
35
|
+
let nextId = 0;
|
|
36
|
+
const newName = () => {
|
|
37
|
+
let name;
|
|
38
|
+
do
|
|
39
|
+
name = `bandori-${nextId++}`;
|
|
40
|
+
while (usedNames.has(name));
|
|
41
|
+
usedNames.add(name);
|
|
42
|
+
return name;
|
|
43
|
+
};
|
|
44
|
+
const create = (archetype, data, source) => ({ archetype, name: source?.name ?? newName(), data });
|
|
45
|
+
const initialization = create('Initialization', [], bandori.entities.find((entity) => entity.archetype === 'Initialization'));
|
|
46
|
+
const camera = create('CameraChange', [
|
|
47
|
+
{ name: '#BEAT', value: 0 },
|
|
48
|
+
{ name: 'lane', value: 0 },
|
|
49
|
+
{ name: 'size', value: STAGE_SIZE },
|
|
50
|
+
{ name: 'zoom', value: 1 },
|
|
51
|
+
{ name: 'stageTilt', value: 1 },
|
|
52
|
+
]);
|
|
53
|
+
setRef(initialization, 'firstCamera', camera);
|
|
54
|
+
const stage = create('Stage', [
|
|
55
|
+
{ name: 'fromStart', value: 1 },
|
|
56
|
+
{ name: 'untilEnd', value: 1 },
|
|
57
|
+
], bandori.entities.find((entity) => entity.archetype === 'Stage'));
|
|
58
|
+
const mask = create('StageMaskChange', [
|
|
59
|
+
{ name: '#BEAT', value: 0 },
|
|
60
|
+
{ name: 'stage', ref: stage.name },
|
|
61
|
+
{ name: 'lane', value: 0 },
|
|
62
|
+
{ name: 'size', value: STAGE_SIZE },
|
|
63
|
+
]);
|
|
64
|
+
const pivot = create('StagePivotChange', [
|
|
65
|
+
{ name: '#BEAT', value: 0 },
|
|
66
|
+
{ name: 'stage', ref: stage.name },
|
|
67
|
+
{ name: 'lane', value: 0 },
|
|
68
|
+
{ name: 'divisionSize', value: 1 },
|
|
69
|
+
// Odd parity puts lane centers on integers and dividers on half-integers.
|
|
70
|
+
{ name: 'divisionParity', value: 1 },
|
|
71
|
+
]);
|
|
72
|
+
const style = create('StageStyleChange', [
|
|
73
|
+
{ name: '#BEAT', value: 0 },
|
|
74
|
+
{ name: 'stage', ref: stage.name },
|
|
75
|
+
{ name: 'judgeLineColor', value: 5 },
|
|
76
|
+
{ name: 'laneAlpha', value: 1 },
|
|
77
|
+
{ name: 'judgeLineAlpha', value: 1 },
|
|
78
|
+
{ name: 'divisionLineAlpha', value: 1 },
|
|
79
|
+
{ name: 'noteAlpha', value: 1 },
|
|
80
|
+
]);
|
|
81
|
+
setRef(stage, 'firstMaskChange', mask);
|
|
82
|
+
setRef(stage, 'firstPivotChange', pivot);
|
|
83
|
+
setRef(stage, 'firstStyleChange', style);
|
|
84
|
+
const group = create('#TIMESCALE_GROUP', []);
|
|
85
|
+
const change = create('#TIMESCALE_CHANGE', [
|
|
86
|
+
{ name: '#BEAT', value: 0 },
|
|
87
|
+
{ name: '#TIMESCALE', value: 1 },
|
|
88
|
+
{ name: '#TIMESCALE_SKIP', value: 0 },
|
|
89
|
+
{ name: '#TIMESCALE_EASE', value: 0 },
|
|
90
|
+
{ name: '#TIMESCALE_GROUP', ref: group.name },
|
|
91
|
+
]);
|
|
92
|
+
setRef(group, 'first', change);
|
|
93
|
+
const entities = [initialization, camera, stage, mask, pivot, style, group, change];
|
|
94
|
+
const notes = new Map();
|
|
95
|
+
for (const source of bandori.entities) {
|
|
96
|
+
if (source.archetype === '#BPM_CHANGE') {
|
|
97
|
+
entities.push(create('#BPM_CHANGE', [
|
|
98
|
+
{ name: '#BEAT', value: getValue(source, '#BEAT') },
|
|
99
|
+
{ name: '#BPM', value: getValue(source, '#BPM') },
|
|
100
|
+
], source));
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
const archetype = noteArchetypes.get(source.archetype);
|
|
104
|
+
if (!archetype)
|
|
105
|
+
continue;
|
|
106
|
+
const directional = source.archetype === 'DirectionalFlickNote';
|
|
107
|
+
const width = directional ? getValue(source, 'size', 1) : 1;
|
|
108
|
+
const direction = directional ? (getValue(source, 'direction') < 0 ? -1 : 1) : 0;
|
|
109
|
+
// A directional flick's lane is its starting lane, not its center.
|
|
110
|
+
const lane = getValue(source, 'lane') + (direction * (width - 1)) / 2;
|
|
111
|
+
const note = create(archetype, [
|
|
112
|
+
{ name: '#BEAT', value: getValue(source, '#BEAT') },
|
|
113
|
+
{ name: 'lane', value: lane },
|
|
114
|
+
{ name: 'size', value: width * NOTE_SIZE },
|
|
115
|
+
{ name: 'direction', value: direction < 0 ? 1 : direction > 0 ? 2 : 0 },
|
|
116
|
+
{ name: 'isAttached', value: 0 },
|
|
117
|
+
{ name: 'connectorEase', value: 1 },
|
|
118
|
+
{ name: 'isSeparator', value: 0 },
|
|
119
|
+
{ name: 'segmentKind', value: 1 },
|
|
120
|
+
{ name: 'segmentAlpha', value: 1 },
|
|
121
|
+
{ name: '#TIMESCALE_GROUP', ref: group.name },
|
|
122
|
+
{ name: 'stage', ref: stage.name },
|
|
123
|
+
], source);
|
|
124
|
+
notes.set(source, note);
|
|
125
|
+
entities.push(note);
|
|
126
|
+
}
|
|
127
|
+
const resolveNote = (entity, name) => {
|
|
128
|
+
const source = resolve(entity, name);
|
|
129
|
+
return source && notes.get(source);
|
|
130
|
+
};
|
|
131
|
+
for (const [source, note] of notes) {
|
|
132
|
+
const first = source.archetype === 'SlideStartNote' ? note : resolveNote(source, 'first');
|
|
133
|
+
if (first)
|
|
134
|
+
setRef(note, 'activeHead', first);
|
|
135
|
+
const prev = resolveNote(source, 'prev');
|
|
136
|
+
if (prev)
|
|
137
|
+
setRef(note, 'prev', prev);
|
|
138
|
+
}
|
|
139
|
+
for (const source of bandori.entities) {
|
|
140
|
+
if (source.archetype === 'StraightSlideConnector' ||
|
|
141
|
+
source.archetype === 'CurvedSlideConnector') {
|
|
142
|
+
const head = resolveNote(source, 'head');
|
|
143
|
+
const tail = resolveNote(source, 'tail');
|
|
144
|
+
const start = resolveNote(source, 'start');
|
|
145
|
+
const end = resolveNote(source, 'end');
|
|
146
|
+
const firstSource = resolve(source, 'first');
|
|
147
|
+
const first = firstSource && notes.get(firstSource);
|
|
148
|
+
if (!head || !tail || !start || !end || !first || !firstSource)
|
|
149
|
+
continue;
|
|
150
|
+
const last = resolveNote(firstSource, 'last') ?? end;
|
|
151
|
+
// Both Bandori connector types interpolate linearly between their
|
|
152
|
+
// explicit points; "curved" only selects a different skin sprite.
|
|
153
|
+
const connector = create('Connector', [], source);
|
|
154
|
+
for (const [name, target] of [
|
|
155
|
+
['head', head],
|
|
156
|
+
['tail', tail],
|
|
157
|
+
['segmentHead', start],
|
|
158
|
+
['segmentTail', end],
|
|
159
|
+
['activeHead', first],
|
|
160
|
+
['activeTail', last],
|
|
161
|
+
]) {
|
|
162
|
+
setRef(connector, name, target);
|
|
163
|
+
}
|
|
164
|
+
setRef(head, 'next', tail);
|
|
165
|
+
setRef(tail, 'prev', head);
|
|
166
|
+
setRef(head, 'activeHead', first);
|
|
167
|
+
setRef(tail, 'activeHead', first);
|
|
168
|
+
entities.push(connector);
|
|
169
|
+
}
|
|
170
|
+
else if (source.archetype === 'SimLine') {
|
|
171
|
+
const a = resolveNote(source, 'a');
|
|
172
|
+
const b = resolveNote(source, 'b');
|
|
173
|
+
if (!a || !b)
|
|
174
|
+
continue;
|
|
175
|
+
const [left, right] = getValue(a, 'lane') <= getValue(b, 'lane') ? [a, b] : [b, a];
|
|
176
|
+
const simLine = create('SimLine', [], source);
|
|
177
|
+
setRef(simLine, 'left', left);
|
|
178
|
+
setRef(simLine, 'right', right);
|
|
179
|
+
entities.push(simLine);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return { ...bandori, bgmOffset: bandori.bgmOffset + offset, entities };
|
|
183
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { LevelData } from '@sonolus/core';
|
|
2
|
+
import { bandoriToLeveldata } from './bandori/convert.js';
|
|
2
3
|
import { type ExtendedEntityData, type ExtendedEntityDataField, extendedToLevelData } from './extended/convert.js';
|
|
3
4
|
import { hldToLeveldata } from './holodori/convert.js';
|
|
4
5
|
import { mmwsToUSC, ucmmwsToLevelData } from './mmw/convert.js';
|
|
6
|
+
import { siriusToLeveldata } from './sirius/convert.js';
|
|
5
7
|
import { susToUSC } from './sus/convert.js';
|
|
6
8
|
import { uscToLevelData } from './usc/convert.js';
|
|
7
9
|
import { USC } from './usc/index.js';
|
|
8
10
|
export * from './usc/index.js';
|
|
9
|
-
export { type ExtendedEntityData, type ExtendedEntityDataField, extendedToLevelData, hldToLeveldata, mmwsToUSC, susToUSC, ucmmwsToLevelData, uscToLevelData, };
|
|
11
|
+
export { type ExtendedEntityData, type ExtendedEntityDataField, bandoriToLeveldata, extendedToLevelData, hldToLeveldata, mmwsToUSC, siriusToLeveldata, susToUSC, ucmmwsToLevelData, uscToLevelData, };
|
|
10
12
|
export declare const convertToLevelData: (input: string | Uint8Array | USC | LevelData, offset?: number) => LevelData;
|
|
11
|
-
export declare const version = "2.
|
|
13
|
+
export declare const version = "2.14.0-kizu";
|
|
12
14
|
export declare const engineFullName: {
|
|
13
15
|
readonly en: 'Next RUSH';
|
|
14
16
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { TextFunction } from '@sonolus/core';
|
|
2
|
+
import { isBandoriLevelData } from './bandori/analyze.js';
|
|
3
|
+
import { bandoriToLeveldata } from './bandori/convert.js';
|
|
2
4
|
import { isExtendedLevelData } from './extended/analyze.js';
|
|
3
5
|
import { extendedToLevelData, } from './extended/convert.js';
|
|
4
6
|
import { isHolodoriLevelData } from './holodori/analyze.js';
|
|
@@ -6,12 +8,20 @@ import { hldToLeveldata } from './holodori/convert.js';
|
|
|
6
8
|
import { isLevelData } from './LevelData/analyze.js';
|
|
7
9
|
import { detectMMWSType } from './mmw/analyze.js';
|
|
8
10
|
import { mmwsToUSC, ucmmwsToLevelData } from './mmw/convert.js';
|
|
11
|
+
import { isSiriusLevelData } from './sirius/analyze.js';
|
|
12
|
+
import { siriusToLeveldata } from './sirius/convert.js';
|
|
9
13
|
import { susToUSC } from './sus/convert.js';
|
|
10
14
|
import { isUSC } from './usc/analyze.js';
|
|
11
15
|
import { uscToLevelData } from './usc/convert.js';
|
|
12
16
|
export * from './usc/index.js';
|
|
13
|
-
export { extendedToLevelData, hldToLeveldata, mmwsToUSC, susToUSC, ucmmwsToLevelData, uscToLevelData, };
|
|
17
|
+
export { bandoriToLeveldata, extendedToLevelData, hldToLeveldata, mmwsToUSC, siriusToLeveldata, susToUSC, ucmmwsToLevelData, uscToLevelData, };
|
|
14
18
|
export const convertToLevelData = (input, offset = 0) => {
|
|
19
|
+
if (isSiriusLevelData(input)) {
|
|
20
|
+
return siriusToLeveldata(input, offset);
|
|
21
|
+
}
|
|
22
|
+
if (isBandoriLevelData(input)) {
|
|
23
|
+
return bandoriToLeveldata(input, offset);
|
|
24
|
+
}
|
|
15
25
|
if (isHolodoriLevelData(input)) {
|
|
16
26
|
return hldToLeveldata(input, offset);
|
|
17
27
|
}
|
|
@@ -46,6 +56,12 @@ export const convertToLevelData = (input, offset = 0) => {
|
|
|
46
56
|
else if (typeof input === 'string') {
|
|
47
57
|
try {
|
|
48
58
|
const parsed = JSON.parse(input);
|
|
59
|
+
if (isSiriusLevelData(parsed)) {
|
|
60
|
+
return siriusToLeveldata(parsed, offset);
|
|
61
|
+
}
|
|
62
|
+
if (isBandoriLevelData(parsed)) {
|
|
63
|
+
return bandoriToLeveldata(parsed, offset);
|
|
64
|
+
}
|
|
49
65
|
if (isHolodoriLevelData(parsed)) {
|
|
50
66
|
return hldToLeveldata(parsed, offset);
|
|
51
67
|
}
|
|
@@ -74,7 +90,7 @@ export const convertToLevelData = (input, offset = 0) => {
|
|
|
74
90
|
}
|
|
75
91
|
return uscToLevelData(usc, offset, true, true);
|
|
76
92
|
};
|
|
77
|
-
export const version = '2.
|
|
93
|
+
export const version = '2.14.0-kizu';
|
|
78
94
|
export const engineFullName = {
|
|
79
95
|
en: 'Next RUSH',
|
|
80
96
|
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { isLevelData } from '../LevelData/analyze.js';
|
|
2
|
+
/** Sirius prefixes its gameplay and system archetypes, including empty charts. */
|
|
3
|
+
export const isSiriusLevelData = (input) => isLevelData(input) && input.entities.some((entity) => entity?.archetype?.startsWith('Sirius '));
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
const startArchetypes = new Map([
|
|
2
|
+
['Sirius Hold Start', 'NormalHeadTapNote'],
|
|
3
|
+
['Sirius Critical Hold Start', 'CriticalHeadTapNote'],
|
|
4
|
+
['Sirius Scratch Hold Start', 'NormalHeadTapNote'],
|
|
5
|
+
['Sirius Critical Scratch Hold Start', 'CriticalHeadTapNote'],
|
|
6
|
+
]);
|
|
7
|
+
const endArchetypes = new Set([
|
|
8
|
+
'Sirius Hold End',
|
|
9
|
+
'Sirius Nontail Hold End',
|
|
10
|
+
'Sirius Scratch Hold End',
|
|
11
|
+
'Sirius Nontail Scratch Hold End',
|
|
12
|
+
]);
|
|
13
|
+
const getValue = (entity, name, fallback = 0) => {
|
|
14
|
+
const field = entity.data.find((field) => field.name === name);
|
|
15
|
+
return field && 'value' in field ? field.value : fallback;
|
|
16
|
+
};
|
|
17
|
+
const setRef = (entity, name, target) => {
|
|
18
|
+
entity.data = entity.data.filter((field) => field.name !== name);
|
|
19
|
+
entity.data.push({ name, ref: target.name });
|
|
20
|
+
};
|
|
21
|
+
const setValue = (entity, name, value) => {
|
|
22
|
+
entity.data = entity.data.filter((field) => field.name !== name);
|
|
23
|
+
entity.data.push({ name, value });
|
|
24
|
+
};
|
|
25
|
+
const geometryKey = (entity) => `${getValue(entity, 'lane')}:${getValue(entity, 'laneLength', 1)}`;
|
|
26
|
+
const isCriticalHold = (entity) => [101, 111].includes(getValue(entity, 'holdType') % 1000);
|
|
27
|
+
/** Convert Sirius LevelData, whose note "beat" fields are seconds, without mutation. */
|
|
28
|
+
export const siriusToLeveldata = (sirius, offset = 0) => {
|
|
29
|
+
const usedNames = new Set(sirius.entities.flatMap((entity) => (entity.name === undefined ? [] : [entity.name])));
|
|
30
|
+
let nextId = 0;
|
|
31
|
+
const newName = () => {
|
|
32
|
+
let name;
|
|
33
|
+
do
|
|
34
|
+
name = `sirius-${nextId++}`;
|
|
35
|
+
while (usedNames.has(name));
|
|
36
|
+
usedNames.add(name);
|
|
37
|
+
return name;
|
|
38
|
+
};
|
|
39
|
+
const entities = [];
|
|
40
|
+
const create = (archetype, data, source) => {
|
|
41
|
+
const entity = { archetype, name: source?.name ?? newName(), data };
|
|
42
|
+
entities.push(entity);
|
|
43
|
+
return entity;
|
|
44
|
+
};
|
|
45
|
+
create('Initialization', [], sirius.entities.find((entity) => entity.archetype === 'Sirius Initialization'));
|
|
46
|
+
// Upstream SUS -> TXT -> LevelData already resolves BPM changes to seconds.
|
|
47
|
+
// At 60 BPM the target #BEAT values retain those exact times.
|
|
48
|
+
create('#BPM_CHANGE', [
|
|
49
|
+
{ name: '#BEAT', value: 0 },
|
|
50
|
+
{ name: '#BPM', value: 60 },
|
|
51
|
+
]);
|
|
52
|
+
const group = create('#TIMESCALE_GROUP', []);
|
|
53
|
+
const speeds = sirius.entities
|
|
54
|
+
.filter((entity) => entity.archetype === '#TIMESCALE_CHANGE')
|
|
55
|
+
.map((entity) => ({
|
|
56
|
+
beat: getValue(entity, '#BEAT'),
|
|
57
|
+
speed: getValue(entity, '#TIMESCALE', 1),
|
|
58
|
+
source: entity,
|
|
59
|
+
}))
|
|
60
|
+
.sort((a, b) => a.beat - b.beat);
|
|
61
|
+
if (speeds.length === 0 || speeds[0].beat > 0) {
|
|
62
|
+
speeds.unshift({ beat: 0, speed: 1, source: undefined });
|
|
63
|
+
}
|
|
64
|
+
let previousChange;
|
|
65
|
+
for (const speed of speeds) {
|
|
66
|
+
const change = create('#TIMESCALE_CHANGE', [
|
|
67
|
+
{ name: '#BEAT', value: speed.beat },
|
|
68
|
+
{ name: '#TIMESCALE', value: speed.speed },
|
|
69
|
+
{ name: '#TIMESCALE_SKIP', value: 0 },
|
|
70
|
+
{ name: '#TIMESCALE_EASE', value: 0 },
|
|
71
|
+
{ name: '#TIMESCALE_GROUP', ref: group.name },
|
|
72
|
+
], speed.source);
|
|
73
|
+
setRef(previousChange ?? group, previousChange ? 'next' : 'first', change);
|
|
74
|
+
previousChange = change;
|
|
75
|
+
}
|
|
76
|
+
const createNote = (archetype, source, beat = getValue(source, 'beat'), retainName = true, scratchSpan = false) => {
|
|
77
|
+
let left = getValue(source, 'lane', 1);
|
|
78
|
+
let width = getValue(source, 'laneLength', 1);
|
|
79
|
+
const scratch = getValue(source, 'scratchLength');
|
|
80
|
+
if (scratchSpan && scratch !== 0) {
|
|
81
|
+
if (scratch < 0)
|
|
82
|
+
left += width + scratch;
|
|
83
|
+
width = Math.abs(scratch);
|
|
84
|
+
}
|
|
85
|
+
return create(archetype, [
|
|
86
|
+
{ name: '#BEAT', value: beat },
|
|
87
|
+
// Sirius lanes start at 1; Next Rush has edges at -6 and 6.
|
|
88
|
+
{ name: 'lane', value: left + width / 2 - 7 },
|
|
89
|
+
{ name: 'size', value: width / 2 },
|
|
90
|
+
{ name: 'direction', value: scratch < 0 ? 1 : scratch > 0 ? 2 : 0 },
|
|
91
|
+
{ name: 'isAttached', value: 0 },
|
|
92
|
+
{ name: 'connectorEase', value: 1 },
|
|
93
|
+
{ name: 'isSeparator', value: 0 },
|
|
94
|
+
{ name: 'segmentKind', value: archetype.startsWith('Critical') ? 2 : 1 },
|
|
95
|
+
{ name: 'segmentAlpha', value: 1 },
|
|
96
|
+
{ name: '#TIMESCALE_GROUP', ref: group.name },
|
|
97
|
+
], retainName ? source : undefined);
|
|
98
|
+
};
|
|
99
|
+
const notes = new Map();
|
|
100
|
+
const starts = new Map();
|
|
101
|
+
const midpoints = new Map();
|
|
102
|
+
const simNotes = new Map();
|
|
103
|
+
const addSimNote = (source, note) => {
|
|
104
|
+
const beat = getValue(source, 'beat');
|
|
105
|
+
const atBeat = simNotes.get(beat) ?? [];
|
|
106
|
+
atBeat.push(note);
|
|
107
|
+
simNotes.set(beat, atBeat);
|
|
108
|
+
};
|
|
109
|
+
for (const source of sirius.entities) {
|
|
110
|
+
let archetype = startArchetypes.get(source.archetype);
|
|
111
|
+
if (archetype) {
|
|
112
|
+
const key = geometryKey(source);
|
|
113
|
+
const atLane = starts.get(key) ?? [];
|
|
114
|
+
atLane.push(source);
|
|
115
|
+
starts.set(key, atLane);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
switch (source.archetype) {
|
|
119
|
+
case 'Sirius Normal Note':
|
|
120
|
+
archetype = 'NormalTapNote';
|
|
121
|
+
break;
|
|
122
|
+
case 'Sirius Critical Note':
|
|
123
|
+
archetype = 'CriticalTapNote';
|
|
124
|
+
break;
|
|
125
|
+
case 'Sirius Flick Note':
|
|
126
|
+
archetype = 'NormalFlickNote';
|
|
127
|
+
break;
|
|
128
|
+
case 'Sirius Sound':
|
|
129
|
+
archetype = isCriticalHold(source) ? 'CriticalTapNote' : 'NormalTapNote';
|
|
130
|
+
break;
|
|
131
|
+
case 'Sirius Hold Eighth':
|
|
132
|
+
archetype = 'TransientHiddenTickNote';
|
|
133
|
+
break;
|
|
134
|
+
default:
|
|
135
|
+
if (!endArchetypes.has(source.archetype))
|
|
136
|
+
continue;
|
|
137
|
+
archetype = source.archetype.includes('Nontail')
|
|
138
|
+
? 'AnchorNote'
|
|
139
|
+
: source.archetype.includes('Scratch')
|
|
140
|
+
? 'NormalTailTraceFlickNote'
|
|
141
|
+
: 'NormalTailTraceNote';
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
const note = createNote(archetype, source, getValue(source, 'beat'), true, endArchetypes.has(source.archetype) && !source.archetype.includes('Nontail'));
|
|
146
|
+
notes.set(source, note);
|
|
147
|
+
if (source.archetype === 'Sirius Sound' || source.archetype === 'Sirius Hold Eighth') {
|
|
148
|
+
const key = geometryKey(source);
|
|
149
|
+
const atLane = midpoints.get(key) ?? [];
|
|
150
|
+
atLane.push(source);
|
|
151
|
+
midpoints.set(key, atLane);
|
|
152
|
+
}
|
|
153
|
+
else if (!source.archetype.includes('Nontail')) {
|
|
154
|
+
addSimNote(source, note);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
for (const atLane of midpoints.values()) {
|
|
158
|
+
atLane.sort((a, b) => getValue(a, 'beat') - getValue(b, 'beat'));
|
|
159
|
+
}
|
|
160
|
+
const usedStarts = new Set();
|
|
161
|
+
const previousHolds = new Map();
|
|
162
|
+
const ends = sirius.entities
|
|
163
|
+
.filter((entity) => endArchetypes.has(entity.archetype))
|
|
164
|
+
.sort((a, b) => getValue(a, 'stBeat') - getValue(b, 'stBeat'));
|
|
165
|
+
for (const source of ends) {
|
|
166
|
+
const startBeat = getValue(source, 'stBeat');
|
|
167
|
+
const endBeat = getValue(source, 'beat');
|
|
168
|
+
const tail = notes.get(source);
|
|
169
|
+
if (endBeat <= startBeat) {
|
|
170
|
+
// Upstream SoundPurple creates a scratch judgement with no hold body.
|
|
171
|
+
tail.archetype = tail.archetype.replace('Tail', '');
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
const key = geometryKey(source);
|
|
175
|
+
const startSource = starts
|
|
176
|
+
.get(key)
|
|
177
|
+
?.find((note) => !usedStarts.has(note) && getValue(note, 'beat') === startBeat);
|
|
178
|
+
const points = (midpoints.get(key) ?? []).filter((note) => getValue(note, 'beat') > startBeat && getValue(note, 'beat') < endBeat);
|
|
179
|
+
const previous = previousHolds.get(key);
|
|
180
|
+
const critical = startSource
|
|
181
|
+
? startSource.archetype.includes('Critical')
|
|
182
|
+
: points.some(isCriticalHold) || (previous?.end === startBeat && previous.critical);
|
|
183
|
+
previousHolds.set(key, { end: endBeat, critical });
|
|
184
|
+
if (critical && tail.archetype.startsWith('Normal')) {
|
|
185
|
+
tail.archetype = tail.archetype.replace('Normal', 'Critical');
|
|
186
|
+
setValue(tail, 'segmentKind', 2);
|
|
187
|
+
}
|
|
188
|
+
const head = startSource
|
|
189
|
+
? notes.get(startSource)
|
|
190
|
+
: createNote('AnchorNote', source, startBeat, false);
|
|
191
|
+
if (startSource)
|
|
192
|
+
usedStarts.add(startSource);
|
|
193
|
+
setValue(head, 'segmentKind', critical ? 2 : 1);
|
|
194
|
+
// Scratch tails can extend beyond the hold body. Keep an unscored body
|
|
195
|
+
// endpoint so the connector stays at the original lane and width.
|
|
196
|
+
const bodyTail = getValue(tail, 'lane') !== getValue(head, 'lane') ||
|
|
197
|
+
getValue(tail, 'size') !== getValue(head, 'size')
|
|
198
|
+
? createNote('AnchorNote', source, endBeat, false)
|
|
199
|
+
: tail;
|
|
200
|
+
const chain = [head, ...points.map((point) => notes.get(point)), bodyTail];
|
|
201
|
+
if (bodyTail !== tail)
|
|
202
|
+
chain.push(tail);
|
|
203
|
+
for (const [index, point] of chain.entries()) {
|
|
204
|
+
setRef(point, 'activeHead', head);
|
|
205
|
+
setValue(point, 'segmentKind', critical ? 2 : 1);
|
|
206
|
+
if (index > 0)
|
|
207
|
+
setRef(point, 'prev', chain[index - 1]);
|
|
208
|
+
if (index < chain.length - 1)
|
|
209
|
+
setRef(point, 'next', chain[index + 1]);
|
|
210
|
+
}
|
|
211
|
+
for (const point of points) {
|
|
212
|
+
if (point.archetype !== 'Sirius Hold Eighth')
|
|
213
|
+
continue;
|
|
214
|
+
const tick = notes.get(point);
|
|
215
|
+
setValue(tick, 'isAttached', 1);
|
|
216
|
+
setRef(tick, 'attachHead', head);
|
|
217
|
+
setRef(tick, 'attachTail', bodyTail);
|
|
218
|
+
}
|
|
219
|
+
const joints = [
|
|
220
|
+
head,
|
|
221
|
+
...points
|
|
222
|
+
.filter((point) => point.archetype === 'Sirius Sound')
|
|
223
|
+
.map((point) => notes.get(point)),
|
|
224
|
+
bodyTail,
|
|
225
|
+
];
|
|
226
|
+
for (let index = 1; index < joints.length; index++) {
|
|
227
|
+
const connector = create('Connector', []);
|
|
228
|
+
for (const [name, target] of [
|
|
229
|
+
['head', joints[index - 1]],
|
|
230
|
+
['tail', joints[index]],
|
|
231
|
+
['segmentHead', head],
|
|
232
|
+
['segmentTail', bodyTail],
|
|
233
|
+
['activeHead', head],
|
|
234
|
+
['activeTail', tail],
|
|
235
|
+
]) {
|
|
236
|
+
setRef(connector, name, target);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
for (const source of sirius.entities) {
|
|
241
|
+
if (source.archetype !== 'Sirius Sync Line')
|
|
242
|
+
continue;
|
|
243
|
+
const candidates = [...(simNotes.get(getValue(source, 'beat')) ?? [])].sort((a, b) => getValue(a, 'lane') - getValue(b, 'lane'));
|
|
244
|
+
if (candidates.length < 2)
|
|
245
|
+
continue;
|
|
246
|
+
const line = create('SimLine', [], source);
|
|
247
|
+
setRef(line, 'left', candidates[0]);
|
|
248
|
+
setRef(line, 'right', candidates[candidates.length - 1]);
|
|
249
|
+
}
|
|
250
|
+
return { ...sirius, bgmOffset: sirius.bgmOffset + offset, entities };
|
|
251
|
+
};
|