53 lines
1.4 KiB
GDScript
53 lines
1.4 KiB
GDScript
class_name QuestBuilderMissingTool
|
|
extends QuestBase
|
|
|
|
@export var is_hammer_found:bool = false
|
|
@export var is_hammer_delivered:bool = false
|
|
@export var is_bridge_built:bool = false
|
|
|
|
@onready var bridge = %Bridge
|
|
@onready var merchant: NonPlayerCharacter = %Merchant
|
|
|
|
var _bridge_transform:Transform3D = Transform3D.IDENTITY
|
|
var _merchant_conversation_actionable:ConversationActionable = null
|
|
|
|
signal wrench_delivered
|
|
|
|
func _ready():
|
|
super._ready()
|
|
|
|
_bridge_transform = bridge.global_transform
|
|
bridge.global_transform = Transform3D.IDENTITY.translated(Vector3.UP * -1000)
|
|
|
|
_merchant_conversation_actionable = merchant.find_child("Conversation", true, false)
|
|
assert(_merchant_conversation_actionable != null)
|
|
_merchant_conversation_actionable.conversation_started.connect(on_dialogue_started)
|
|
|
|
func on_dialogue_started() -> void:
|
|
_player.is_input_blocked = true
|
|
|
|
func on_dialogue_ended(_dialog_resource: DialogueResource) -> void:
|
|
_player.is_input_blocked = false
|
|
|
|
if is_completed:
|
|
return
|
|
|
|
if is_hammer_delivered and not is_bridge_built:
|
|
wrench_delivered.emit()
|
|
|
|
|
|
func _process(_delta):
|
|
if is_hammer_delivered:
|
|
is_bridge_built = true
|
|
bridge.global_transform = _bridge_transform
|
|
|
|
if is_completed:
|
|
return
|
|
|
|
var hammer_item:ItemResource = load("res://data/items/hammer.tres")
|
|
if _player.inventory.has_all([hammer_item]):
|
|
is_hammer_found = true
|
|
|
|
if is_bridge_built:
|
|
is_completed = true
|