spaceship/buildings/GasBurnerBuildingVisual.gd
Loïc Wisniewski 2f161621c3 #84: move 215 root files into a folder hierarchy
Everything lived in one flat directory, so a diff gave no clue what area it
touched and finding the file you wanted meant knowing its exact name. Twelve
folders now, grouped by what a thing IS rather than what type it is - a
vessel's definition, its component scenes and its upgrade resources sit
together, because that is the set you read when you change one of them.

  buildings  core  controllers  enemies  logistics  planets
  resources  shaders  surface  ui  vessels  vfx  world

332 files moved and every res:// reference rewritten - 306 files touched,
including the autoload and main-scene paths in project.godot. Nothing renamed:
this is purely where files sit, so the diff is a pile of pure moves and no
behaviour is buried in it. ui_theme.tres, icon.svg and web_shell.html stay at
the root, where Godot and the export preset expect them.

Verified three ways, because a suite alone would not have caught all of it:
the full 117 pass, the web export builds clean, and the game renders.

The export is why that matters. The FIRST export after the move failed with
"Attempt to open script 'res://GameState.gd'" - the old path - while
project.godot on disk plainly said res://core/GameState.gd. That is this
project's documented Android FUSE mtime trap: Godot served a cached copy of a
file whose content had changed. A `touch` fixed it. Nothing in the test suite
would have found that, because the suite runs from a copy on a native
filesystem - the one place the bug cannot happen.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-21 19:44:14 +02:00

45 lines
1.6 KiB
GDScript

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)