2222
2323if TYPE_CHECKING :
2424 from entrance_rando import ERPlacementState
25+ from rule_builder .rules import Rule
2526 from worlds import AutoWorld
2627
2728
@@ -726,6 +727,7 @@ class CollectionState():
726727 advancements : Set [Location ]
727728 path : Dict [Union [Region , Entrance ], PathValue ]
728729 locations_checked : Set [Location ]
730+ """Internal cache for Advancement Locations already checked by this CollectionState. Not for use in logic."""
729731 stale : Dict [int , bool ]
730732 allow_partial_entrances : bool
731733 additional_init_functions : List [Callable [[CollectionState , MultiWorld ], None ]] = []
@@ -787,9 +789,11 @@ def _update_reachable_regions_explicit_indirect_conditions(self, player: int, qu
787789 self .multiworld .worlds [player ].reached_region (self , new_region )
788790
789791 # Retry connections if the new region can unblock them
790- for new_entrance in self .multiworld .indirect_connections .get (new_region , set ()):
791- if new_entrance in blocked_connections and new_entrance not in queue :
792- queue .append (new_entrance )
792+ entrances = self .multiworld .indirect_connections .get (new_region )
793+ if entrances is not None :
794+ relevant_entrances = entrances .intersection (blocked_connections )
795+ relevant_entrances .difference_update (queue )
796+ queue .extend (relevant_entrances )
793797
794798 def _update_reachable_regions_auto_indirect_conditions (self , player : int , queue : deque [Entrance ]):
795799 reachable_regions = self .reachable_regions [player ]
@@ -1368,7 +1372,7 @@ def add_event(
13681372 self ,
13691373 location_name : str ,
13701374 item_name : str | None = None ,
1371- rule : CollectionRule | None = None ,
1375+ rule : CollectionRule | Rule [ Any ] | None = None ,
13721376 location_type : type [Location ] | None = None ,
13731377 item_type : type [Item ] | None = None ,
13741378 show_in_spoiler : bool = True ,
@@ -1396,7 +1400,7 @@ def add_event(
13961400 event_location = location_type (self .player , location_name , None , self )
13971401 event_location .show_in_spoiler = show_in_spoiler
13981402 if rule is not None :
1399- event_location . access_rule = rule
1403+ self . multiworld . worlds [ self . player ]. set_rule ( event_location , rule )
14001404
14011405 event_item = item_type (item_name , ItemClassification .progression , None , self .player )
14021406
@@ -1407,16 +1411,16 @@ def add_event(
14071411 return event_item
14081412
14091413 def connect (self , connecting_region : Region , name : Optional [str ] = None ,
1410- rule : Optional [CollectionRule ] = None ) -> Entrance :
1414+ rule : Optional [CollectionRule | Rule [ Any ] ] = None ) -> Entrance :
14111415 """
14121416 Connects this Region to another Region, placing the provided rule on the connection.
14131417
14141418 :param connecting_region: Region object to connect to path is `self -> exiting_region`
14151419 :param name: name of the connection being created
14161420 :param rule: callable to determine access of this connection to go from self to the exiting_region"""
14171421 exit_ = self .create_exit (name if name else f"{ self .name } -> { connecting_region .name } " )
1418- if rule :
1419- exit_ . access_rule = rule
1422+ if rule is not None :
1423+ self . multiworld . worlds [ self . player ]. set_rule ( exit_ , rule )
14201424 exit_ .connect (connecting_region )
14211425 return exit_
14221426
@@ -1441,7 +1445,7 @@ def create_er_target(self, name: str) -> Entrance:
14411445 return entrance
14421446
14431447 def add_exits (self , exits : Iterable [str ] | Mapping [str , str | None ],
1444- rules : Mapping [str , CollectionRule ] | None = None ) -> List [Entrance ]:
1448+ rules : Mapping [str , CollectionRule | Rule [ Any ] ] | None = None ) -> List [Entrance ]:
14451449 """
14461450 Connects current region to regions in exit dictionary. Passed region names must exist first.
14471451
0 commit comments