39 lines
1.1 KiB
GDScript
39 lines
1.1 KiB
GDScript
class_name DiveTelemetrySample
|
|
extends RefCounted
|
|
|
|
var depth_m: float
|
|
var longitudinal_effort: float
|
|
var steering_effort: float
|
|
var vertical_effort: float
|
|
var high_thrust_active: bool
|
|
|
|
|
|
func _init(
|
|
p_depth_m: float = 0.0,
|
|
p_longitudinal_effort: float = 0.0,
|
|
p_steering_effort: float = 0.0,
|
|
p_vertical_effort: float = 0.0,
|
|
p_high_thrust_active: bool = false
|
|
) -> void:
|
|
depth_m = p_depth_m
|
|
longitudinal_effort = p_longitudinal_effort
|
|
steering_effort = p_steering_effort
|
|
vertical_effort = p_vertical_effort
|
|
high_thrust_active = p_high_thrust_active
|
|
|
|
|
|
func validation_error() -> String:
|
|
if not is_finite(depth_m) or depth_m < 0.0:
|
|
return "telemetry depth must be finite and non-negative"
|
|
if not _is_normalized(longitudinal_effort):
|
|
return "longitudinal effort must be between -1 and 1"
|
|
if not _is_normalized(steering_effort):
|
|
return "steering effort must be between -1 and 1"
|
|
if not _is_normalized(vertical_effort):
|
|
return "vertical effort must be between -1 and 1"
|
|
return ""
|
|
|
|
|
|
func _is_normalized(value: float) -> bool:
|
|
return is_finite(value) and value >= -1.0 and value <= 1.0
|