-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathshape.py
More file actions
39 lines (28 loc) · 1 KB
/
shape.py
File metadata and controls
39 lines (28 loc) · 1 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
from __future__ import annotations
from typing import TYPE_CHECKING
from xcoder.objects.plain_object import PlainObject
from xcoder.objects.shape import Region
if TYPE_CHECKING:
from xcoder.swf import SupercellSWF
class Shape(PlainObject):
def __init__(self):
super().__init__()
self.id = 0
self.regions: list[Region] = []
def load(self, swf: SupercellSWF, tag: int):
assert swf.reader is not None
self.id = swf.reader.read_ushort()
swf.reader.read_ushort() # regions_count
if tag == 18:
swf.reader.read_ushort() # point_count
while True:
region_tag = swf.reader.read_char()
region_length = swf.reader.read_uint()
if region_tag == 0:
return
elif region_tag in (4, 17, 22):
region = Region()
region.load(swf, region_tag)
self.regions.append(region)
else:
swf.reader.read(region_length)