56 lines
1.5 KiB
GDScript3
56 lines
1.5 KiB
GDScript3
|
|
extends "res://ui/menus/ModalMenu.gd"
|
||
|
|
|
||
|
|
signal transfer_requested(resource_type: String, to_building: bool, amount: int)
|
||
|
|
|
||
|
|
@onready var status: Label = $StatusLabel
|
||
|
|
@onready var resource_list: Control = $ResourceList
|
||
|
|
|
||
|
|
var building_id: int = 0
|
||
|
|
var extractor_index: int = -1
|
||
|
|
|
||
|
|
|
||
|
|
func _ready() -> void:
|
||
|
|
super._ready()
|
||
|
|
resource_list.transfer_requested.connect(
|
||
|
|
func(resource_type: String, to_building: bool, amount: int):
|
||
|
|
transfer_requested.emit(resource_type, to_building, amount))
|
||
|
|
|
||
|
|
|
||
|
|
func open_destination(next_building_id: int, next_extractor_index: int) -> void:
|
||
|
|
building_id = next_building_id
|
||
|
|
extractor_index = next_extractor_index
|
||
|
|
status.text = ""
|
||
|
|
open_menu()
|
||
|
|
refresh()
|
||
|
|
|
||
|
|
|
||
|
|
func close_menu() -> void:
|
||
|
|
super.close_menu()
|
||
|
|
building_id = 0
|
||
|
|
extractor_index = -1
|
||
|
|
|
||
|
|
|
||
|
|
func refresh() -> void:
|
||
|
|
if extractor_index >= 0:
|
||
|
|
resource_list.set_extractor_destination(extractor_index, "Planet extractor")
|
||
|
|
return
|
||
|
|
var building: Dictionary = GameState.find_building(building_id)
|
||
|
|
var heading: String = "This building"
|
||
|
|
if GameState.building_has_capability(building, "bank"):
|
||
|
|
heading = "Mothership bank"
|
||
|
|
resource_list.set_destination(building_id, heading)
|
||
|
|
|
||
|
|
|
||
|
|
func place_name() -> String:
|
||
|
|
if extractor_index >= 0:
|
||
|
|
return "the extractor"
|
||
|
|
var building: Dictionary = GameState.find_building(building_id)
|
||
|
|
if building.is_empty():
|
||
|
|
return "this building"
|
||
|
|
if GameState.building_has_capability(building, "bank"):
|
||
|
|
return "the bank"
|
||
|
|
return "this building"
|
||
|
|
|
||
|
|
|
||
|
|
func show_status(message: String) -> void:
|
||
|
|
status.text = message
|