blob: 1865786022170d2fff9df8db5f43681d164fcb59 (
plain)
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
|
class_name ActionFormat
## Byte Length: 2 [br]
## SP
var signature: String = "AC"
## Byte Type: u8 [br]
## Byte Length: 2
var version: Version
## Byte Type: u16 [br]
## Byte Length: 2
var action_count: int
## Byte Type: u8 [br]
## Byte Length: 10
var reserved: PackedByteArray
## Length: [member action_count]
var actions: Array[Action]
## Byte Type: u16 [br]
## Byte Length: 2
var event_count: int
## Length: [member event_count]
var events: Array[Event]
## Byte Type: f32 [br]
## Byte Length: 4
var frame_times: float
func get_byte_length() -> int:
var length := 22
for action in actions:
length += action.get_byte_length()
length += Event.BYTE_LENGTH * event_count
return length
static func from_bytes(bytes: PackedByteArray):
var action = ActionFormat.new()
@warning_ignore("shadowed_variable")
var version = Version.new()
version.minor = bytes.decode_u8(2)
version.major = bytes.decode_u8(3)
action.version = version
print(version)
action.action_count = bytes.decode_u16(4)
action.reserved = bytes.slice(6, 6 + 10)
# TODO
action.actions = [] as Array[Action]
action.event_count = 0
action.frame_times = 0.0
print(inst_to_dict(action))
return action
class Action:
## Byte Type: u32 [br]
## Byte Length: 4
var motion_count: int
## Length: [member motion_count]
var motions: Array[Motion]
func get_byte_length() -> int:
var length := 4
for motion in motions:
length += motion.get_byte_length()
return length
class Motion:
## Byte Type: u8 [br]
## Byte Length: 32
var unused: PackedByteArray
## Byte Type: u32 [br]
## Byte Length: 4
var sprite_layer_count: int
## Length: [member sprite_layer_count]
var sprite_layers: Array[SpriteLayer]
## Byte Type: i32 [br]
## Byte Length: 4
var event_id: int
## Byte Type: u32 [br]
## Byte Length: 4
var sprite_anchor_count: int
## Length: [member sprite_anchor_count]
var sprite_anchors: Array[SpriteAnchor]
func get_byte_length() -> int:
return 44 + SpriteLayer.BYTE_LENGTH * sprite_layer_count + SpriteAnchor.BYTE_LENGTH * sprite_anchor_count
class SpriteLayer:
const BYTE_LENGTH := 48
## Byte Type: i32 [br]
## Byte Length: 4
var position_u: int
## Byte Type: i32 [br]
## Byte Length: 4
var position_v: int
## Byte Type: i32 [br]
## Byte Length: 4
var sprite_index: int
## Byte Type: u32 [br]
## Byte Length: 4
var is_flipped_vertical: int
## Byte Type: u8 [br]
## Byte Length: 1
var color_r: int
## Byte Type: u8 [br]
## Byte Length: 1
var color_g: int
## Byte Type: u8 [br]
## Byte Length: 1
var color_b: int
## Byte Type: u8 [br]
## Byte Length: 1
var color_a: int
## Byte Type: f32 [br]
## Byte Length: 4
var scale_u: float
## Byte Type: f32 [br]
## Byte Length: 4
var scale_v: float
## Byte Type: i32 [br]
## Byte Length: 4
var rotation_degrees: int
## Byte Type: u32 [br]
## Byte Length: 4
var sprite_type: int
## Byte Type: u32 [br]
## Byte Length: 4
var sprite_width: int
## Byte Type: u32 [br]
## Byte Length: 4
var sprite_height: int
func get_position() -> Vector2:
return Vector2(position_u, position_v)
func get_color() -> Color:
return Color8(color_r, color_g, color_b, color_a)
func get_scale() -> Vector2:
return Vector2(scale_u, scale_v)
func get_size() -> Vector2:
return Vector2(sprite_width, sprite_height)
class SpriteAnchor:
const BYTE_LENGTH := 16
## Byte Type: u8 [br]
## Byte Length: 4
var unused: PackedByteArray
## Byte Type: i32 [br]
## Byte Length: 4
var position_u: int
## Byte Type: i32 [br]
## Byte Length: 4
var position_v: int
## Byte Type: u32 [br]
## Byte Length: 4
var flag: int
func get_position() -> Vector2:
return Vector2(position_u, position_v)
class Event:
const BYTE_LENGTH := 40
## Byte Type: u8 [br]
## Byte Length: 40
var name: String
|