#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:
parent
f9ed46746d
commit
39ad050dc6
5 changed files with 146 additions and 2 deletions
|
|
@ -30,10 +30,11 @@ var stage: int = 0
|
|||
var elapsed: float = 0.0
|
||||
var crane_x_start: float = 0.0
|
||||
var satellite_rotation_start: float = 0.0
|
||||
var game_state: Node
|
||||
|
||||
|
||||
func _initialize() -> void:
|
||||
var game_state: Node = root.get_node("GameState")
|
||||
game_state = root.get_node("GameState")
|
||||
game_state.buildings.clear()
|
||||
game_state.extractors.clear()
|
||||
scene = load("res://world/Main.tscn").instantiate()
|
||||
|
|
@ -71,6 +72,10 @@ func _process(delta: float) -> bool:
|
|||
quit(1)
|
||||
return true
|
||||
|
||||
# #117: an idle crafter holds its clock, so there would be no
|
||||
# animation to measure the cost of. The point of this test is
|
||||
# that animating is CHEAP, not that it happens unprompted.
|
||||
game_state.queue_order(int(_crafter_id(field)), GameState.VESSEL_INTERCEPTOR)
|
||||
crane_x_start = crafter._crane.position.x
|
||||
satellite_rotation_start = mothership._satellites.rotation
|
||||
elapsed = 0.0
|
||||
|
|
@ -108,3 +113,10 @@ func _process(delta: float) -> bool:
|
|||
quit(0)
|
||||
return true
|
||||
return false
|
||||
|
||||
|
||||
func _crafter_id(building_field: Node) -> int:
|
||||
for b in building_field.spawned:
|
||||
if is_instance_valid(b) and b.building_type == GameState.BUILDING_SHIP_CRAFTER:
|
||||
return int(b.building_id)
|
||||
return 0
|
||||
|
|
|
|||
Loading…
Reference in a new issue