88from importlib import resources as impresources
99from sourcehold import resources
1010
11- mapping_xyinversed_offset = np .zeros (shape = (AIV_WIDTH , AIV_HEIGHT ), dtype = 'uint32' )
12- mapping_xy_offset = np .zeros (shape = (AIV_WIDTH , AIV_HEIGHT ), dtype = 'uint32' )
11+ # mapping_xyinversed_offset = np.zeros(shape=(AIV_WIDTH, AIV_HEIGHT), dtype='uint32')
12+ # mapping_xy_offset = np.zeros(shape=(AIV_WIDTH, AIV_HEIGHT), dtype='uint32')
1313
14- offset = - 1
15- for x in x_range ():
16- for y in y_range (invert_y = False ):
17- offset += 1
18- mapping_xy_offset [x , y ] = offset
14+ # offset = -1
15+ # for x in x_range(invert_x=False ):
16+ # for y in y_range(invert_y=False):
17+ # offset += 1
18+ # mapping_xy_offset[x, y] = offset
1919
20- offset = - 1
21- for x in x_range ():
22- for y in y_range (invert_y = True ):
23- offset += 1
24- mapping_xyinversed_offset [x , y ] = offset
20+ # offset = -1
21+ # for x in x_range(invert_x=False ):
22+ # for y in y_range(invert_y=True):
23+ # offset += 1
24+ # mapping_xyinversed_offset[x, y] = offset
2525
26- def convert_offset (offset , invert_y = False ):
27- return (offset // AIV_WIDTH , offset % AIV_HEIGHT if not invert_y else (AIV_HEIGHT - 1 ) - (offset % AIV_HEIGHT ))
26+ def convert_offset (offset , invert_y = False , invert_x = False ):
27+ y = offset % AIV_HEIGHT if not invert_y else (AIV_HEIGHT - 1 ) - (offset % AIV_HEIGHT )
28+ x = offset // AIV_WIDTH if not invert_x else ((AIV_WIDTH - 1 ) - (offset // AIV_WIDTH ))
29+ return (x , y )
2830
29- def convert_offsets (offsets , invert_y = False ):
31+ def convert_offsets (offsets , invert_y = False , invert_x = False ):
3032 for loc in offsets :
31- yield convert_offset (loc , invert_y = invert_y )
33+ yield convert_offset (loc , invert_y = invert_y , invert_x = invert_x )
3234
33- def from_json (path : Union [str , None ] = None , data : Union [Dict , None ] = None , f = None , invert_y = True , report = False ):
35+ def from_json (path : Union [str , None ] = None , data : Union [Dict , None ] = None , f = None , invert_y = False , invert_x = True , report = False ):
3436 if not path and not data and not f :
3537 raise Exception ()
3638
@@ -62,7 +64,7 @@ def from_json(path: Union[str, None] = None, data: Union[Dict, None] = None, f=N
6264 # Special type
6365 aivID = convertMapperEnumToAIVEnum (v = mapperID )
6466 locations = frame ['tilePositionOfsets' ]
65- for x , y in convert_offsets (locations , invert_y = invert_y ):
67+ for x , y in convert_offsets (locations , invert_y = invert_y , invert_x = invert_x ):
6668 constructions [x , y ] = aivID
6769 steps [x , y ] = step
6870 else :
@@ -74,7 +76,7 @@ def from_json(path: Union[str, None] = None, data: Union[Dict, None] = None, f=N
7476 if len (frame ['tilePositionOfsets' ]) > 1 :
7577 raise Exception (f'too many locations for a building: { frame ["tilePositionOfsets" ]} ' )
7678 location = frame ['tilePositionOfsets' ][0 ]
77- x , y = convert_offset (location , invert_y = invert_y )
79+ x , y = convert_offset (location , invert_y = invert_y , invert_x = invert_x )
7880 constructions [x :(x + size ),y :(y + size )] = aivID
7981 steps [x :(x + size ),y :(y + size )] = step
8082 for miscItem in data ['miscItems' ]:
0 commit comments