-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstructs.py
More file actions
328 lines (281 loc) · 9.54 KB
/
structs.py
File metadata and controls
328 lines (281 loc) · 9.54 KB
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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
from enum import Enum
import math
class Pointers:
def __init__(self,
metadata=0,
poseKeyframes=0,
heightKeyframes=0,
noteKeyframes=0,
scoreKeyframes=0,
comboKeyframes=0,
multiplierKeyframes=0,
energyKeyframes=0,
fpsKeyframes=0):
self.metadata = metadata
self.poseKeyframes = poseKeyframes
self.heightKeyframes = heightKeyframes
self.noteKeyframes = noteKeyframes
self.scoreKeyframes = scoreKeyframes
self.comboKeyframes = comboKeyframes
self.multiplierKeyframes = multiplierKeyframes
self.energyKeyframes = energyKeyframes
self.fpsKeyframes = fpsKeyframes
class ReplayData:
def to_dict(self) -> dict:
return dict(self)
def __repr__(self) -> str:
return repr(self.to_dict())
class Metadata(ReplayData):
def __init__(self,
Version="",
LevelID="",
Difficulty=0,
Characteristic="",
Environment="",
Modifiers=[],
NoteSpawnOffset=0.0,
LeftHanded=False,
InitialHeight=0.0,
RoomRotation=0.0,
RoomCenter=None,
FailTime=0.0):
self.Version = Version
self.LevelID = LevelID
self.Difficulty = Difficulty
self.Characteristic = Characteristic
self.Environment = Environment
self.Modifiers = Modifiers
self.NoteSpawnOffset = NoteSpawnOffset
self.LeftHanded = LeftHanded
self.InitialHeight = InitialHeight
self.RoomRotation = RoomRotation
self.RoomCenter = RoomCenter
self.FailTime = FailTime
def to_dict(self):
return {
'Version': self.Version,
'LevelID': self.LevelID,
'Difficulty': self.Difficulty,
'Characteristic': self.Characteristic,
'Environment': self.Environment,
'Modifiers': self.Modifiers,
'NoteSpawnOffset': self.NoteSpawnOffset,
'LeftHanded': self.LeftHanded,
'InitialHeight': self.InitialHeight,
'RoomRotation': self.RoomRotation,
'RoomCenter': self.RoomCenter,
'FailTime': self.FailTime,
}
class ScoreEvent(ReplayData):
def __init__(self, Score=None, Time=None, ImmediateMaxPossibleScore=None):
self.Score = Score
self.Time = Time
self.ImmediateMaxPossibleScore = ImmediateMaxPossibleScore
def to_dict(self):
return {
'Score': self.Score,
'Time': self.Time,
'ImmediateMaxPossibleScore': self.ImmediateMaxPossibleScore,
}
class ComboEvent(ReplayData):
def __init__(self, Combo=None, Time=None):
self.Combo = Combo
self.Time = Time
def to_dict(self):
return {
'Combo': self.Combo,
'Time': self.Time,
}
class NoteEvent(ReplayData):
def __init__(self,
NoteID=None,
EventType=None,
CutPoint=None,
CutNormal=None,
SaberDirection=None,
SaberType=None,
DirectionOK=None,
SaberSpeed=None,
CutAngle=None,
CutDistanceToCenter=None,
CutDirectionDeviation=None,
BeforeCutRating=None,
AfterCutRating=None,
Time=None,
UnityTimescale=None,
TimeSyncTimescale=None,
# New in V3
TimeDeviation=None,
WorldRotation=None,
InverseWorldRotation=None,
NoteRotation=None,
NotePosition=None,
):
self.NoteID = NoteID
self.EventType = EventType
self.CutPoint = CutPoint
self.CutNormal = CutNormal
self.SaberDirection = SaberDirection
self.SaberType = SaberType
self.DirectionOK = DirectionOK
self.SaberSpeed = SaberSpeed
self.CutAngle = CutAngle
self.CutDistanceToCenter = CutDistanceToCenter
self.CutDirectionDeviation = CutDirectionDeviation
self.BeforeCutRating = BeforeCutRating
self.AfterCutRating = AfterCutRating
self.Time = Time
self.UnityTimescale = UnityTimescale
self.TimeSyncTimescale = TimeSyncTimescale
self.TimeDeviation = TimeDeviation
self.WorldRotation = WorldRotation
self.InverseWorldRotation = InverseWorldRotation
self.NoteRotation = NoteRotation
self.NotePosition = NotePosition
def to_dict(self):
return {
'NoteID': self.NoteID,
'EventType': self.EventType,
'CutPoint': self.CutPoint,
'CutNormal': self.CutNormal,
'SaberDirection': self.SaberDirection,
'SaberType': self.SaberType,
'DirectionOK': self.DirectionOK,
'SaberSpeed': self.SaberSpeed,
'CutAngle': self.CutAngle,
'CutDistanceToCenter': self.CutDistanceToCenter,
'CutDirectionDeviation': self.CutDirectionDeviation,
'BeforeCutRating': self.BeforeCutRating,
'AfterCutRating': self.AfterCutRating,
'Time': self.Time,
'UnityTimescale': self.UnityTimescale,
'TimeSyncTimescale': self.TimeSyncTimescale,
'TimeDeviation': self.TimeDeviation,
'WorldRotation': self.WorldRotation,
'InverseWorldRotation': self.InverseWorldRotation,
'NoteRotation': self.NoteRotation,
'NotePosition': self.NotePosition,
}
class NoteEventType(Enum):
NoneType = 0
GoodCut = 1
BadCut = 2
Miss = 3
Bomb = 4
class NoteID(ReplayData):
def __init__(self,
Time=None,
LineLayer=None,
LineIndex=None,
ColorType=None,
CutDirection=None,
# New in V3
GameplayType=None,
ScoringType=None,
CutDirectionAngleOffset=None,
):
self.Time = Time
self.LineLayer = LineLayer
self.LineIndex = LineIndex
self.ColorType = ColorType
self.CutDirection = CutDirection
self.GameplayType = GameplayType
self.ScoringType = ScoringType
self.CutDirectionAngleOffset = CutDirectionAngleOffset
def __eq__(self, other):
return math.isclose(self.Time, other.Time) and self.LineIndex == other.LineIndex and self.LineLayer == other.LineLayer and self.ColorType == other.ColorType and self.CutDirection == other.CutDirection
def __ne__(self, other):
return not self.__eq__(other)
def __hash__(self):
return hash((self.Time, self.LineLayer, self.LineIndex))
def to_dict(self):
return {
'Time': self.Time,
'LineLayer': self.LineLayer,
'LineIndex': self.LineIndex,
'ColorType': self.ColorType,
'CutDirection': self.CutDirection,
'GameplayType': self.GameplayType,
'ScoringType': self.ScoringType,
'CutDirectionAngleOffset': self.CutDirectionAngleOffset,
}
class EnergyEvent(ReplayData):
def __init__(self, Energy=None, Time=None):
self.Energy = Energy
self.Time = Time
def to_dict(self) -> str:
return {
'Energy': self.Energy,
'Time': self.Time,
}
class HeightEvent(ReplayData):
def __init__(self, Height=None, Time=None):
self.Height = Height
self.Time = Time
def to_dict(self) -> str:
return {
'Height': self.Height,
'Time': self.Time,
}
class MultiplierEvent(ReplayData):
def __init__(self, Multiplier=None, NextMultiplierProgress=None, Time=None):
self.Multiplier = Multiplier
self.NextMultiplierProgress = NextMultiplierProgress
self.Time = Time
def to_dict(self) -> str:
return {
'Multiplier': self.Multiplier,
'NextMultiplierProgress': self.NextMultiplierProgress,
'Time': self.Time,
}
class VRPoseGroup(ReplayData):
def __init__(self, Head=None, Left=None, Right=None, FPS=0, Time=0.0):
self.Head = Head
self.Left = Left
self.Right = Right
self.FPS = FPS
self.Time = Time
def to_dict(self) -> str:
return {
'Head': self.Head,
'Left': self.Left,
'Right': self.Right,
'FPS': self.FPS,
'Time': self.Time,
}
class VRPose(ReplayData):
def __init__(self, Position=None, Rotation=None):
self.Position = Position
self.Rotation = Rotation
def to_dict(self) -> str:
return {
'Position': self.Position,
'Rotation': self.Rotation,
}
class VRPosition(ReplayData):
def __init__(self, x, y, z):
self.X = x
self.Y = y
self.Z = z
@staticmethod
def Origin():
return VRPosition()
def to_dict(self):
return {
'X': self.X,
'Y': self.Y,
'Z': self.Z
}
class VRRotation(ReplayData):
def __init__(self, x, y, z, w):
self.X = x
self.Y = y
self.Z = z
self.W = w
def to_dict(self):
return {
'X': self.X,
'Y': self.Y,
'Z': self.Z,
'W': self.W
}