46 lines
1.1 KiB
GDScript
46 lines
1.1 KiB
GDScript
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
|
|
@export var is_completed:bool = false
|
|
|
|
@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_completed:
|
|
return
|
|
|
|
if is_wrench_delivered and not is_bridge_built:
|
|
print ("Will build bridge!")
|
|
emit_signal("wrench_delivered")
|
|
|
|
|
|
func _process(_delta):
|
|
if is_wrench_delivered:
|
|
is_bridge_built = true
|
|
bridge.global_transform = _bridge_transform
|
|
|
|
if is_completed:
|
|
return
|
|
|
|
var wrench_item:Item = load("res://data/items/wrench.tres")
|
|
if _player.inventory.has_all([wrench_item]):
|
|
is_wrench_found = true
|
|
|
|
if is_bridge_built:
|
|
is_completed = true
|