about summary refs log tree commit diff stats
path: root/client/Archipelago/gamedata.gd
blob: 41d966a502e9a8a36fc01e27daecc41b0b6afb11 (plain) (blame)
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
extends Node

var SCRIPT_proto

var objects
var door_id_by_map_node_path = {}
var painting_id_by_map_node_path = {}
var panel_id_by_map_node_path = {}
var door_id_by_ap_id = {}
var map_id_by_name = {}
var progressive_id_by_ap_id = {}
var letter_id_by_ap_id = {}
var symbol_item_ids = []
var anti_trap_ids = {}

var kSYMBOL_ITEMS


func _init(proto_script):
	SCRIPT_proto = proto_script

	kSYMBOL_ITEMS = {
		SCRIPT_proto.PuzzleSymbol.SUN: "Sun Symbol",
		SCRIPT_proto.PuzzleSymbol.SPARKLES: "Sparkles Symbol",
		SCRIPT_proto.PuzzleSymbol.ZERO: "Zero Symbol",
		SCRIPT_proto.PuzzleSymbol.EXAMPLE: "Example Symbol",
		SCRIPT_proto.PuzzleSymbol.BOXES: "Boxes Symbol",
		SCRIPT_proto.PuzzleSymbol.PLANET: "Planet Symbol",
		SCRIPT_proto.PuzzleSymbol.PYRAMID: "Pyramid Symbol",
		SCRIPT_proto.PuzzleSymbol.CROSS: "Cross Symbol",
		SCRIPT_proto.PuzzleSymbol.SWEET: "Sweet Symbol",
		SCRIPT_proto.PuzzleSymbol.GENDER: "Gender Symbol",
		SCRIPT_proto.PuzzleSymbol.AGE: "Age Symbol",
		SCRIPT_proto.PuzzleSymbol.SOUND: "Sound Symbol",
		SCRIPT_proto.PuzzleSymbol.ANAGRAM: "Anagram Symbol",
		SCRIPT_proto.PuzzleSymbol.JOB: "Job Symbol",
		SCRIPT_proto.PuzzleSymbol.STARS: "Stars Symbol",
		SCRIPT_proto.PuzzleSymbol.NULL: "Null Symbol",
		SCRIPT_proto.PuzzleSymbol.EVAL: "Eval Symbol",
		SCRIPT_proto.PuzzleSymbol.LINGO: "Lingo Symbol",
		SCRIPT_proto.PuzzleSymbol.QUESTION: "Question Symbol",
	}


func load(data_bytes):
	objects = SCRIPT_proto.AllObjects.new()

	var result_code = objects.from_bytes(data_bytes)
	if result_code != SCRIPT_proto.PB_ERR.NO_ERRORS:
		print("Could not load generated data: %d" % result_code)
		return

	for map in objects.get_maps():
		map_id_by_name[map.get_name()] = map.get_id()

	for door in objects.get_doors():
		var map = objects.get_maps()[door.get_map_id()]

		if not map.get_name() in door_id_by_map_node_path:
			door_id_by_map_node_path[map.get_name()] = {}

		var map_data = door_id_by_map_node_path[map.get_name()]
		for receiver in door.get_receivers():
			map_data[receiver] = door.get_id()

		for painting_id in door.get_move_paintings():
			var painting = objects.get_paintings()[painting_id]
			map_data[painting.get_path()] = door.get_id()

		if door.has_ap_id():
			door_id_by_ap_id[door.get_ap_id()] = door.get_id()

	for painting in objects.get_paintings():
		var room = objects.get_rooms()[painting.get_room_id()]
		var map = objects.get_maps()[room.get_map_id()]

		if not map.get_name() in painting_id_by_map_node_path:
			painting_id_by_map_node_path[map.get_name()] = {}

		var _map_data = painting_id_by_map_node_path[map.get_name()]

	for progressive in objects.get_progressives():
		progressive_id_by_ap_id[progressive.get_ap_id()] = progressive.get_id()

	for letter in objects.get_letters():
		letter_id_by_ap_id[letter.get_ap_id()] = letter.get_id()

	for panel in objects.get_panels():
		var room = objects.get_rooms()[panel.get_room_id()]
		var map = objects.get_maps()[room.get_map_id()]

		if not map.get_name() in panel_id_by_map_node_path:
			panel_id_by_map_node_path[map.get_name()] = {}

		var map_data = panel_id_by_map_node_path[map.get_name()]
		map_data[panel.get_path()] = panel.get_id()

	for symbol_name in kSYMBOL_ITEMS.values():
		symbol_item_ids.append(objects.get_special_ids()[symbol_name])

	for special_name in objects.get_special_ids().keys():
		if special_name.begins_with("Anti "):
			anti_trap_ids[objects.get_special_ids()[special_name]] = (
				special_name.substr(5).to_lower()
			)


func get_door_for_map_node_path(map_name, node_path):
	if not door_id_by_map_node_path.has(map_name):
		return null

	var map_data = door_id_by_map_node_path[map_name]
	return map_data.get(node_path, null)


func get_panel_for_map_node_path(map_name, node_path):
	if not panel_id_by_map_node_path.has(map_name):
		return null

	var map_data = panel_id_by_map_node_path[map_name]
	return map_data.get(node_path, null)


func get_door_ap_id(door_id):
	var door = objects.get_doors()[door_id]
	if door.has_ap_id():
		return door.get_ap_id()
	else:
		return null


func get_door_receivers(door_id):
	var door = objects.get_doors()[door_id]
	return door.get_receivers()


func get_door_map_name(door_id):
	var door = objects.get_doors()[door_id]
	var map = objects.get_maps()[door.get_map_id()]
	return map.get_name()
> // only cases when this shouldn't be set is the two disappearing keyholders in // The Congruent. optional string key = 3; } message HumanLetter { optional string key = 1; optional bool level2 = 2; optional string path = 3; } message HumanMastery { optional string name = 1; optional string path = 2; } message HumanEnding { optional string name = 1; optional string path = 2; } message HumanRoom { optional string name = 1; optional string display_name = 2; // This is used in panelsanity location names and location names for STANDARD // doors generated from panels in the same area. optional string panel_display_name = 10; repeated HumanPanel panels = 3; repeated HumanPainting paintings = 4; repeated HumanLetter letters = 5; repeated HumanPort ports = 6; repeated HumanKeyholder keyholders = 7; repeated HumanMastery masteries = 8; repeated HumanEnding endings = 9; } message HumanMap { optional string display_name = 1; repeated string excluded_nodes = 2; } message HumanProgressive { optional string name = 1; repeated DoorIdentifier doors = 2; } message HumanProgressives { repeated HumanProgressive progressives = 1; } message HumanDoorGroup { optional string name = 1; optional DoorGroupType type = 2; repeated DoorIdentifier doors = 3; } message HumanDoorGroups { repeated HumanDoorGroup door_groups = 1; } message IdMappings { message RoomIds { map<string, uint64> panels = 1; map<string, uint64> masteries = 2; map<string, uint64> keyholders = 3; } message MapIds { map<string, uint64> doors = 1; map<string, RoomIds> rooms = 2; } map<string, MapIds> maps = 1; map<string, uint64> special = 2; map<string, uint64> letters = 3; map<string, uint64> endings = 4; map<string, uint64> progressives = 5; map<string, uint64> door_groups = 6; }