Files
car-os/widgets/base_widget_node.gd
T

48 lines
1.1 KiB
GDScript
Raw Normal View History

2026-07-04 18:22:23 -06:00
extends Node2D
class_name BaseWidgetNode
var sensor_class: String
var used_sensors: Dictionary = {}
var host_vehicle: VehicleNode
var timer: float = 0.
static var timer_1_60: float = 1/60
2026-07-04 18:22:23 -06:00
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
Signals.vehicle_added.connect(_on_vehicle_added)
Signals.requested_host_vehicle.emit(self)
func _process(delta: float):
timer += delta
2026-07-04 18:22:23 -06:00
if host_vehicle != null:
if timer < timer_1_60:
return
timer = 0
_update_data()
2026-07-04 18:22:23 -06:00
return
Signals.requested_host_vehicle.emit(self)
func _update_data():
pass
2026-07-04 18:22:23 -06:00
func _on_vehicle_added(new_vehicle):
host_vehicle = new_vehicle
func set_host_vehicle(new_vehicle):
host_vehicle = new_vehicle
func check_valid_sensor(sensor_ip: String, sensor_class: String):
if host_vehicle == null:
return false
if sensor_ip not in host_vehicle.sensor_suites:
return false
if sensor_class == null:
return true
if sensor_class not in host_vehicle.sensor_classes:
return false
if sensor_ip not in host_vehicle.sensor_classes[sensor_class]:
return false
return true