Skip to content

Commit 8ff72c0

Browse files
Berserker66FlySniper
authored andcommitted
Subnautica: avoid cache recreation in create_regions call and clean up function. (ArchipelagoMW#2365)
1 parent 3034e19 commit 8ff72c0

File tree

1 file changed

+28
-12
lines changed

1 file changed

+28
-12
lines changed

worlds/subnautica/__init__.py

+28-12
Original file line numberDiff line numberDiff line change
@@ -65,22 +65,38 @@ def generate_early(self) -> None:
6565
creature_pool, self.options.creature_scans.value)
6666

6767
def create_regions(self):
68-
self.multiworld.regions += [
69-
self.create_region("Menu", None, ["Lifepod 5"]),
70-
self.create_region("Planet 4546B",
71-
locations.events +
72-
[location["name"] for location in locations.location_table.values()] +
73-
[creature + creatures.suffix for creature in self.creatures_to_scan])
74-
]
68+
# Create Regions
69+
menu_region = Region("Menu", self.player, self.multiworld)
70+
planet_region = Region("Planet 4546B", self.player, self.multiworld)
71+
72+
# Link regions together
73+
menu_region.connect(planet_region, "Lifepod 5")
74+
75+
# Create regular locations
76+
location_names = itertools.chain((location["name"] for location in locations.location_table.values()),
77+
(creature + creatures.suffix for creature in self.creatures_to_scan))
78+
for location_name in location_names:
79+
loc_id = self.location_name_to_id[location_name]
80+
location = SubnauticaLocation(self.player, location_name, loc_id, planet_region)
81+
planet_region.locations.append(location)
7582

76-
# Link regions
77-
self.multiworld.get_entrance("Lifepod 5", self.player).connect(self.multiworld.get_region("Planet 4546B", self.player))
83+
# Create events
84+
goal_event_name = self.options.goal.get_event_name()
7885

7986
for event in locations.events:
80-
self.multiworld.get_location(event, self.player).place_locked_item(
87+
location = SubnauticaLocation(self.player, event, None, planet_region)
88+
planet_region.locations.append(location)
89+
location.place_locked_item(
8190
SubnauticaItem(event, ItemClassification.progression, None, player=self.player))
82-
# make the goal event the victory "item"
83-
self.multiworld.get_location(self.options.goal.get_event_name(), self.player).item.name = "Victory"
91+
if event == goal_event_name:
92+
# make the goal event the victory "item"
93+
location.item.name = "Victory"
94+
95+
# Register regions to multiworld
96+
self.multiworld.regions += [
97+
menu_region,
98+
planet_region
99+
]
84100

85101
# refer to Rules.py
86102
set_rules = set_rules

0 commit comments

Comments
 (0)