Queue lab research from local stock
This commit is contained in:
parent
798deb48a1
commit
e9acca569e
7 changed files with 137 additions and 27 deletions
50
GameState.gd
50
GameState.gd
|
|
@ -357,6 +357,7 @@ const BUILD_TIMES: Dictionary = {
|
|||
VESSEL_SHIELD: 16.0,
|
||||
VESSEL_TRANSPORTER: 8.0,
|
||||
}
|
||||
const LAB_RESEARCH_TIME: float = 8.0
|
||||
|
||||
|
||||
# Test seam. Headless tests need the timed path - queued, started, finishing
|
||||
|
|
@ -368,6 +369,10 @@ var build_time_scale: float = 1.0
|
|||
func build_time(product: String) -> float:
|
||||
return float(BUILD_TIMES.get(product, 10.0)) * build_time_scale
|
||||
|
||||
|
||||
func lab_research_time() -> float:
|
||||
return LAB_RESEARCH_TIME * build_time_scale
|
||||
|
||||
# Researched at the ship lab, per vessel type. Separate from SKILL_TREE on
|
||||
# purpose: that gates what the player may build at all and is a strategic
|
||||
# spine, while these are repeatable tuning on a vessel you already have.
|
||||
|
|
@ -712,6 +717,50 @@ func _advance_production(delta: float) -> void:
|
|||
order_completed.emit(int(b.id), product)
|
||||
|
||||
|
||||
func queue_lab_research(lab_id: int, upgrade_id: String) -> bool:
|
||||
var lab: Dictionary = find_building(lab_id)
|
||||
if lab.is_empty() or lab.type != BUILDING_SHIP_LAB or upgrade_id == "":
|
||||
return false
|
||||
var orders: Array = lab.get("research_orders", [])
|
||||
if not orders.is_empty() or (upgrade_id != UNLOCK_SHIELD_VESSEL and upgrade_maxed(upgrade_id)):
|
||||
return false
|
||||
orders.append({"id": upgrade_id, "elapsed": 0.0, "started": false})
|
||||
lab.research_orders = orders
|
||||
return true
|
||||
|
||||
|
||||
func lab_research_order(lab_id: int) -> Dictionary:
|
||||
var lab: Dictionary = find_building(lab_id)
|
||||
var orders: Array = lab.get("research_orders", [])
|
||||
return {} if orders.is_empty() else orders[0]
|
||||
|
||||
|
||||
func _advance_lab_research(delta: float) -> void:
|
||||
for lab in buildings:
|
||||
if lab.type != BUILDING_SHIP_LAB:
|
||||
continue
|
||||
var orders: Array = lab.get("research_orders", [])
|
||||
if orders.is_empty():
|
||||
continue
|
||||
var order: Dictionary = orders[0]
|
||||
var id: String = String(order.id)
|
||||
var cost: int = UNLOCK_SHIELD_COST if id == UNLOCK_SHIELD_VESSEL else upgrade_cost(id)
|
||||
if not bool(order.started):
|
||||
if int(lab.get("stock", 0)) < cost:
|
||||
continue
|
||||
lab.stock = int(lab.stock) - cost
|
||||
order.started = true
|
||||
order.elapsed = float(order.elapsed) + delta
|
||||
if float(order.elapsed) < lab_research_time():
|
||||
continue
|
||||
if id == UNLOCK_SHIELD_VESSEL:
|
||||
vessel_levels[id] = 1
|
||||
else:
|
||||
vessel_levels[id] = upgrade_level(id) + 1
|
||||
vessel_upgraded.emit(id)
|
||||
orders.pop_front()
|
||||
|
||||
|
||||
func claim_stored_vessel(index: int) -> String:
|
||||
# Hands one finished vessel over to be crewed. Returns its type, or ""
|
||||
# when there is nothing there - the caller decides whether the fleet
|
||||
|
|
@ -829,6 +878,7 @@ func _process(delta: float) -> void:
|
|||
# Runs in the autoload, so mining and transport continue while the player
|
||||
# is on a planet's surface or nowhere near either.
|
||||
_advance_production(delta)
|
||||
_advance_lab_research(delta)
|
||||
_advance_vessel_deliveries(delta)
|
||||
for e in extractors:
|
||||
e.mining_progress = float(e.get("mining_progress", 0.0)) + delta * EXTRACTOR_RATE
|
||||
|
|
|
|||
Loading…
Reference in a new issue