Skip to content

Commit

Permalink
Subnautica: avoid cache recreation in create_regions call and clean u…
Browse files Browse the repository at this point in the history
…p function. (ArchipelagoMW#2365)
  • Loading branch information
Berserker66 authored Oct 25, 2023
1 parent dab704d commit aa73dba
Showing 1 changed file with 28 additions and 12 deletions.
40 changes: 28 additions & 12 deletions worlds/subnautica/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,38 @@ def generate_early(self) -> None:
creature_pool, self.options.creature_scans.value)

def create_regions(self):
self.multiworld.regions += [
self.create_region("Menu", None, ["Lifepod 5"]),
self.create_region("Planet 4546B",
locations.events +
[location["name"] for location in locations.location_table.values()] +
[creature + creatures.suffix for creature in self.creatures_to_scan])
]
# Create Regions
menu_region = Region("Menu", self.player, self.multiworld)
planet_region = Region("Planet 4546B", self.player, self.multiworld)

# Link regions together
menu_region.connect(planet_region, "Lifepod 5")

# Create regular locations
location_names = itertools.chain((location["name"] for location in locations.location_table.values()),
(creature + creatures.suffix for creature in self.creatures_to_scan))
for location_name in location_names:
loc_id = self.location_name_to_id[location_name]
location = SubnauticaLocation(self.player, location_name, loc_id, planet_region)
planet_region.locations.append(location)

# Link regions
self.multiworld.get_entrance("Lifepod 5", self.player).connect(self.multiworld.get_region("Planet 4546B", self.player))
# Create events
goal_event_name = self.options.goal.get_event_name()

for event in locations.events:
self.multiworld.get_location(event, self.player).place_locked_item(
location = SubnauticaLocation(self.player, event, None, planet_region)
planet_region.locations.append(location)
location.place_locked_item(
SubnauticaItem(event, ItemClassification.progression, None, player=self.player))
# make the goal event the victory "item"
self.multiworld.get_location(self.options.goal.get_event_name(), self.player).item.name = "Victory"
if event == goal_event_name:
# make the goal event the victory "item"
location.item.name = "Victory"

# Register regions to multiworld
self.multiworld.regions += [
menu_region,
planet_region
]

# refer to Rules.py
set_rules = set_rules
Expand Down

0 comments on commit aa73dba

Please sign in to comment.