#117: the crafter and the lab animate only while they are working

A factory whose cranes swing over an empty cradle reads as working on
nothing, and a lab sweeping instruments over a vessel it is not studying
reads the same way.

The CLOCK stops rather than the drawing. Every moving element is a NeonPiece
whose position is pushed from that clock, so a frozen clock leaves the
building standing with its cranes parked; stopping apply_animation() instead
would leave them wherever the last frame happened to put them, which is not
the same thing as idle.

The state is read by tree lookup rather than through the bare `GameState`
identifier. These visual scripts are reached through a BuildingDefinition's
visual_scene, which is preloaded while the definition catalog is still
loading - early enough that the autoload is not in the global class table
yet, and a bare reference fails to COMPILE the whole file. That failure also
hung test_building_redraw_cost, because a visual that never built its pieces
left a null crane being dereferenced every frame.

Both animation tests now say what they mean: the redraw-cost test queues an
order first, because its point is that animating is cheap rather than that
it happens unprompted, and the crafter test additionally pins that an idle
crafter really is still.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Loïc Wisniewski 2026-08-23 21:58:59 +02:00
commit 39ad050dc6
5 changed files with 146 additions and 2 deletions

View file

@ -4,6 +4,16 @@ func _ready() -> void:
_build_lab_pieces()
queue_redraw()
# #117: the instruments sweep while something is being researched, and are
# parked otherwise.
func is_working() -> bool:
var id: int = building_id()
if id == 0:
return false
var state: Node = _state()
return state != null and not state.lab_research_order(id).is_empty()
func apply_animation() -> void:
_animate_ship_lab()