about summary refs log tree commit diff stats
path: root/data/maps/the_partial/connections.txtpb
diff options
context:
space:
mode:
Diffstat (limited to 'data/maps/the_partial/connections.txtpb')
-rw-r--r--data/maps/the_partial/connections.txtpb32
1 files changed, 32 insertions, 0 deletions
diff --git a/data/maps/the_partial/connections.txtpb b/data/maps/the_partial/connections.txtpb new file mode 100644 index 0000000..34ff94f --- /dev/null +++ b/data/maps/the_partial/connections.txtpb
@@ -0,0 +1,32 @@
1connections {
2 from_room: "Obverse Side"
3 to_room: "P Room"
4 door { name: "Giant P" }
5}
6connections {
7 from_room: "Obverse Side"
8 to_room: "Reverse Side"
9 door { name: "R Entered" }
10}
11connections {
12 from_room: "Obverse Side"
13 to_room: "Reverse Side"
14 door { name: "P Entered" }
15}
16connections {
17 from_room: "Obverse Side"
18 to_room: "Control Center Entrance"
19 door { name: "L Entered" }
20 oneway: true
21}
22connections {
23 from_room: "Control Center Entrance"
24 to_room: "Obverse Side"
25 door { name: "Control Center Entrance" }
26 oneway: true
27}
28connections {
29 from_room: "Reverse Side"
30 to_room: "F Room"
31 door { name: "Giant F" }
32}
0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
extends Node

const my_version = "0.1.0"

var SCRIPT_client
var SCRIPT_locationListener
var SCRIPT_uuid

var ap_server = ""
var ap_user = ""
var ap_pass = ""
var connection_history = []

var client

var _received_indexes = []
var _last_new_item = -1

signal could_not_connect
signal connect_status
signal ap_connected


func _ready():
	client = SCRIPT_client.new()
	client.SCRIPT_uuid = SCRIPT_uuid

	client.connect("item_received", _process_item)
	client.connect("could_not_connect", _client_could_not_connect)
	client.connect("connect_status", _client_connect_status)
	client.connect("client_connected", _client_connected)

	add_child(client)


func saveSettings():
	pass


func connectToServer():
	_received_indexes = []
	_last_new_item = -1

	client.connectToServer(ap_server, ap_user, ap_pass)


func getSaveFileName():
	return "zzAP_%s_%d" % [client._seed, client._slot]


func disconnect_from_ap():
	client.disconnect_from_ap()


func get_item_id_for_door(door_id):
	var gamedata = global.get_node("Gamedata")
	var door = gamedata.objects.get_doors()[door_id]
	if (
		door.get_type() == gamedata.SCRIPT_proto.DoorType.EVENT
		or door.get_type() == gamedata.SCRIPT_proto.DoorType.LOCATION_ONLY
		or door.get_type() == gamedata.SCRIPT_proto.DoorType.CONTROL_CENTER_COLOR
	):
		return null
	return gamedata.get_door_ap_id(door_id)


func has_item(item_id):
	return client.hasItem(item_id)


func _process_item(item, index, from, flags):
	if index != null:
		if _received_indexes.has(index):
			# Do not re-process items.
			return

		_received_indexes.append(index)

	var item_name = "Unknown"
	if client._item_id_to_name["Lingo 2"].has(item):
		item_name = client._item_id_to_name["Lingo 2"][item]

	var gamedata = global.get_node("Gamedata")
	var door_id = gamedata.door_id_by_ap_id.get(item, null)
	if door_id != null and gamedata.get_door_map_name(door_id) == global.map:
		var receivers = gamedata.get_door_receivers(door_id)
		var scene = get_tree().get_root().get_node_or_null("scene")
		if scene != null:
			for receiver in receivers:
				var rnode = scene.get_node_or_null(receiver)
				if rnode != null:
					rnode.handleTriggered()
			for painting_id in gamedata.objects.get_doors()[door_id].get_move_paintings():
				var painting = gamedata.objects.get_paintings()[painting_id]
				var pnode = scene.get_node_or_null(painting.get_path() + "/teleportListener")
				if pnode != null:
					pnode.handleTriggered()

	# Show a message about the item if it's new.
	if index != null and index > _last_new_item:
		_last_new_item = index
		#saveLocaldata()

		var player_name = "Unknown"
		if client._player_name_by_slot.has(from):
			player_name = client._player_name_by_slot[from]

		var item_color = colorForItemType(flags)

		var message
		if from == client._slot:
			message = "Found [color=%s]%s[/color]" % [item_color, item_name]
		else:
			message = "Received [color=%s]%s[/color] from %s" % [item_color, item_name, player_name]

		global._print(message)

		global.get_node("Messages").showMessage(message)


func _process_message(message):
	if (
		!message.has("receiving")
		or !message.has("item")
		or message["item"]["player"] != client._slot
	):
		return

	var item_name = "Unknown"
	var item_player_game = client._game_by_player[message["receiving"]]
	if client._item_id_to_name[item_player_game].has(message["item"]["item"]):
		item_name = client._item_id_to_name[item_player_game][message["item"]["item"]]

	var location_name = "Unknown"
	var location_player_game = client._game_by_player[message["item"]["player"]]
	if client._location_id_to_name[location_player_game].has(message["item"]["location"]):
		location_name = (
			client._location_id_to_name[location_player_game][message["item"]["location"]]
		)

	var player_name = "Unknown"
	if client._player_name_by_slot.has(message["receiving"]):
		player_name = client._player_name_by_slot[message["receiving"]]

	var item_color = colorForItemType(message["item"]["flags"])

	if message["type"] == "Hint":
		var is_for = ""
		if message["receiving"] != client._slot:
			is_for = " for %s" % player_name
		if !message.has("found") || !message["found"]:
			global.get_node("Messages").showMessage(
				(
					"Hint: [color=%s]%s[/color]%s is on %s"
					% [item_color, item_name, is_for, location_name]
				)
			)
	else:
		if message["receiving"] != client._slot:
			var sentMsg = "Sent [color=%s]%s[/color] to %s" % [item_color, item_name, player_name]
			#if _hinted_locations.has(message["item"]["location"]):
			#	sentMsg += " ([color=#fafad2]Hinted![/color])"
			global.get_node("Messages").showMessage(sentMsg)


func _client_could_not_connect():
	emit_signal("could_not_connect")


func _client_connect_status(message):
	emit_signal("connect_status", message)


func _client_connected():
	emit_signal("ap_connected")


func send_location(loc_id):
	client.sendLocation(loc_id)


func colorForItemType(flags):
	var int_flags = int(flags)
	if int_flags & 1:  # progression
		if int_flags & 2:  # proguseful
			return "#f0d200"
		else:
			return "#bc51e0"
	elif int_flags & 2:  # useful
		return "#2b67ff"
	elif int_flags & 4:  # trap
		return "#d63a22"
	else:  # filler
		return "#14de9e"