about summary refs log tree commit diff stats
path: root/vendor/godobuf/LICENSE
blob: 5d473d85e96110d553e3b9a442d08d680a49c681 (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
BSD 3-Clause License

Copyright (c) 2018, oniksan
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
  list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
  this list of conditions and the following disclaimer in the documentation
  and/or other materials provided with the distribution.

* Neither the name of the copyright holder nor the names of its
  contributors may be used to endorse or promote products derived from
  this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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 */
const kALL_MASTERIES = 19


func on_map_load(root):
	var ap = global.get_node("Archipelago")

	# Remove the door blocking the trophy case.
	root.get_node("/root/scene/Components/Doors/entry_18").queue_free()

	# Set up mastery listeners for extra maps.
	_set_up_mastery_listener(root, "advanced")
	_set_up_mastery_listener(root, "charismatic")
	_set_up_mastery_listener(root, "crystalline")
	_set_up_mastery_listener(root, "fuzzy")
	_set_up_mastery_listener(root, "icarus")
	_set_up_mastery_listener(root, "stellar")

	if ap.endings_requirement != 12 or ap.masteries_requirement != 0:
		# Set up listeners for the potential White Ending requirements.
		var merging_prefab = preload("res://objects/nodes/listeners/mergingListener.tscn")

		var old_door = root.get_node("/root/scene/Components/Doors/entry_19")
		var new_door = old_door.duplicate()
		new_door.name = "entry_19_new"
		new_door.senders.clear()
		new_door.senderGroup.clear()
		new_door.excludeSenders.clear()

		if ap.endings_requirement == 12:
			new_door.senderGroup.append(NodePath("/root/scene/Meshes/Trophies/Listeners"))
		elif ap.endings_requirement > 0:
			if ap.masteries_requirement == 0:
				new_door.senderGroup.append(NodePath("/root/scene/Meshes/Trophies/Listeners"))
				new_door.complete_at = ap.endings_requirement
			else:
				var endings_merge = merging_prefab.instantiate()
				endings_merge.name = "EndingsMerge"
				endings_merge.senderGroup.append(NodePath("/root/scene/Meshes/Trophies/Listeners"))
				endings_merge.complete_at = ap.endings_requirement
				root.get_node("/root/scene/Components").add_child.call_deferred(endings_merge)
				new_door.senders.append(NodePath("/root/scene/Components/EndingsMerge"))

		if ap.masteries_requirement == kALL_MASTERIES:
			new_door.senderGroup.append(NodePath("/root/scene/Meshes/Trophies/MasteryListeners"))
			new_door.excludeSenders.append(
				NodePath("/root/scene/Meshes/Trophies/MasteryListeners/unlockReaderListenerWhite")
			)
		elif ap.masteries_requirement > 0:
			if ap.endings_requirement == 0:
				new_door.senderGroup.append(
					NodePath("/root/scene/Meshes/Trophies/MasteryListeners")
				)
				new_door.excludeSenders.append(
					NodePath(
						"/root/scene/Meshes/Trophies/MasteryListeners/unlockReaderListenerWhite"
					)
				)
				new_door.complete_at = ap.masteries_requirement
			else:
				var masteries_merge = merging_prefab.instantiate()
				masteries_merge.name = "MasteriesMerge"
				masteries_merge.senderGroup.append(
					NodePath("/root/scene/Meshes/Trophies/MasteryListeners")
				)
				masteries_merge.excludeSenders.append(
					NodePath(
						"/root/scene/Meshes/Trophies/MasteryListeners/unlockReaderListenerWhite"
					)
				)
				masteries_merge.complete_at = ap.masteries_requirement
				root.get_node("/root/scene/Components").add_child.call_deferred(masteries_merge)
				new_door.senders.append(NodePath("/root/scene/Components/MasteriesMerge"))

		old_door.queue_free()
		root.get_node("/root/scene/Components/Doors").add_child.call_deferred(new_door)


func _set_up_mastery_listener(root, name):
	var prefab = preload("res://objects/nodes/listeners/unlockReaderListener.tscn")
	var url = prefab.instantiate()
	url.name = "unlockReaderListenerMastery_%s" % name
	url.key = "%s_mastery" % name
	url.value = "unlocked"
	root.get_node("/root/scene/Meshes/Trophies/MasteryListeners").add_child.call_deferred(url)