Skip to content

Commit

Permalink
(station) snow on shelters (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahyangyi authored Oct 10, 2024
1 parent 5105e9f commit ca29f8e
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
51 changes: 50 additions & 1 deletion station/stations/platforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
BuildingFull,
Demo,
AParentSprite,
AChildSprite,
Registers,
)
from station.lib.parameters import parameter_list
from agrf.graphics.voxel import LazyVoxel
Expand All @@ -21,6 +23,7 @@
concourse_tiles,
entries,
)
from agrf.graphics.recolour import NON_RENDERABLE_COLOUR


gray_ps = ground_ps.gray
Expand All @@ -46,6 +49,7 @@ def __init__(self):
voxel_getter=lambda path="station/voxels/cns/concourse.vox": path,
load_from="station/files/cns-gorender.json",
)
self.snow_sprites = {}

@property
def name(self):
Expand All @@ -57,6 +61,34 @@ def get_platform_classes(self):
def get_shelter_classes(self):
return ["shelter_1", "shelter_2"]

def _get_snow_sprite(self, location, shelter_class):
key = location + "_" + shelter_class
if key in self.snow_sprites:
return self.snow_sprites[key]

if location in ["building"]:
symmetry = BuildingFull
else:
symmetry = BuildingSymmetricalX

s = shelter_class + ("_" if location != "" else "") + location
skeeps = {s, s + "_snow"}
v2 = self.v.discard_layers(
tuple(sorted(tuple(platform_components) + tuple(shelter_components - skeeps))), f"subset_{s}_snow_base"
)
v3 = self.v.discard_layers(
tuple(sorted(tuple(platform_components) + tuple(shelter_components - {s + "_snow"}))),
f"subset_{s}_snow_only",
)
v = v3.compose(v2, "merge", ignore_mask=True, colour_map=NON_RENDERABLE_COLOUR)
v.config["overlap"] = 1.3
v.config["agrf_childsprite"] = (0, -10)
v.in_place_subset(symmetry.render_indices())
s = symmetry.create_variants(v.spritesheet())
self.snow_sprites[key] = AChildSprite(s, (0, 0), flags={"dodraw": Registers.SNOW})

return self.snow_sprites[key]

def get_sprite(self, location, rail_facing, platform_class, shelter_class):
if platform_class == "":
pkeeps = set()
Expand All @@ -80,6 +112,7 @@ def get_sprite(self, location, rail_facing, platform_class, shelter_class):
tuple(sorted(tuple(platform_components - pkeeps) + tuple(shelter_components - skeeps))),
f"subset_{platform_class}_{rail_facing}_{shelter_class}_{location}",
)
v2.config["agrf_manual_crop"] = (0, 10)
if location in ["building", "building_narrow"]:
symmetry = BuildingFull
else:
Expand All @@ -91,8 +124,18 @@ def get_sprite(self, location, rail_facing, platform_class, shelter_class):
)

height = max((platform_height if platform_class != "" else 0), (shelter_height if shelter_class != "" else 0))
if shelter_class in ["shelter_1", "shelter_2"]:
child_sprites = [self._get_snow_sprite(location.replace("_narrow", ""), shelter_class)]

# XXX Temporarily disable snow sprites until WenSim adds them in CNS
child_sprites = []
else:
child_sprites = []
return AParentSprite(
sprite, (16, platform_width, height - foundation_height), (0, 16 - platform_width, foundation_height)
sprite,
(16, platform_width, height - foundation_height),
(0, 16 - platform_width, foundation_height),
child_sprites=child_sprites,
)

def get_concourse_sprite(self, platform_class, side):
Expand Down Expand Up @@ -126,6 +169,12 @@ def get_concourse_sprite(self, platform_class, side):
"shelter_2",
"shelter_2_building",
"shelter_2_building_v",
"shelter_1_snow",
"shelter_1_building_snow",
"shelter_1_building_v_snow",
"shelter_2_snow",
"shelter_2_building_snow",
"shelter_2_building_v_snow",
"pillar",
"pillar_building",
"pillar_central",
Expand Down
Binary file modified station/voxels/cns/cns.vox
Binary file not shown.
Binary file modified station/voxels/cns/concourse.vox
Binary file not shown.

0 comments on commit ca29f8e

Please sign in to comment.