summary refs log tree commit diff stats
path: root/randomizer/load.gd
blob: 9fcd0383ffbc29be7b6373dd0253d7a5eea29c05 (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
extends "res://scripts/load.gd"


func _load():
	global._print("Hooked Load Start")

	var randomizer = global.get_node("Randomizer")
	var panels_parent = $Panels

	# Hide the countdown true panels.
	for child in $CountdownPanels.get_children():
		if child.is_class("Spatial"):
			child.get_node(child.replace_with).translation.y -= 100.0

	# Apply the randomized panels.
	randomizer.generator.apply(self)

	# Write static panels.
	set_static_panel("Entry Room/Panel_hi_hi", "hi")
	if randomizer.generator.is_set_seed:
		set_static_panel("Entry Room/Panel_write_write", "set seed")
	else:
		set_static_panel("Entry Room/Panel_write_write", "random seed")
	set_static_panel("Entry Room/Panel_same_same", str(randomizer.generator.gen_seed))
	set_static_panel("Entry Room/Panel_type_type", "version")
	set_static_panel("Entry Room/Panel_this_this", randomizer.my_version)
	set_static_panel("Entry Room/Panel_hi_high", "goode", "good")
	set_static_panel("Entry Room/Panel_low_low", "serendipity", "luck")
	set_static_panel("Shuffle Room/Panel_secret_secret", "trans rights", "human rights")
	set_static_panel("Color Arrow Room/Panel_me", "me", "hatkirby")

	# HOT CRUSTS should be at eye-level, have a yellow block behind it, and
	# not vanish when solved.
	var hotcrusts = panels_parent.get_node("Shuffle Room/Panel_shortcuts")
	hotcrusts.translation.y = 1.5
	hotcrusts.get_node("Viewport/GUI/Panel/TextEdit").disconnect(
		"answer_correct", hotcrusts, "handle_correct"
	)

	set_gridmap_tile(-20.5, 1.5, -79.5, "MeshInstance9")

	# TRANS RIGHTS should be bottom white, like it used to be.
	var trans_rights = panels_parent.get_node("Shuffle Room/Panel_secret_secret")
	trans_rights.translation.y = 0.5

	# Move LOW/LOW back to where it used to be.
	var panel_low = panels_parent.get_node("Entry Room/Panel_low_low")
	var sign_low = $Decorations/PanelSign/sign21
	panel_low.translation = sign_low.translation
	panel_low.rotation = sign_low.rotation
	sign_low.queue_free()

	# Require LOW/LOW for opening the second door.
	get_node("Doors/Entry Room Area Doors/Door_hi_high").panels.append("../../../Panels/Entry Room/Panel_low_low")
	get_node("Doors/Entry Room Area Doors/Door_hi_high")._ready()

	# Proceed with the rest of the load.
	global._print("Hooked Load End")
	._load()


func set_static_panel(name, question, answer = ""):
	if answer == "":
		answer = question

	var node = self.get_node("Panels").get_node(name)

	node.text = question
	node.answer = answer


func set_gridmap_tile(x, y, z, tile):
	var gridmap = self.get_node("GridMap")
	var mesh_library = gridmap.mesh_library
	var mapvec = gridmap.world_to_map(gridmap.to_local(Vector3(x, y, z)))

	gridmap.set_cell_item(mapvec.x, mapvec.y, mapvec.z, mesh_library.find_item_by_name(tile))