1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
from typing import TYPE_CHECKING
from BaseClasses import Region
from .locations import Lingo2Location
from .player_logic import AccessRequirements
from .rules import make_location_lambda
if TYPE_CHECKING:
from . import Lingo2World
def create_region(room, world: "Lingo2World") -> Region:
new_region = Region(world.static_logic.get_room_region_name(room.id), world.player, world.multiworld)
for location in world.player_logic.locations_by_room.get(room.id, {}):
new_location = Lingo2Location(world.player, world.static_logic.location_id_to_name[location.code],
location.code, new_region)
new_location.access_rule = make_location_lambda(location.reqs, world)
new_region.locations.append(new_location)
return new_region
def create_regions(world: "Lingo2World"):
regions = {
"Menu": Region("Menu", world.player, world.multiworld)
}
for room in world.static_logic.objects.rooms:
region = create_region(room, world)
regions[region.name] = region
regions["Menu"].connect(regions["the_entry - Starting Room"], "Start Game")
# TODO: The requirements of the opposite trigger also matter.
for connection in world.static_logic.objects.connections:
from_region = world.static_logic.get_room_region_name(connection.from_room)
to_region = world.static_logic.get_room_region_name(connection.to_room)
connection_name = f"{from_region} -> {to_region}"
reqs = AccessRequirements()
if connection.HasField("required_door"):
reqs.merge(world.player_logic.get_door_open_reqs(connection.required_door))
door = world.static_logic.objects.doors[connection.required_door]
wmap = world.static_logic.objects.maps[door.map_id]
connection_name = f"{connection_name} (using {wmap.name} - {door.name})"
if connection.HasField("port"):
port = world.static_logic.objects.ports[connection.port]
connection_name = f"{connection_name} (via port {port.name})"
if port.HasField("required_door"):
reqs.merge(world.player_logic.get_door_open_reqs(port.required_door))
if connection.HasField("painting"):
painting = world.static_logic.objects.paintings[connection.painting]
connection_name = f"{connection_name} (via painting {painting.name})"
if painting.HasField("required_door"):
reqs.merge(world.player_logic.get_door_open_reqs(painting.required_door))
if connection.HasField("panel"):
proxy = connection.panel
reqs.merge(world.player_logic.get_panel_reqs(proxy.panel,
proxy.answer if proxy.HasField("answer") else None))
panel = world.static_logic.objects.panels[proxy.panel]
if proxy.HasField("answer"):
connection_name = f"{connection_name} (via panel {panel.name}/{proxy.answer})"
else:
connection_name = f"{connection_name} (via panel {panel.name})"
if from_region in regions and to_region in regions:
regions[from_region].connect(regions[to_region], connection_name, make_location_lambda(reqs, world))
world.multiworld.regions += regions.values()
|