Compare commits

...
Author SHA1 Message Date
Loïc Wisniewski
18a7d44db4 Make shield vessels unarmed hexagons 2026-08-14 22:46:30 +02:00
Loïc Wisniewski
3fc04f816a Supply lab research with transporters 2026-08-14 22:46:25 +02:00
6 changed files with 76 additions and 6 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:

View file

@ -29,6 +29,7 @@ enum Icon {
GAS,
LEFT_ARROW, RIGHT_ARROW,
MINUS, PLUS,
SHIELD_VESSEL,
}
# Size the glyphs were originally drawn against. Every glyph dimension is
@ -213,6 +214,8 @@ func _draw() -> void:
_draw_minus(center, pulse, s)
Icon.PLUS:
_draw_plus(center, pulse, s)
Icon.SHIELD_VESSEL:
_draw_shield_vessel(center, pulse, s)
func _draw_close(center: Vector2, pulse: float, s: float) -> void:
@ -229,6 +232,14 @@ func _draw_ship(center: Vector2, pulse: float, s: float) -> void:
NeonDraw.draw_glowing_polygon(self, points, _active_color(), pulse, core_color)
func _draw_shield_vessel(center: Vector2, pulse: float, s: float) -> void:
var points: PackedVector2Array = PackedVector2Array()
for i in range(6):
var angle: float = -PI / 2.0 + float(i) * TAU / 6.0
points.append(center + Vector2(cos(angle), sin(angle)) * 11.0 * s)
NeonDraw.draw_glowing_polygon(self, points, _active_color(), pulse, core_color)
func _draw_arrow(center: Vector2, pulse: float, direction: float, s: float) -> void:
var r: float = 9.0 * s
var tip: Vector2 = center + Vector2(0, r * direction)

View file

@ -1,6 +1,5 @@
[gd_resource type="Resource" script_class="VesselDefinition" load_steps=7 format=3]
[gd_resource type="Resource" script_class="VesselDefinition" load_steps=6 format=3]
[ext_resource type="Script" path="res://VesselDefinition.gd" id="1"]
[ext_resource type="PackedScene" path="res://VesselWeaponComponent.tscn" id="2"]
[ext_resource type="PackedScene" path="res://VesselShieldComponent.tscn" id="3"]
[ext_resource type="Resource" path="res://ShieldHitsUpgrade.tres" id="4"]
[ext_resource type="Resource" path="res://ShieldRechargeUpgrade.tres" id="5"]
@ -12,10 +11,11 @@ display_name = "Shield Vessel"
description = "Combat vessel whose rechargeable personal shield absorbs lethal impacts."
build_cost = 14
build_time = 16.0
icon = 2
icon = 30
glow_color = Color(0.45, 0.8, 1, 1)
capabilities = PackedStringArray("weapon", "shield")
component_scenes = Array[PackedScene]([ExtResource("2"), ExtResource("3")])
capabilities = PackedStringArray("shield")
component_scenes = Array[PackedScene]([ExtResource("3")])
hull_points = PackedVector2Array(0, -24, 20.7846, -12, 20.7846, 12, 0, 24, -20.7846, 12, -20.7846, -12)
base_stats = {"damage": 1.0, "fire_cooldown": 0.5, "fire_range": 320.0, "max_speed": 460.0, "acceleration": 450.0, "shield_charges": 1.0, "shield_recharge": 6.0, "delivery_speed": 180.0}
minimum_stats = {"shield_recharge": 2.0}
upgrades = Array[Resource]([ExtResource("4"), ExtResource("5"), ExtResource("6")])

View file

@ -0,0 +1,46 @@
extends SceneTree
var state: Node
var lab_id: int
var elapsed: float = 0.0
func _initialize() -> void:
state = root.get_node("GameState")
state.buildings.clear()
state.extractors.clear()
state.transporters.clear()
state.reset_progression()
state.rocks = 100
state.build_time_scale = 0.02
state.add_building(state.BUILDING_MOTHERSHIP, Vector2.ZERO)
var hub_id: int = state.add_building(state.BUILDING_TRANSPORT_HUB, Vector2(50, 0))
lab_id = state.add_building(state.BUILDING_SHIP_LAB, Vector2(100, 0))
state.transporters.append({"hub_id": hub_id, "state": state.TRANSPORTER_IDLE,
"target_id": 0, "extractor_index": -1, "carrying": 0, "progress": 1.0,
"from": Vector2(50, 0), "to": Vector2(50, 0)})
if not state.queue_lab_research(lab_id, "int_damage"):
return _fail("could not queue lab research")
if state.outstanding_cost(lab_id) != state.upgrade_cost("int_damage"):
return _fail("queued research did not expose its ore demand")
func _process(delta: float) -> bool:
elapsed += delta
if state.upgrade_level("int_damage") == 1:
if state.lab_research_order(lab_id).is_empty():
print("transporter supplied queued lab research end to end")
print("TEST_LAB_TRANSPORTER_DELIVERY: PASS")
quit(0)
return true
if elapsed > 5.0:
return _fail("lab still waiting: demand=%d transporter=%s stock=%d" % [
state.outstanding_cost(lab_id), state.transporters[0].state,
state.building_stock(lab_id)])
return false
func _fail(message: String) -> bool:
print("TEST_LAB_TRANSPORTER_DELIVERY: FAIL (%s)" % message)
quit(1)
return true

View file

@ -0,0 +1 @@
uid://dmw83vfmot52d

View file

@ -37,6 +37,10 @@ func _process(delta: float) -> bool:
return _fail("%s metadata did not come from its definition" % definition.definition_id)
if ships[0].has_capability("shield") or not ships[1].has_capability("shield"):
return _fail("shield behavior is not controlled by component presence")
if (ships[1].has_capability("weapon")
or definitions[1].hull_points.size() != 6
or definitions[1].icon != IconButton.Icon.SHIELD_VESSEL):
return _fail("shield vessel is not an unarmed hexagon")
if ships[2].has_capability("weapon") or not ships[2].has_capability("transport"):
return _fail("transporter capabilities were composed incorrectly")
print("TEST_VESSEL_COMPOSITION: PASS")