Files
Ransom-s-wake/game/presentation/cockpit/cockpit_sonar_console.gd
T

146 lines
3.0 KiB
GDScript

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_grid()
_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_grid() -> 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
)
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
)