2024-08-16 00:24:27 +02:00
|
|
|
class_name QuestBuilderMissingTool
|
2024-07-12 14:32:33 +02:00
|
|
|
extends Node
|
|
|
|
|
2024-10-02 17:33:11 +02:00
|
|
|
@export var is_hammer_found:bool = false
|
|
|
|
@export var is_hammer_delivered:bool = false
|
2024-07-15 22:20:49 +02:00
|
|
|
@export var is_bridge_built:bool = false
|
2024-08-16 01:05:43 +02:00
|
|
|
@export var is_completed:bool = false
|
2024-07-20 09:49:49 +02:00
|
|
|
|
2024-07-15 22:20:49 +02:00
|
|
|
@onready var bridge = %Bridge
|
|
|
|
|
|
|
|
var _bridge_transform:Transform3D = Transform3D.IDENTITY
|
2024-08-16 00:24:27 +02:00
|
|
|
var _player:Player = null
|
2024-07-15 22:20:49 +02:00
|
|
|
|
|
|
|
signal wrench_delivered
|
|
|
|
|
|
|
|
func _ready():
|
|
|
|
_bridge_transform = bridge.global_transform
|
|
|
|
bridge.global_transform = Transform3D.IDENTITY.translated(Vector3.UP * -1000)
|
2024-08-16 00:24:27 +02:00
|
|
|
|
|
|
|
_player = get_tree().root.find_child("Player", true, false)
|
2024-07-15 22:20:49 +02:00
|
|
|
|
2024-07-20 09:49:49 +02:00
|
|
|
|
2024-07-15 22:20:49 +02:00
|
|
|
func on_dialogue_ended(_dialog_resource: DialogueResource) -> void:
|
2024-08-16 01:05:43 +02:00
|
|
|
if is_completed:
|
|
|
|
return
|
|
|
|
|
2024-10-02 17:33:11 +02:00
|
|
|
if is_hammer_delivered and not is_bridge_built:
|
2024-07-15 22:20:49 +02:00
|
|
|
print ("Will build bridge!")
|
|
|
|
emit_signal("wrench_delivered")
|
|
|
|
|
|
|
|
|
2024-07-20 09:49:49 +02:00
|
|
|
func _process(_delta):
|
2024-10-02 17:33:11 +02:00
|
|
|
if is_hammer_delivered:
|
2024-08-16 01:05:43 +02:00
|
|
|
is_bridge_built = true
|
|
|
|
bridge.global_transform = _bridge_transform
|
|
|
|
|
|
|
|
if is_completed:
|
|
|
|
return
|
|
|
|
|
2024-10-02 17:33:11 +02:00
|
|
|
var hammer_item:Item = load("res://data/items/hammer.tres")
|
|
|
|
if _player.inventory.has_all([hammer_item]):
|
|
|
|
is_hammer_found = true
|
2024-07-20 09:49:49 +02:00
|
|
|
|
2024-08-16 01:05:43 +02:00
|
|
|
if is_bridge_built:
|
|
|
|
is_completed = true
|