extends "res://buildings/BuildingVisualBase.gd" # Drawn once, not per frame - the burner has no animation. It does have two # LOOKS though (#78): lit while it is converting, cold while the player has # paused it. A one-shot draw plus a redraw on the state signal keeps that free. # # GameState is reached through the tree rather than by its global autoload # name. This script is compiled as part of a preload chain from # BuildingDefinitions, which can happen before autoloads are registered - a # bare `GameState` reference here failed to compile outright, taking the whole # visual with it. Same hazard PlanetSetups and PlanetSurfaceController already # work around, and the same fix. func _state() -> Node: return get_tree().root.get_node_or_null("GameState") func _ready() -> void: set_process(false) var state: Node = _state() if state != null: state.building_paused_changed.connect(_on_building_paused_changed) queue_redraw() func _on_building_paused_changed(id: int, _paused: bool) -> void: if id == _own_building_id(): queue_redraw() # The visual sits under Building/VisualHost, so its owner is two levels up. # Asked for rather than stored, because the visual is instantiated before the # Building node has finished setting its own id. func _own_building_id() -> int: var host: Node = get_parent() var building: Node = host.get_parent() if host != null else null return int(building.building_id) if building != null and "building_id" in building else 0 func _draw() -> void: register_draw() var state: Node = _state() var paused: bool = state != null and state.is_building_paused(_own_building_id()) _draw_gas_burner_static(self, paused)