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>
24 lines
616 B
GDScript
24 lines
616 B
GDScript
extends "res://buildings/BuildingVisualBase.gd"
|
|
|
|
func _ready() -> void:
|
|
for part in SHIP_PARTS:
|
|
_hull_parts.append(PackedVector2Array(part.points))
|
|
_build_crafter_pieces()
|
|
queue_redraw()
|
|
|
|
# #117: the line runs when there is something on it. An idle crafter with
|
|
# its cranes swinging read as a factory working on nothing.
|
|
func is_working() -> bool:
|
|
var id: int = building_id()
|
|
if id == 0:
|
|
return false
|
|
var state: Node = _state()
|
|
return state != null and state.pending_orders(id) > 0
|
|
|
|
|
|
func apply_animation() -> void:
|
|
_animate_crafter()
|
|
|
|
func _draw() -> void:
|
|
register_draw()
|
|
_draw_crafter_static(self)
|