Core: offer API hook to modify Group World creation
This commit is contained in:
parent
5d47c5b316
commit
e114ed5566
|
@ -202,14 +202,7 @@ class MultiWorld():
|
|||
self.player_types[new_id] = NetUtils.SlotType.group
|
||||
self._region_cache[new_id] = {}
|
||||
world_type = AutoWorld.AutoWorldRegister.world_types[game]
|
||||
for option_key, option in world_type.option_definitions.items():
|
||||
getattr(self, option_key)[new_id] = option(option.default)
|
||||
for option_key, option in Options.common_options.items():
|
||||
getattr(self, option_key)[new_id] = option(option.default)
|
||||
for option_key, option in Options.per_game_common_options.items():
|
||||
getattr(self, option_key)[new_id] = option(option.default)
|
||||
|
||||
self.worlds[new_id] = world_type(self, new_id)
|
||||
self.worlds[new_id] = world_type.create_group(self, new_id, players)
|
||||
self.worlds[new_id].collect_item = classmethod(AutoWorld.World.collect_item).__get__(self.worlds[new_id])
|
||||
self.player_name[new_id] = name
|
||||
|
||||
|
|
|
@ -358,6 +358,21 @@ class World(metaclass=AutoWorldRegister):
|
|||
logging.warning(f"World {self} is generating a filler item without custom filler pool.")
|
||||
return self.multiworld.random.choice(tuple(self.item_name_to_id.keys()))
|
||||
|
||||
@classmethod
|
||||
def create_group(cls, multiworld: "MultiWorld", new_player_id: int, players: Set[int]) -> World:
|
||||
"""Creates a group, which is an instance of World that is responsible for multiple others.
|
||||
An example case is ItemLinks creating these."""
|
||||
import Options
|
||||
|
||||
for option_key, option in cls.option_definitions.items():
|
||||
getattr(multiworld, option_key)[new_player_id] = option(option.default)
|
||||
for option_key, option in Options.common_options.items():
|
||||
getattr(multiworld, option_key)[new_player_id] = option(option.default)
|
||||
for option_key, option in Options.per_game_common_options.items():
|
||||
getattr(multiworld, option_key)[new_player_id] = option(option.default)
|
||||
|
||||
return cls(multiworld, new_player_id)
|
||||
|
||||
# decent place to implement progressive items, in most cases can stay as-is
|
||||
def collect_item(self, state: "CollectionState", item: "Item", remove: bool = False) -> Optional[str]:
|
||||
"""Collect an item name into state. For speed reasons items that aren't logically useful get skipped.
|
||||
|
|
Loading…
Reference in New Issue