Queue lab research from local stock
This commit is contained in:
parent
798deb48a1
commit
e9acca569e
7 changed files with 137 additions and 27 deletions
|
|
@ -98,6 +98,7 @@ extends Node2D
|
|||
# Buy controls below them only describe the one the player tapped.
|
||||
var lab_vessel: String = GameState.VESSEL_INTERCEPTOR
|
||||
var lab_choice: int = 0
|
||||
var lab_building_id: int = 0
|
||||
@onready var planet_field: Node2D = get_node("../PlanetField")
|
||||
@onready var info_popup: Control = get_node("../UI/BuildMenu/InfoPopup")
|
||||
@onready var info_title: Label = get_node("../UI/BuildMenu/InfoPopup/Panel/TitleLabel")
|
||||
|
|
@ -488,6 +489,7 @@ func _on_action_pressed() -> void:
|
|||
craft_menu.visible = true
|
||||
_refresh_craft_status()
|
||||
elif current_building.building_type == GameState.BUILDING_SHIP_LAB:
|
||||
lab_building_id = current_building.building_id
|
||||
lab_menu.visible = true
|
||||
_refresh_lab()
|
||||
elif current_building.building_type == GameState.BUILDING_COMMAND_CENTER:
|
||||
|
|
@ -878,25 +880,11 @@ func _on_lab_buy() -> void:
|
|||
if options.is_empty():
|
||||
return
|
||||
var choice: Dictionary = options[lab_choice]
|
||||
if choice.unlock:
|
||||
if GameState.unlock_shield_vessel():
|
||||
lab_status.text = "Shield vessel unlocked - build one at a ship crafter"
|
||||
else:
|
||||
lab_status.text = "Not enough ore: needs %d, you have %d" % [
|
||||
GameState.UNLOCK_SHIELD_COST, GameState.rocks
|
||||
]
|
||||
lab_choice = 0
|
||||
_refresh_lab()
|
||||
var id: String = GameState.UNLOCK_SHIELD_VESSEL if choice.unlock else String(choice.id)
|
||||
if not GameState.queue_lab_research(lab_building_id, id):
|
||||
lab_status.text = "Research is already queued or complete"
|
||||
return
|
||||
var id: String = choice.id
|
||||
if GameState.upgrade_maxed(id):
|
||||
lab_status.text = "%s is already fully researched" % choice.name
|
||||
return
|
||||
var cost: int = GameState.upgrade_cost(id)
|
||||
if not GameState.buy_upgrade(id):
|
||||
lab_status.text = "Not enough ore: needs %d, you have %d" % [cost, GameState.rocks]
|
||||
return
|
||||
lab_status.text = "%s is now level %d" % [choice.name, GameState.upgrade_level(id)]
|
||||
lab_status.text = "%s queued - deliver ore to this lab" % choice.name
|
||||
_refresh_lab()
|
||||
|
||||
|
||||
|
|
@ -938,10 +926,10 @@ func _refresh_lab() -> void:
|
|||
|
||||
var choice: Dictionary = options[lab_choice]
|
||||
lab_detail.text = "%s\n%s" % [choice.name, choice.desc]
|
||||
if choice.unlock:
|
||||
lab_buy_button.enabled = GameState.can_afford(GameState.UNLOCK_SHIELD_COST)
|
||||
else:
|
||||
lab_buy_button.enabled = GameState.can_buy_upgrade(choice.id)
|
||||
var queued: Dictionary = GameState.lab_research_order(lab_building_id)
|
||||
lab_buy_button.enabled = queued.is_empty() and (choice.unlock or not GameState.upgrade_maxed(choice.id))
|
||||
if not queued.is_empty():
|
||||
lab_status.text = "%s %d%%" % ["Researching" if bool(queued.started) else "Waiting for ore", int(100.0 * float(queued.elapsed) / maxf(GameState.lab_research_time(), 0.001))]
|
||||
lab_buy_button.queue_redraw()
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue