Skip to content

Commit 14ed33f

Browse files
committed
WIP: Remember threads between quest playthroughs
TODO: - In two places we award threads in dialogue that aren't tagged with a scene + node. Seems bad, not sure what will happen. Put a non-revealed CollectibleItem in the scene, make the script make the TaggedItem, award that?
1 parent 7f35443 commit 14ed33f

23 files changed

Lines changed: 437 additions & 26 deletions

File tree

scenes/dev/dev_archipelago.tscn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ position = Vector2(0, 64)
174174

175175
[node name="TemplateElder" parent="OnTheGround/Elders" unique_id=1625796178 node_paths=PackedStringArray("abandon_point") instance=ExtResource("11_ui3i3")]
176176
position = Vector2(481, 1107)
177+
quest_directory = "res://scenes/dev/level_design/"
177178
abandon_point = NodePath("SpawnPoint")
178179

179180
[node name="SpawnPoint" parent="OnTheGround/Elders/TemplateElder" unique_id=1656237801 instance=ExtResource("18_elr7o")]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# SPDX-FileCopyrightText: The Threadbare Authors
2+
# SPDX-License-Identifier: MPL-2.0
3+
~ start
4+
if optional_collectible_item:
5+
Ulysses Thriftweed: If you go East, you can get out of here.
6+
Ulysses Thriftweed: If you go through the cave up North, there's another thread you can collect first, if you're feeling brave.
7+
else:
8+
Ulysses Thriftweed: I hope now you've learned to stop picking your nose.
9+
=> END
10+
11+
~ wow
12+
Ulysses Thriftweed: You run THAT fast?
13+
=> END
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[remap]
2+
3+
importer="dialogue_manager"
4+
importer_version=15
5+
type="Resource"
6+
uid="uid://b1ywwu7aese02"
7+
path="res://.godot/imported/optional_threads.dialogue-f583759440f80634b369fea5863492be.tres"
8+
9+
[deps]
10+
11+
source_file="res://scenes/dev/level_design/optional_threads/optional_threads.dialogue"
12+
dest_files=["res://.godot/imported/optional_threads.dialogue-f583759440f80634b369fea5863492be.tres"]
13+
14+
[params]
15+
16+
defaults=true
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
extends Node2D
2+
3+
@export var dark_sky_color: Color
4+
var _tween: Tween
5+
6+
@onready var cave_lighting: Area2D = %CaveLighting
7+
@onready var canvas_modulate: CanvasModulate = %CanvasModulate
8+
@onready var optional_collectible_item: CollectibleItem = %OptionalCollectibleItem
9+
10+
11+
func _ready() -> void:
12+
optional_collectible_item.tree_exiting.connect(func() -> void: optional_collectible_item = null)
13+
cave_lighting.body_entered.connect(_on_cave_lighting_body_entered)
14+
cave_lighting.body_exited.connect(_on_cave_lighting_body_exited)
15+
16+
17+
func _adjust_modulation(target: Color) -> void:
18+
if _tween:
19+
_tween.kill()
20+
21+
_tween = create_tween()
22+
_tween.tween_property(canvas_modulate, "color", target, 0.5)
23+
24+
25+
func _on_cave_lighting_body_entered(_body: Node2D) -> void:
26+
_adjust_modulation(dark_sky_color)
27+
28+
29+
func _on_cave_lighting_body_exited(_body: Node2D) -> void:
30+
_adjust_modulation(Color.WHITE)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uid://b4muk3fixh36l

scenes/dev/level_design/optional_threads/optional_threads.tscn

Lines changed: 196 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[gd_resource type="Resource" script_class="Quest" format=3 uid="uid://pdpqinul8nu5"]
2+
3+
[ext_resource type="Script" uid="uid://dts1hwdy3phin" path="res://scenes/menus/storybook/components/quest.gd" id="1_cjuqo"]
4+
5+
[resource]
6+
script = ExtResource("1_cjuqo")
7+
title = "Optional Threads"
8+
description = "Shows how to add an optional thread to a scene."
9+
first_scene = "uid://cplmo457h47p8"
10+
threads_to_collect = 2
11+
metadata/_custom_type_script = "uid://dts1hwdy3phin"

scenes/game_elements/characters/npcs/elder/components/elder.gd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ func _ready() -> void:
6161
animated_sprite_2d.connect("frame_changed", _on_frame_changed)
6262

6363
if GameState.quest:
64-
GameState.quest.inventory.item_collected.connect(_update_dialogue_title)
65-
GameState.quest.inventory.item_consumed.connect(_update_dialogue_title)
64+
GameState.quest.inventory.item_collected.connect(_update_dialogue_title.unbind(1))
65+
GameState.quest.inventory.item_consumed.connect(_update_dialogue_title.unbind(1))
6666
_update_dialogue_title()
6767

6868

@@ -105,7 +105,7 @@ func congratulate_player() -> void:
105105
await DialogueManager.dialogue_ended
106106

107107

108-
func _update_dialogue_title(_item: InventoryItem = null) -> void:
108+
func _update_dialogue_title() -> void:
109109
if eternal_loom and eternal_loom.is_item_offering_possible():
110110
talk_behavior.title = "go_to_loom"
111111
elif not _quests:
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2024 KingToot
2+
// SPDX-License-Identifier: CC0-1.0
3+
// https://godotshaders.com/shader/dithering-screen-door-transparency/
4+
shader_type canvas_item;
5+
6+
uniform float intensity: hint_range(0.0, 1.0, 0.05) = 0.0;
7+
8+
const mat4 THRESHOLD_MATRIX = mat4(
9+
vec4(1.0 / 17.0, 9.0 / 17.0, 3.0 / 17.0, 11.0 / 17.0),
10+
vec4(13.0 / 17.0, 5.0 / 17.0, 15.0 / 17.0, 7.0 / 17.0),
11+
vec4(4.0 / 17.0, 12.0 / 17.0, 2.0 / 17.0, 10.0 / 17.0),
12+
vec4(16.0 / 17.0, 8.0 / 17.0, 14.0 / 17.0, 6.0 / 17.0));
13+
14+
void fragment() {
15+
vec2 uv = UV / TEXTURE_PIXEL_SIZE;
16+
COLOR.a *= step(0.0, THRESHOLD_MATRIX[int(uv.x) % 4][int(uv.y) % 4] - intensity);
17+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uid://cj250ayvmpwf3

0 commit comments

Comments
 (0)