extends SceneTree # A logistics vessel is ONE vessel, so it looks the same wherever it is drawn. # # #216 made transporters and repair drones fly out from the mothership as # ordinary vessel deliveries. A delivery draws the hull off the vessel # DEFINITION; the stationed nodes each drew a copy written into their own # script. The copies had drifted - the transporter's definition declared no # hull at all, so one in flight was an empty polygon, and the drone's two # shapes differed by a couple of units - which is why a transporter changed # shape the moment it was assigned. # # Covers: # A. every vessel that can be delivered declares a hull to be drawn by # B. the stationed node draws that same hull, not a second copy # C. and the colours agree, so it does not change livery either const DELIVERABLE: Array = ["transporter", "repair_drone"] func _initialize() -> void: var definitions: Script = load("res://vessels/VesselDefinitions.gd") var nodes: Dictionary = { "transporter": load("res://logistics/Transporter.gd"), "repair_drone": load("res://logistics/RepairDrone.gd"), } for vessel_type in DELIVERABLE: var definition: Resource = definitions.get_definition(vessel_type) if definition == null: return _fail("no definition for '%s'" % vessel_type) # --- A. there is a hull at all ------------------------------- # An empty one is not a small bug: VesselDelivery draws exactly this, # so a vessel with no hull is invisible for the whole flight. if definition.hull_points.is_empty(): return _fail("'%s' declares no hull, so it is invisible in flight" % vessel_type) # --- B. and the stationed node draws that one ---------------- var node: Node2D = nodes[vessel_type].new() root.add_child(node) var drawn: PackedVector2Array = node._hull() node.free() if drawn != definition.hull_points: return _fail("'%s' is drawn as %s at its post and %s in flight" \ % [vessel_type, drawn, definition.hull_points]) # --- C. same livery too --------------------------------------- var node_colour: Color = nodes[vessel_type].HULL_COLOR var definition_colour: Color = definition.glow_color if not is_equal_approx(node_colour.r, definition_colour.r) \ or not is_equal_approx(node_colour.g, definition_colour.g) \ or not is_equal_approx(node_colour.b, definition_colour.b): return _fail("'%s' is %s at its post and %s in flight" \ % [vessel_type, node_colour, definition_colour]) print("%s: one hull of %d points, one colour, both places" \ % [vessel_type, definition.hull_points.size()]) print("TEST_LOGISTICS_HULL_IDENTITY: PASS") quit(0) func _fail(message: String) -> void: print("TEST_LOGISTICS_HULL_IDENTITY: FAIL (%s)" % message) quit(1)