Core: check for key-only once in sweep (#361)

This commit is contained in:
Fabian Dill 2022-03-31 03:30:06 +02:00 committed by GitHub
parent 8337689640
commit cebd7fb545
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 4 deletions

View File

@ -643,11 +643,10 @@ class CollectionState():
locations = self.world.get_filled_locations()
new_locations = True
# since the loop has a good chance to run more than once, only filter the events once
locations = {location for location in locations if location.event}
locations = {location for location in locations if location.event and
not key_only or getattr(location.item, "locked_dungeon_item", False)}
while new_locations:
reachable_events = {location for location in locations if
(not key_only or getattr(location.item, "locked_dungeon_item", False))
and location.can_reach(self)}
reachable_events = {location for location in locations if location.can_reach(self)}
new_locations = reachable_events - self.events
for event in new_locations:
self.events.add(event)