diff --git a/dialogue/testdialogue.dialogue b/dialogue/bridge_builder_missing_tool.dialogue similarity index 100% rename from dialogue/testdialogue.dialogue rename to dialogue/bridge_builder_missing_tool.dialogue diff --git a/dialogue/bridge_builder_missing_tool.dialogue.import b/dialogue/bridge_builder_missing_tool.dialogue.import new file mode 100644 index 0000000..d72300e --- /dev/null +++ b/dialogue/bridge_builder_missing_tool.dialogue.import @@ -0,0 +1,15 @@ +[remap] + +importer="dialogue_manager_compiler_12" +type="Resource" +uid="uid://qgj4sfugsnav" +path="res://.godot/imported/bridge_builder_missing_tool.dialogue-a575250aecf80f00531ba8af1b054b06.tres" + +[deps] + +source_file="res://dialogue/bridge_builder_missing_tool.dialogue" +dest_files=["res://.godot/imported/bridge_builder_missing_tool.dialogue-a575250aecf80f00531ba8af1b054b06.tres"] + +[params] + +defaults=true diff --git a/dialogue/testdialogue.dialogue.import b/dialogue/testdialogue.dialogue.import deleted file mode 100644 index 203814d..0000000 --- a/dialogue/testdialogue.dialogue.import +++ /dev/null @@ -1,15 +0,0 @@ -[remap] - -importer="dialogue_manager_compiler_12" -type="Resource" -uid="uid://b1gd54koq1h7o" -path="res://.godot/imported/testdialogue.dialogue-d110de06b87504b7beec281f973d2007.tres" - -[deps] - -source_file="res://dialogue/testdialogue.dialogue" -dest_files=["res://.godot/imported/testdialogue.dialogue-d110de06b87504b7beec281f973d2007.tres"] - -[params] - -defaults=true diff --git a/objects/actionable.gd b/objects/actionable.gd index 0213b2e..3315a08 100644 --- a/objects/actionable.gd +++ b/objects/actionable.gd @@ -3,8 +3,9 @@ extends Area3D @export var dialogue_resource: DialogueResource @export var dialogue_start: String = "start" -func action(quest_state: QuestState) -> void: - var balloon = load("res://ui/dialogue/balloon.tscn").instantiate() - DialogueManager.connect("dialogue_ended", quest_state.on_dialogue_ended) +func action() -> void: + var balloon = load("res://ui/dialogue/balloon.tscn").instantiate() as DialogueBaloon + get_tree().current_scene.add_child(balloon) - balloon.start(dialogue_resource, dialogue_start, [quest_state]) + var quest_states = get_tree().get_nodes_in_group("quest_state") + balloon.start(dialogue_resource, dialogue_start, quest_states) diff --git a/player.gd b/player.gd index 0664c65..1814903 100644 --- a/player.gd +++ b/player.gd @@ -6,8 +6,6 @@ const JUMP_VELOCITY = 2.5 @onready var geometry = %Geometry @onready var actionable_detector = %ActionableDetector -@onready var quest_state = %BuilderMissingTool -@onready var bridge = %Bridge # Get the gravity from the project settings to be synced with RigidBody nodes. var gravity = ProjectSettings.get_setting("physics/3d/default_gravity") @@ -52,4 +50,4 @@ func _unhandled_input(_event: InputEvent) -> void: if Input.is_action_just_pressed("ui_accept"): var actionables = actionable_detector.get_overlapping_areas() if actionables.size() > 0: - actionables[0].action(quest_state) + actionables[0].action() diff --git a/project.godot b/project.godot index d13da5a..015632e 100644 --- a/project.godot +++ b/project.godot @@ -61,7 +61,7 @@ toggle_inventory={ [internationalization] -locale/translations_pot_files=PackedStringArray("res://dialogue/testdialogue.dialogue") +locale/translations_pot_files=PackedStringArray("res://dialogue/bridge_builder_missing_tool.dialogue") [layer_names] diff --git a/quests/builder_missing_tool_quest.gd b/quests/builder_missing_tool_quest.gd index 421a11a..f62ab02 100644 --- a/quests/builder_missing_tool_quest.gd +++ b/quests/builder_missing_tool_quest.gd @@ -1,32 +1,34 @@ -class_name QuestState +class_name QuestBuilderMissingTool extends Node @export var is_wrench_found:bool = false @export var is_wrench_delivered:bool = false @export var is_bridge_built:bool = false -@onready var player:Player = %Player @onready var merchant = %Merchant @onready var bridge = %Bridge var _bridge_transform:Transform3D = Transform3D.IDENTITY +var _player:Player = null signal wrench_delivered func _ready(): _bridge_transform = bridge.global_transform bridge.global_transform = Transform3D.IDENTITY.translated(Vector3.UP * -1000) + + _player = get_tree().root.find_child("Player", true, false) func on_dialogue_ended(_dialog_resource: DialogueResource) -> void: - if is_wrench_delivered: + if is_wrench_delivered and not is_bridge_built: print ("Will build bridge!") emit_signal("wrench_delivered") func _process(_delta): - for item in player.inventory.get_items(): + for item in _player.inventory.get_items(): if item.name == "Wrench": is_wrench_found = true diff --git a/scenes/game.tscn b/scenes/game.tscn index 79eadf2..6424748 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -1,14 +1,9 @@ -[gd_scene load_steps=19 format=3 uid="uid://cqie4cy0uy1t0"] +[gd_scene load_steps=12 format=3 uid="uid://cqie4cy0uy1t0"] -[ext_resource type="Texture2D" uid="uid://bq3b1hxl5ojh6" path="res://assets/icons/npc_emotes/attention.tres" id="2_4dxur"] -[ext_resource type="PackedScene" uid="uid://2q8dhf61a7os" path="res://assets/characters/engineer.tscn" id="3_gf736"] -[ext_resource type="PackedScene" uid="uid://dhpc2xvlfln7o" path="res://objects/actionable.tscn" id="4_pths5"] -[ext_resource type="Resource" uid="uid://b1gd54koq1h7o" path="res://dialogue/testdialogue.dialogue" id="5_i1opu"] +[ext_resource type="Script" path="res://systems/QuestSystem.gd" id="4_8oxap"] [ext_resource type="PackedScene" uid="uid://dmagdl5pi6jdj" path="res://world/level.tscn" id="6_svjo8"] [ext_resource type="Script" path="res://player.gd" id="13_2wo8v"] -[ext_resource type="Script" path="res://quests/builder_missing_tool_quest.gd" id="14_g3xjj"] [ext_resource type="PackedScene" uid="uid://dy8vjf760prhq" path="res://assets/characters/rogue.tscn" id="15_2476h"] -[ext_resource type="Script" path="res://quests/scared_to_walk_in_the_dark.gd" id="18_7v3bk"] [sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_y65pc"] @@ -21,12 +16,6 @@ sky = SubResource("Sky_tw7u4") ambient_light_source = 3 ambient_light_color = Color(0.662452, 0.662452, 0.662452, 1) -[sub_resource type="CylinderShape3D" id="CylinderShape3D_vq44x"] -height = 0.6 -radius = 0.158352 - -[sub_resource type="SphereShape3D" id="SphereShape3D_6nrvr"] - [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_jd31k"] albedo_color = Color(1, 1, 0.698039, 1) @@ -51,38 +40,8 @@ environment = SubResource("Environment_v85yo") transform = Transform3D(0.836133, 0.124138, 0.534295, -0.548527, 0.189226, 0.81444, 0, -0.974055, 0.226311, 5.06819, 4.51394, 0) shadow_enabled = true -[node name="Merchant" type="CharacterBody3D" parent="."] -unique_name_in_owner = true -transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 3.64783, 0, -1.58598) - -[node name="CollisionShape3D" type="CollisionShape3D" parent="Merchant"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.310637, 0) -shape = SubResource("CylinderShape3D_vq44x") - -[node name="StateMarker" type="Sprite3D" parent="Merchant"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0272007, 0.901301, 0.168392) -centered = false -billboard = 1 -texture_filter = 0 -texture = ExtResource("2_4dxur") - -[node name="Geometry" type="Node3D" parent="Merchant"] -transform = Transform3D(0.4, 0, 0, 0, 0.4, 0, 0, 0, 0.4, 0, 0, 0) - -[node name="Engineer" parent="Merchant/Geometry" instance=ExtResource("3_gf736")] - -[node name="Actionable" parent="Merchant" instance=ExtResource("4_pths5")] -dialogue_resource = ExtResource("5_i1opu") - -[node name="CollisionShape3D" type="CollisionShape3D" parent="Merchant/Actionable"] -shape = SubResource("SphereShape3D_6nrvr") - [node name="Level" parent="." instance=ExtResource("6_svjo8")] -[node name="Bridge" type="Node3D" parent="."] -unique_name_in_owner = true -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.375699, -0.115042, 0) - [node name="Player" type="CharacterBody3D" parent="."] unique_name_in_owner = true script = ExtResource("13_2wo8v") @@ -116,11 +75,5 @@ unique_name_in_owner = true transform = Transform3D(1, 0, 0, 0, 0.460138, 0.887848, 0, -0.887848, 0.460138, 0, 2.91421, 1.186) current = true -[node name="Quests" type="Node" parent="."] - -[node name="BuilderMissingTool" type="Node" parent="Quests" groups=["quest_state"]] -unique_name_in_owner = true -script = ExtResource("14_g3xjj") - -[node name="ScaredToWalkInTheDark" type="Node" parent="Quests" groups=["quest_state"]] -script = ExtResource("18_7v3bk") +[node name="QuestSystem" type="Node" parent="."] +script = ExtResource("4_8oxap") diff --git a/systems/QuestSystem.gd b/systems/QuestSystem.gd new file mode 100644 index 0000000..f207b67 --- /dev/null +++ b/systems/QuestSystem.gd @@ -0,0 +1,15 @@ +class_name QuestSystem +extends Node + +var _quest_states:Array = [] + +# Called when the node enters the scene tree for the first time. +func _ready(): + _quest_states = get_tree().get_nodes_in_group("quest_state") + + DialogueManager.connect("dialogue_ended", _on_dialogue_ended) + +func _on_dialogue_ended(_dialog_resource: DialogueResource): + for quest_state in _quest_states: + if quest_state.has_method("on_dialogue_ended"): + quest_state.on_dialogue_ended(_dialog_resource) diff --git a/ui/dialogue/balloon.gd b/ui/dialogue/balloon.gd index 422b35a..3e58f44 100644 --- a/ui/dialogue/balloon.gd +++ b/ui/dialogue/balloon.gd @@ -1,3 +1,4 @@ +class_name DialogueBaloon extends CanvasLayer ## The action to use for advancing the dialogue diff --git a/ui/dialogue/balloon.tscn b/ui/dialogue/balloon.tscn index b7e526c..9d3aae0 100644 --- a/ui/dialogue/balloon.tscn +++ b/ui/dialogue/balloon.tscn @@ -8,8 +8,6 @@ [node name="ExampleBalloon" type="CanvasLayer"] layer = 100 script = ExtResource("1_36de5") -next_action = null -skip_action = null [node name="Balloon" type="Control" parent="."] unique_name_in_owner = true diff --git a/world/level.tscn b/world/level.tscn index 210724e..0fb5879 100644 --- a/world/level.tscn +++ b/world/level.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=12 format=3 uid="uid://dmagdl5pi6jdj"] +[gd_scene load_steps=21 format=3 uid="uid://dmagdl5pi6jdj"] [ext_resource type="MeshLibrary" uid="uid://dcpuitbu16j1a" path="res://assets/mesh_library.tres" id="1_q0eym"] [ext_resource type="PackedScene" uid="uid://da5r82nvypfk4" path="res://objects/pickup_item.tscn" id="2_qurr0"] @@ -7,10 +7,23 @@ [ext_resource type="Resource" uid="uid://coser1y1y5unl" path="res://data/items/door.tres" id="5_twsf3"] [ext_resource type="Resource" uid="uid://c1ll2snhgv3m1" path="res://data/items/treelog.tres" id="8_pafka"] [ext_resource type="PackedScene" uid="uid://dnobr4inhiskv" path="res://assets/3rdparty/kenney/platformer-kit/Models/GLB format/tree-pine.glb" id="11_ldjca"] +[ext_resource type="Texture2D" uid="uid://bq3b1hxl5ojh6" path="res://assets/icons/npc_emotes/attention.tres" id="12_3vn8y"] [ext_resource type="PackedScene" uid="uid://m4tk7vhjy310" path="res://assets/3rdparty/kenney/platformer-kit/Models/GLB format/tree.glb" id="12_l5e57"] [ext_resource type="PackedScene" uid="uid://cgde10y3e7w86" path="res://assets/3rdparty/kenney/platformer-kit/Models/GLB format/rocks.glb" id="13_dbop6"] +[ext_resource type="PackedScene" uid="uid://2q8dhf61a7os" path="res://assets/characters/engineer.tscn" id="13_t16lh"] [ext_resource type="PackedScene" uid="uid://dg1rtct0vrk3p" path="res://assets/3rdparty/kenney/platformer-kit/Models/GLB format/poles.glb" id="14_8e8cl"] +[ext_resource type="PackedScene" uid="uid://dhpc2xvlfln7o" path="res://objects/actionable.tscn" id="14_8oq2l"] +[ext_resource type="Resource" uid="uid://qgj4sfugsnav" path="res://dialogue/bridge_builder_missing_tool.dialogue" id="15_mqfyi"] [ext_resource type="PackedScene" uid="uid://cej0a41nm3eh7" path="res://assets/3rdparty/kenney/platformer-kit/Models/GLB format/mushrooms.glb" id="15_y1ifw"] +[ext_resource type="Script" path="res://quests/builder_missing_tool_quest.gd" id="16_dr1ca"] +[ext_resource type="Script" path="res://quests/scared_to_walk_in_the_dark.gd" id="17_nupwt"] +[ext_resource type="PackedScene" uid="uid://kpyvcyklt68g" path="res://assets/scene_props/bridge.tscn" id="18_yqn1p"] + +[sub_resource type="CylinderShape3D" id="CylinderShape3D_0soe6"] +height = 0.6 +radius = 0.158352 + +[sub_resource type="SphereShape3D" id="SphereShape3D_ugkqa"] [node name="Level" type="Node3D"] @@ -59,3 +72,48 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.56186, 0, -3.13331) [node name="mushrooms2" parent="Decorations" instance=ExtResource("15_y1ifw")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.851, 0, 0.798104) + +[node name="Quests" type="Node" parent="."] + +[node name="BuilderMissingTool" type="Node" parent="Quests" groups=["quest_state"]] +unique_name_in_owner = true +script = ExtResource("16_dr1ca") + +[node name="Bridge" type="Node3D" parent="Quests/BuilderMissingTool"] +unique_name_in_owner = true +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4.84904, 0.325371, -1.81888) + +[node name="poles2" parent="Quests/BuilderMissingTool/Bridge" instance=ExtResource("18_yqn1p")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.400034, 0) + +[node name="poles3" parent="Quests/BuilderMissingTool/Bridge" instance=ExtResource("18_yqn1p")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.398493, 0.670723) + +[node name="Merchant" type="CharacterBody3D" parent="Quests/BuilderMissingTool"] +unique_name_in_owner = true +transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 3.64783, 0, -1.58598) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Quests/BuilderMissingTool/Merchant"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.310637, 0) +shape = SubResource("CylinderShape3D_0soe6") + +[node name="StateMarker" type="Sprite3D" parent="Quests/BuilderMissingTool/Merchant"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0272007, 0.901301, 0.168392) +centered = false +billboard = 1 +texture_filter = 0 +texture = ExtResource("12_3vn8y") + +[node name="Geometry" type="Node3D" parent="Quests/BuilderMissingTool/Merchant"] +transform = Transform3D(0.4, 0, 0, 0, 0.4, 0, 0, 0, 0.4, 0, 0, 0) + +[node name="Engineer" parent="Quests/BuilderMissingTool/Merchant/Geometry" instance=ExtResource("13_t16lh")] + +[node name="Actionable" parent="Quests/BuilderMissingTool/Merchant" instance=ExtResource("14_8oq2l")] +dialogue_resource = ExtResource("15_mqfyi") + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Quests/BuilderMissingTool/Merchant/Actionable"] +shape = SubResource("SphereShape3D_ugkqa") + +[node name="ScaredToWalkInTheDark" type="Node" parent="Quests" groups=["quest_state"]] +script = ExtResource("17_nupwt")