spaceship/VesselDefinitions.gd
Loïc Wisniewski bbb1d4b0c5 Add carrier vessel (#57)
An unarmed hauler with no weapon component - only VesselCargoComponent,
so it structurally cannot fire, the same pattern that already made the
shield vessel weaponless after #35. Its cargo_capacity (120, six
interceptors' worth) makes it the first real payoff for #56's fleet
hold cap.

Wired into the crafter, hangar and ship lab menus, all of which were
already generic over VesselDefinitions.fleet()/.all() - only the
per-vessel UI *nodes* are hand-placed (Main.tscn), not the logic, so
this repacks those three button rows to 4/4/5 columns and extends
BuildController's matching onready arrays. No new signal handlers were
needed.

Also fixes test_vessel_composition.gd's hardcoded fleet-catalog size
(3 -> 4) now that a fourth vessel is fleet-eligible.
2026-08-16 16:20:39 +02:00

34 lines
1 KiB
GDScript

class_name VesselDefinitions
extends RefCounted
const ORDER: PackedStringArray = ["interceptor", "shield", "gas_bomber", "transporter", "carrier"]
const DEFINITIONS: Dictionary = {
"interceptor": preload("res://InterceptorVesselDefinition.tres"),
"shield": preload("res://ShieldVesselDefinition.tres"),
"gas_bomber": preload("res://GasBomberVesselDefinition.tres"),
"transporter": preload("res://TransporterVesselDefinition.tres"),
"carrier": preload("res://CarrierVesselDefinition.tres"),
}
static func get_definition(definition_id: String) -> Resource:
return DEFINITIONS.get(definition_id)
static func all() -> Array:
var result: Array = []
for definition_id in ORDER:
result.append(DEFINITIONS[definition_id])
return result
static func fleet() -> Array:
var result: Array = []
for definition in all():
if definition.fleet_eligible:
result.append(definition)
return result
static func with_capability(capability: String) -> Resource:
for definition in all():
if definition.has_capability(capability):
return definition
return null