Supply lab research with transporters

This commit is contained in:
Loïc Wisniewski 2026-08-14 22:46:25 +02:00
commit 3fc04f816a
3 changed files with 56 additions and 1 deletions

View file

@ -670,6 +670,9 @@ func outstanding_cost(id: int) -> int:
# A started build has already paid, so it is not still owed.
if not bool(o.started):
need += product_cost(String(o.product))
for order in b.get("research_orders", []):
if not bool(order.started):
need += research_cost(String(order.id))
return maxi(need - _inventory_for_record(b).amount(RESOURCE_ORE), 0)
@ -771,6 +774,11 @@ func lab_research_order(lab_id: int) -> Dictionary:
return {} if orders.is_empty() else orders[0]
func research_cost(id: String) -> int:
var unlock_definition: Resource = vessel_for_unlock(id)
return unlock_definition.unlock_cost if unlock_definition != null else upgrade_cost(id)
func _advance_lab_research(delta: float) -> void:
for lab in buildings:
if not building_has_capability(lab, "vessel_research"):
@ -781,7 +789,7 @@ func _advance_lab_research(delta: float) -> void:
var order: Dictionary = orders[0]
var id: String = String(order.id)
var unlock_definition: Resource = vessel_for_unlock(id)
var cost: int = unlock_definition.unlock_cost if unlock_definition != null else upgrade_cost(id)
var cost: int = research_cost(id)
var inventory: RefCounted = _inventory_for_record(lab)
if not bool(order.started):
if inventory.amount(RESOURCE_ORE) < cost: