A manually aimed instant beam, modelled on the gas bomber's press-drag-
release aiming (GasBombController/VesselGasBomberComponent) but firing
the moment the touch releases - no projectile travel time. Damage,
beam_range and cooldown are resolved per ship from base_stats/upgrades
(VesselLaserComponent.apply_stats(), the same pattern
VesselWeaponComponent uses) rather than hardcoded in the controller, so
the new damage/range/cooldown ship-lab upgrades actually reach them.
Cooldown lives on the component (per ship), not the controller (per
fleet) - two laser ships give two shots, the exact bug already fixed
for bombers in eb79efd.
LaserController.gd is reused unmodified by both Main.tscn and
PlanetSurface.tscn (relative ../Fleet, ../Camera2D, ../UI/LaserButton
paths, matching GasBombController), so it works identically in space
and on a landed surface. Wired into GameController's touch/drag
first-refusal chain alongside the bomb controller.
The crafter, hangar and ship-lab menus were already generic over
VesselDefinitions.fleet()/.all() - only the per-vessel Main.tscn nodes
are hand-placed, not the logic - so this repacks those rows to
5/5/6 columns and extends BuildController's onready arrays. No new
signal handlers were needed. Also fixes test_vessel_composition.gd's
hardcoded fleet-catalog size again (4 -> 5) now that laser is a fifth
fleet-eligible vessel.
Note for later tickets: a brand-new class_name script (LaserController)
resolves fine as a static type when its own file is the godot -s entry
point, but the identical type hint fails to parse ("Could not find
type") when the script holding it is only reached indirectly - e.g.
Main.tscn loaded from inside a _screenshot_tool.gd preview. Untyped
Node + duck-typed calls sidesteps it; GameController.gd's
laser_controller field documents this in place.
64 lines
2.7 KiB
GDScript
64 lines
2.7 KiB
GDScript
extends SceneTree
|
|
|
|
const VESSEL_DEFINITIONS = preload("res://VesselDefinitions.gd")
|
|
|
|
var ships: Array = []
|
|
var elapsed: float = 0.0
|
|
var game_state: Node
|
|
|
|
|
|
func _initialize() -> void:
|
|
game_state = root.get_node("GameState")
|
|
var scene: PackedScene = load("res://Ship.tscn")
|
|
for definition in VESSEL_DEFINITIONS.all():
|
|
var ship: Area2D = scene.instantiate()
|
|
ship.vessel_type = definition.definition_id
|
|
root.add_child(ship)
|
|
ships.append(ship)
|
|
|
|
|
|
func _process(delta: float) -> bool:
|
|
elapsed += delta
|
|
if elapsed < 0.1:
|
|
return false
|
|
var definitions: Array = VESSEL_DEFINITIONS.all()
|
|
var fleet_definitions: Array = VESSEL_DEFINITIONS.fleet()
|
|
if fleet_definitions.size() != 5 \
|
|
or fleet_definitions.any(func(definition): return definition.has_capability("transport")):
|
|
return _fail("logistics transporters leaked into the combat-fleet catalog")
|
|
if ships.size() != definitions.size():
|
|
return _fail("catalog and composed fleet differ in size")
|
|
for i in range(definitions.size()):
|
|
var definition: Resource = definitions[i]
|
|
var ship: Node = ships[i]
|
|
if ship.definition == null or ship.definition.definition_id != definition.definition_id:
|
|
return _fail("%s did not resolve its definition" % definition.definition_id)
|
|
for capability in definition.capabilities:
|
|
if not ship.has_capability(capability):
|
|
return _fail("%s did not compose %s" % [definition.definition_id, capability])
|
|
if game_state.product_cost(definition.definition_id) != definition.build_cost \
|
|
or game_state.vessel_name(definition.definition_id) != definition.display_name:
|
|
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")
|
|
var gas_index: int = VESSEL_DEFINITIONS.ORDER.find(GameState.VESSEL_GAS_BOMBER)
|
|
if gas_index < 0 or ships[gas_index].has_capability("weapon") \
|
|
or not ships[gas_index].definition.has_capability("gas_bomber"):
|
|
return _fail("gas bomber is not an unarmed skill vessel")
|
|
var transporter_index: int = VESSEL_DEFINITIONS.ORDER.find(GameState.VESSEL_TRANSPORTER)
|
|
if ships[transporter_index].has_capability("weapon") \
|
|
or not ships[transporter_index].has_capability("transport"):
|
|
return _fail("transporter capabilities were composed incorrectly")
|
|
print("TEST_VESSEL_COMPOSITION: PASS")
|
|
quit(0)
|
|
return true
|
|
|
|
|
|
func _fail(message: String) -> bool:
|
|
print("TEST_VESSEL_COMPOSITION: FAIL (%s)" % message)
|
|
quit(1)
|
|
return true
|