Integrate gauges into cockpit dashboard

This commit is contained in:
chindit committed 2026-10-03 09:40:36 +02:00
1 parent 0b79bf9b82
commit 53288b48c8
7 files changed
+213 -17

No files matched your search

@@ -0,0 +1,114 @@
class_name CockpitDashboardDetailing
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 = "DashboardDetailing"
_build_structural_frame()
_build_switch_banks()
func control_count() -> int:
return _control_count
func apply_screen_materials(dashboard: Node3D) -> void:
for screen_name: String in ["ResourcesScreen", "NavigationScreen", "IntegrityScreen"]:
var screen := dashboard.get_node_or_null(screen_name) as MeshInstance3D
if screen != null:
screen.material_override = _materials.instrument_screen
func _build_structural_frame() -> void:
CockpitMeshFactory.add_box(
"TopRail",
self,
Vector3(0.0, 0.255, 0.115),
Vector3(1.50, 0.055, 0.055),
_materials.dark_steel
)
CockpitMeshFactory.add_box(
"BottomRail",
self,
Vector3(0.0, -0.205, 0.115),
Vector3(1.50, 0.050, 0.055),
_materials.dark_steel
)
for x: float in [-0.755, 0.755]:
CockpitMeshFactory.add_box(
"SideRail",
self,
Vector3(x, 0.025, 0.115),
Vector3(0.050, 0.46, 0.055),
_materials.dark_steel
)
for x: float in [-0.238, 0.238]:
CockpitMeshFactory.add_box(
"ScreenSeparator",
self,
Vector3(x, 0.015, 0.118),
Vector3(0.038, 0.39, 0.048),
_materials.brass
)
for screw_position: Vector2 in [
Vector2(-0.72, -0.18),
Vector2(-0.72, 0.23),
Vector2(0.72, -0.18),
Vector2(0.72, 0.23),
Vector2(-0.24, -0.18),
Vector2(0.24, -0.18),
]:
CockpitMeshFactory.add_cylinder(
"PanelScrew",
self,
Vector3(screw_position.x, screw_position.y, 0.151),
0.010,
0.010,
_materials.brass,
Vector3(90.0, 0.0, 0.0)
)
func _build_switch_banks() -> void:
_add_switch_bank(-0.59, "AUX")
_add_switch_bank(0.59, "POMPES")
func _add_switch_bank(center_x: float, caption: String) -> void:
CockpitMeshFactory.add_box(
"SwitchPlate",
self,
Vector3(center_x, -0.205, 0.145),
Vector3(0.25, 0.060, 0.020),
_materials.overhead_steel
)
for offset: float in [-0.075, -0.025, 0.025, 0.075]:
CockpitMeshFactory.add_cylinder(
"ToggleSwitch",
self,
Vector3(center_x + offset, -0.195, 0.171),
0.006,
0.030,
_materials.dark_steel,
Vector3(90.0, 0.0, 0.0)
)
_control_count += 1
var label := Label3D.new()
label.name = "%sLabel" % caption.to_pascal_case()
label.text = caption
label.font_size = 10
label.pixel_size = 0.00055
label.modulate = Color(0.72, 0.69, 0.56)
label.position = Vector3(center_x, -0.235, 0.165)
add_child(label)