Files
Ransom-s-wake/game/presentation/cockpit/cockpit_alert_box.gd
T
OlivierandClaude Opus 5.5 2c1ea50aba
Quality Gate / Quality Gate (pull_request) Successful in 7m6s
feat(cockpit): replace procedural cockpit with twelve scripted models
Instance twelve Blender-scripted glTF models in the cockpit scene and
rebuild the cabin around them: gauge panel, sonar, switch panel, alert
box, speaker, porthole, hull wall, caged lamps, gas bottle, handrails
and side consoles. Presentation only; no domain, application or world
rule changes beyond enabling glow in the test environment.

- Needles, alert lamps and sonar screen are driven by the existing
  snapshots; the alert box now carries SYS/ATTN/ALRM.
- Depth dial reads percent of certified depth.
- Sonar display restyled as a turquoise holographic relief with a
  shader grid and height scale; SubViewport matches the glass (960x604).
- Cabin lighting retuned: warm pooled lamp light, cool porthole rim,
  lamp shadows, dial backlight.
- Procedural stand-ins removed (bulkhead, tanks, consoles, levers,
  indicator columns, placeholder pipe run, dial face PNGs).
- Tests adapted where nodes disappeared; one assertion removed
  (pipe_segment_count) until the pipe kit is placed.
- Model .glb files are committed without LFS; textures Godot extracts
  next to them at import are ignored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 21:46:46 +02:00

63 lines
2.0 KiB
GDScript

class_name CockpitAlertBox
extends Node3D
## Drives the three lamps of the imported alert box model. Exactly one lamp is
## lit for the alert level carried by the dive snapshot; the lamps are also
## distinguished by position and by their engraved ALERTE / ATTENTION / DANGER
## plates, so the reading does not depend on colour alone.
const DiveAlertLevel = preload("res://game/domain/dive/dive_alert_level.gd")
const CockpitMeshFactory = preload("res://game/presentation/cockpit/cockpit_mesh_factory.gd")
const LAMP_NAMES: Array[String] = ["Lamp_Alerte", "Lamp_Attention", "Lamp_Danger"]
const LIT_ENERGY := 4.0
const UNLIT_ENERGY := 0.0
var _lamp_materials: Array[BaseMaterial3D] = []
func _ready() -> void:
for lamp_name: String in LAMP_NAMES:
var lamp := find_child(lamp_name, true, false) as MeshInstance3D
var material := CockpitMeshFactory.own_surface_material(lamp)
if material == null:
push_error("Alert box model has no usable %s lamp" % lamp_name)
continue
material.emission_energy_multiplier = UNLIT_ENERGY
_lamp_materials.append(material)
func present(alert_level: DiveAlertLevel.Value) -> void:
var active_index := _lamp_index_for(alert_level)
for lamp_index in _lamp_materials.size():
_lamp_materials[lamp_index].emission_energy_multiplier = (
LIT_ENERGY if lamp_index == active_index else UNLIT_ENERGY
)
func indicator_count() -> int:
return _lamp_materials.size()
func active_indicator_count() -> int:
var count := 0
for material: BaseMaterial3D in _lamp_materials:
if material.emission_energy_multiplier > UNLIT_ENERGY:
count += 1
return count
func active_indicator_name() -> String:
for lamp_index in _lamp_materials.size():
if _lamp_materials[lamp_index].emission_energy_multiplier > UNLIT_ENERGY:
return LAMP_NAMES[lamp_index]
return ""
func _lamp_index_for(alert_level: DiveAlertLevel.Value) -> int:
if alert_level >= DiveAlertLevel.Value.CRITICAL:
return 2
if alert_level >= DiveAlertLevel.Value.ATTENTION:
return 1
return 0