Skip to content

Commit d19b2da

Browse files
Jasper-256R-O-C-K-E-T
authored andcommitted
Support Factorio 2.0 alongside 1.1 and 2.1
1 parent 7856f35 commit d19b2da

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

factorio_sat/assets/fetch.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,27 @@ def find_asset(graphics_directory: str, entity: str, filename: str):
6060

6161

6262
def compose_assembling_machine(graphics_directory: str, destination: str):
63-
"""Build the combined sprite sheet expected by the renderer from 2.x layers."""
63+
"""Copy or build the combined sprite sheet expected by the renderer."""
6464
entity_directory = path.join(graphics_directory, 'assembling-machine-1')
65-
legacy_source = path.join(entity_directory, 'hr-assembling-machine-1.png')
66-
if path.isfile(legacy_source):
67-
print(f'Copying: {legacy_source} -> {destination}')
68-
shutil.copyfile(legacy_source, destination)
69-
return
65+
66+
# Factorio 1.1 and 2.0 both provide the combined sheet, but 2.0 dropped the
67+
# high-resolution filename prefix. Factorio 2.1 splits it into layers.
68+
combined_sources = [
69+
path.join(entity_directory, 'hr-assembling-machine-1.png'),
70+
path.join(entity_directory, 'assembling-machine-1.png'),
71+
]
72+
for source in combined_sources:
73+
if path.isfile(source):
74+
print(f'Copying: {source} -> {destination}')
75+
shutil.copyfile(source, destination)
76+
return
7077

7178
base_source = path.join(entity_directory, 'assembling-machine-1-base.png')
7279
animation_source = path.join(entity_directory, 'assembling-machine-1-anim.png')
7380
if not path.isfile(base_source) or not path.isfile(animation_source):
7481
raise FileNotFoundError(
75-
'Could not find either the Factorio 1.1 combined assembling-machine sprite '
76-
'or the Factorio 2.x base and animation sprites'
82+
'Could not find a Factorio 1.1/2.0 combined assembling-machine sprite '
83+
'or the Factorio 2.1 base and animation sprites'
7784
)
7885

7986
print(f'Composing: {base_source} + {animation_source} -> {destination}')

0 commit comments

Comments
 (0)