courier/scripts/delivery_spot.gd

36 lines
1,014 B
GDScript

extends Area2D
@onready var Dialogue : Control = $Dialogue
@onready var InteractibleManager = $InteractibleManager
@export var HighestAddressParent : Node2D
var Player : Node2D
var WaitingCash : int = 0
@export var CashMultiplier : float = 1
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
Dialogue.DialogueLabel.text = get_address(false)
Player = get_tree().get_first_node_in_group("player")
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
if Input.is_action_pressed("interact") and InteractibleManager.selected and Player.ActiveContract == self:
Player.ActiveContract = null
Player.Money += WaitingCash
func get_address(full: bool = true) -> String:
var address = name
if(full):
var parentNode = get_parent()
while(parentNode != HighestAddressParent):
address += ", " + parentNode.name
parentNode = parentNode.get_parent()
address += ", " + parentNode.name
return address