SoE: create regions cleanup and speedup (#2361)
* SoE: create regions cleanup and speedup keep local reference instead of hitting multiworld cache also technically fixes a bug where all locations are in 'menu', not 'ingame' * SoE: somplify region connection
This commit is contained in:
parent
e87d5d5ac2
commit
e5554f8630
|
@ -224,9 +224,8 @@ class SoEWorld(World):
|
||||||
max_difficulty = 1 if self.multiworld.difficulty[self.player] == Difficulty.option_easy else 256
|
max_difficulty = 1 if self.multiworld.difficulty[self.player] == Difficulty.option_easy else 256
|
||||||
|
|
||||||
# TODO: generate *some* regions from locations' requirements?
|
# TODO: generate *some* regions from locations' requirements?
|
||||||
r = Region('Menu', self.player, self.multiworld)
|
menu = Region('Menu', self.player, self.multiworld)
|
||||||
r.exits = [Entrance(self.player, 'New Game', r)]
|
self.multiworld.regions += [menu]
|
||||||
self.multiworld.regions += [r]
|
|
||||||
|
|
||||||
def get_sphere_index(evermizer_loc):
|
def get_sphere_index(evermizer_loc):
|
||||||
"""Returns 0, 1 or 2 for locations in spheres 1, 2, 3+"""
|
"""Returns 0, 1 or 2 for locations in spheres 1, 2, 3+"""
|
||||||
|
@ -234,11 +233,14 @@ class SoEWorld(World):
|
||||||
return 2
|
return 2
|
||||||
return min(2, len(evermizer_loc.requires))
|
return min(2, len(evermizer_loc.requires))
|
||||||
|
|
||||||
|
# create ingame region
|
||||||
|
ingame = Region('Ingame', self.player, self.multiworld)
|
||||||
|
|
||||||
# group locations into spheres (1, 2, 3+ at index 0, 1, 2)
|
# group locations into spheres (1, 2, 3+ at index 0, 1, 2)
|
||||||
spheres: typing.Dict[int, typing.Dict[int, typing.List[SoELocation]]] = {}
|
spheres: typing.Dict[int, typing.Dict[int, typing.List[SoELocation]]] = {}
|
||||||
for loc in _locations:
|
for loc in _locations:
|
||||||
spheres.setdefault(get_sphere_index(loc), {}).setdefault(loc.type, []).append(
|
spheres.setdefault(get_sphere_index(loc), {}).setdefault(loc.type, []).append(
|
||||||
SoELocation(self.player, loc.name, self.location_name_to_id[loc.name], r,
|
SoELocation(self.player, loc.name, self.location_name_to_id[loc.name], ingame,
|
||||||
loc.difficulty > max_difficulty))
|
loc.difficulty > max_difficulty))
|
||||||
|
|
||||||
# location balancing data
|
# location balancing data
|
||||||
|
@ -280,18 +282,16 @@ class SoEWorld(World):
|
||||||
late_locations = self.multiworld.random.sample(late_bosses, late_count)
|
late_locations = self.multiworld.random.sample(late_bosses, late_count)
|
||||||
|
|
||||||
# add locations to the world
|
# add locations to the world
|
||||||
r = Region('Ingame', self.player, self.multiworld)
|
|
||||||
for sphere in spheres.values():
|
for sphere in spheres.values():
|
||||||
for locations in sphere.values():
|
for locations in sphere.values():
|
||||||
for location in locations:
|
for location in locations:
|
||||||
r.locations.append(location)
|
ingame.locations.append(location)
|
||||||
if location.name in late_locations:
|
if location.name in late_locations:
|
||||||
location.progress_type = LocationProgressType.PRIORITY
|
location.progress_type = LocationProgressType.PRIORITY
|
||||||
|
|
||||||
r.locations.append(SoELocation(self.player, 'Done', None, r))
|
ingame.locations.append(SoELocation(self.player, 'Done', None, ingame))
|
||||||
self.multiworld.regions += [r]
|
menu.connect(ingame, "New Game")
|
||||||
|
self.multiworld.regions += [ingame]
|
||||||
self.multiworld.get_entrance('New Game', self.player).connect(self.multiworld.get_region('Ingame', self.player))
|
|
||||||
|
|
||||||
def create_items(self):
|
def create_items(self):
|
||||||
# add regular items to the pool
|
# add regular items to the pool
|
||||||
|
|
Loading…
Reference in New Issue