class_name CockpitSonarConsole extends Node3D const CockpitMaterialPalette = preload( "res://game/presentation/cockpit/cockpit_material_palette.gd" ) const CockpitMeshFactory = preload( "res://game/presentation/cockpit/cockpit_mesh_factory.gd" ) var _materials: CockpitMaterialPalette var _control_count := 0 func _init(materials: CockpitMaterialPalette) -> void: _materials = materials name = "SonarConsoleDetailing" _build_bezel() _build_graticule() _build_control_strip() _build_mounting_hardware() func control_count() -> int: return _control_count func _build_bezel() -> void: CockpitMeshFactory.add_box( "UpperBezel", self, Vector3(-0.025, 0.151, 0.073), Vector3(0.41, 0.034, 0.035), _materials.brushed_steel ) CockpitMeshFactory.add_box( "LowerBezel", self, Vector3(-0.025, -0.126, 0.073), Vector3(0.41, 0.034, 0.035), _materials.brushed_steel ) for x: float in [-0.225, 0.175]: CockpitMeshFactory.add_box( "SideBezel", self, Vector3(x, 0.012, 0.073), Vector3(0.035, 0.31, 0.035), _materials.brushed_steel ) var label := Label3D.new() label.name = "SonarPlate" label.text = "SONAR · BATHYMÉTRIE" label.font_size = 12 label.pixel_size = 0.00062 label.modulate = Color(0.7, 0.73, 0.64) label.position = Vector3(-0.04, 0.156, 0.097) add_child(label) func _build_control_strip() -> void: CockpitMeshFactory.add_box( "ControlStrip", self, Vector3(0.235, 0.012, 0.072), Vector3(0.075, 0.31, 0.04), _materials.dark_steel ) var lamps: Array[StandardMaterial3D] = [ _materials.indicator_amber, _materials.indicator_amber, _materials.indicator_green, ] for index in 3: var y := 0.095 - index * 0.073 CockpitMeshFactory.add_box( "SonarLampBezel", self, Vector3(0.235, y, 0.101), Vector3(0.044, 0.044, 0.018), _materials.brass ) CockpitMeshFactory.add_sphere( "SonarLamp", self, Vector3(0.235, y, 0.116), 0.013, lamps[index] ) _control_count += 1 CockpitMeshFactory.add_cylinder( "SonarGainKnob", self, Vector3(0.235, -0.102, 0.108), 0.024, 0.026, _materials.rubber, Vector3(90.0, 0.0, 0.0) ) _control_count += 1 func _build_graticule() -> void: for x: float in [-0.145, -0.085, -0.025, 0.035, 0.095]: CockpitMeshFactory.add_box( "SonarGridVertical", self, Vector3(x, 0.012, 0.076), Vector3(0.0015, 0.215, 0.002), _materials.sonar_grid ) for y: float in [-0.075, -0.025, 0.025, 0.075]: CockpitMeshFactory.add_box( "SonarGridHorizontal", self, Vector3(-0.025, y, 0.076), Vector3(0.33, 0.0015, 0.002), _materials.sonar_grid ) var trace_points: Array[Vector3] = [ Vector3(-0.185, -0.035, 0.080), Vector3(-0.135, -0.020, 0.080), Vector3(-0.085, -0.055, 0.080), Vector3(-0.030, -0.005, 0.080), Vector3(0.025, -0.030, 0.080), Vector3(0.075, 0.030, 0.080), Vector3(0.125, 0.075, 0.080), ] for point_index in trace_points.size() - 1: CockpitMeshFactory.add_cylinder_between( "SonarReferenceTrace", self, trace_points[point_index], trace_points[point_index + 1], 0.0025, _materials.sonar_trace ) func _build_mounting_hardware() -> void: for corner: Vector2 in [ Vector2(-0.205, -0.105), Vector2(-0.205, 0.13), Vector2(0.195, -0.105), Vector2(0.195, 0.13), ]: CockpitMeshFactory.add_cylinder( "SonarFastener", self, Vector3(corner.x, corner.y, 0.103), 0.008, 0.012, _materials.brass, Vector3(90.0, 0.0, 0.0) ) CockpitMeshFactory.add_cylinder_between( "LeftSonarHandle", self, Vector3(-0.255, -0.09, 0.06), Vector3(-0.255, 0.11, 0.06), 0.013, _materials.brass )