about summary refs log tree commit diff stats
path: root/client/Archipelago/gamedata.gd
blob: 16368a94393d105c5a186fc3706a0038b3765e15 (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
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { fon
extends Node

var SCRIPT_proto

var objects
var door_id_by_map_node_path = {}
var painting_id_by_map_node_path = {}
var door_id_by_ap_id = {}
var map_id_by_name = {}


func _init(proto_script):
	SCRIPT_proto = proto_script


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()]


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_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()