2026-10-28 15:39:06 +02:00
extends RefCounted
var failures = 0
func check ( ok , label ) :
if not ok : failures + = 1 ; push_error ( " MAINTENANCE QA: " + label )
func shot ( g , label ) :
await g . get_tree ( ) . process_frame
await RenderingServer . frame_post_draw
g . get_viewport ( ) . get_texture ( ) . get_image ( ) . save_png ( " res://captures/maintenance/ " + label + " .png " )
func run ( g ) :
await g . get_tree ( ) . create_timer ( . 3 ) . timeout
g . start_game ( ) ; g . set_process ( false ) ; g . reset_shift ( ) ; g . game_started = true ; g . paused = false
DirAccess . make_dir_recursive_absolute ( " res://captures/maintenance " )
var w = g . workshop ; var d = w . add_station ( 0 , Vector3 . ZERO ) ; g . coins = 3000 ; w . rebuild_nav ( )
w . toggle_build ( )
for rank in range ( 4 ) :
if rank > 0 : w . purchase_expansion ( )
var plane = w . grid . get_child ( 0 )
check ( plane . mesh is PlaneMesh and plane . scale == Vector3 . ONE , " grid is unscaled world-space plane rank %d " %rank )
check ( plane . material_override . get_shader_parameter ( " grid_origin " ) == w . ORIGIN , " grid origin unchanged " )
check ( plane . material_override . get_shader_parameter ( " grid_area " ) == w . grid_area ( ) , " grid matches whole-cell placement boundary " )
check ( w . snap_to_grid ( Vector3 ( 4.2 , 0 , 2.4 ) , 0 ) == Vector3 ( 4 , 0 , 2 ) , " placement lattice unchanged " )
g . camera . position = Vector3 ( 18 , 24 , 30 ) ; g . camera . look_at ( Vector3 ( 6 , 0 , 0 ) ) ; g . camera . size = 30 ; g . architecture . update ( g . camera )
await shot ( g , " grid- %d " %rank )
var point = g . camera . unproject_position ( Vector3 . ZERO ) ; w . pointer_position = point ; w . drag . left_down = true ; w . drag . arm ( 0 , point ) ; w . drag . update ( . 5 )
check ( w . drag . hold_ring . visible and is_equal_approx ( w . drag . hold_ring . progress , . 5 ) and not w . drag . active , " half-filled circle before drag " )
var size = g . get_viewport ( ) . get_visible_rect ( ) . size
var old = clampf ( DisplayServer . screen_get_dpi ( ) / 2.54 * size . y / maxf ( 1 , DisplayServer . window_get_size ( ) . y ) , 28 , 64 )
check ( is_equal_approx ( w . drag . thickness , old * 1.25 * 1.25 ) , " delete strip increased another 25 percent " )
await shot ( g , " hold-half " )
w . pointer_position = point ; w . drag . left_down = true ; w . drag . update ( . 51 ) ; check ( w . drag . active and not w . drag . hold_ring . visible and w . drag . strip . visible , " ring hands off to dragging at one second " )
await shot ( g , " delete-strip " ) ; w . cancel_placement ( ) ; w . drag . cancel ( ) ; w . drag . left_down = false
w . drag . arm ( 0 , point ) ; w . drag . cancel ( ) ; check ( not w . drag . hold_ring . visible , " cancel hides countdown " )
w . toggle_build ( ) ; g . paused = false ; g . hud . hide ( ) ; g . player . hide ( )
var activities = g . life . activities ; var imp = g . life . imps [ 0 ]
for kind in [ " clean " , " mop " , " draw " , " hum " ] :
activities . finish ( imp ) ; activities . start ( imp , kind ) ; imp . root . position = imp . activity_target
activities . update ( imp , . 2 )
check ( imp . activity == kind and is_instance_valid ( imp . activity_props ) , " activity starts with real props: " + kind )
var before = imp . model . get_node ( " ArmR " ) . rotation
2026-10-28 23:04:47 +02:00
activities . update ( imp , . 3 ) ; imp . gait . update ( . 05 , true )
2026-10-28 15:39:06 +02:00
check ( imp . model . get_node ( " ArmR " ) . rotation != before , " activity animates: " + kind )
g . camera . position = imp . root . position + Vector3 ( 3 , 2.4 , 4 ) ; g . camera . look_at ( imp . root . position + Vector3 ( 0 , . 6 , 0 ) ) ; g . camera . size = 3.5
if kind == " draw " :
2026-10-28 23:04:47 +02:00
activities . update ( imp , 3.5 ) ; imp . gait . update ( . 05 , true )
2026-10-28 15:39:06 +02:00
check ( imp . activity_mark . edges . all ( func ( edge ) : return edge . node . visible ) , " pentagram is drawn in five strokes " )
for node in g . architecture . walls : node . show ( )
g . camera . position = imp . root . position + Vector3 ( 3 , 1.5 , 2 ) ; g . camera . look_at ( imp . root . position + Vector3 ( - . 3 , . 7 , 0 ) )
await shot ( g , kind )
activities . update ( imp , 6 ) ; check ( imp . activity == " " and not imp . humming . playing , " activity finishes and cleans props: " + kind )
activities . start ( imp , " clean " ) ; imp . root . position = imp . activity_target ; d . soul = 999
activities . update ( imp , . 1 ) ; check ( imp . activity == " " , " occupied equipment cancels cleaning " ) ; d . soul = - 1
activities . start ( imp , " hum " ) ; imp . root . position = imp . activity_target ; g . test_mode = false ; activities . update ( imp , . 05 )
await g . get_tree ( ) . create_timer ( . 1 ) . timeout
check ( imp . humming . playing , " real quiet humming plays " )
g . paused = true ; var clock = imp . activity_time ; w . update ( . 5 )
check ( imp . humming . stream_paused and imp . activity_time == clock , " pause freezes activity and humming " )
g . muted = true ; activities . sync_audio ( imp ) ; check ( not imp . humming . playing , " mute stops humming " )
g . muted = false ; g . test_mode = true ; g . paused = false ; activities . reset ( )
check ( activities . marks . is_empty ( ) and g . life . imps . all ( func ( i ) : return i . activity == " " ) , " reset clears activities and wall chalk " )
print ( " MAINTENANCE QA " , " PASSED " if failures == 0 else " FAILED " , " : expanded grid, hold countdown, taller strip, four activities, interruption, audio, pause and cleanup " )
g . get_tree ( ) . quit ( 1 if failures else 0 )