36 lines
831 B
GDScript
36 lines
831 B
GDScript
class_name VehicleCommand
|
|
extends RefCounted
|
|
|
|
var sequence: int
|
|
var longitudinal: float
|
|
var steering: float
|
|
var vertical: float
|
|
var high_thrust_active: bool
|
|
|
|
|
|
func _init(
|
|
p_sequence: int,
|
|
p_longitudinal: float,
|
|
p_steering: float,
|
|
p_vertical: float,
|
|
p_high_thrust_active: bool
|
|
) -> void:
|
|
sequence = p_sequence
|
|
longitudinal = p_longitudinal
|
|
steering = p_steering
|
|
vertical = p_vertical
|
|
high_thrust_active = p_high_thrust_active
|
|
|
|
|
|
func validation_error() -> String:
|
|
if sequence < 0:
|
|
return "vehicle command sequence is negative"
|
|
for value: float in [longitudinal, steering, vertical]:
|
|
if not is_finite(value) or value < -1.0 or value > 1.0:
|
|
return "vehicle command axes must be finite and normalized"
|
|
return ""
|
|
|
|
|
|
static func neutral(p_sequence: int) -> VehicleCommand:
|
|
return new(p_sequence, 0.0, 0.0, 0.0, false)
|