Files
Diabolo/Demon_v0.19/room_decor_tests.gd

33 lines
2.4 KiB
GDScript

extends RefCounted
var failures=0
func check(ok,label):
if not ok:failures+=1;push_error("ROOM DECOR QA: "+label)
func shot(g,name):
await g.get_tree().process_frame;await RenderingServer.frame_post_draw
g.get_viewport().get_texture().get_image().save_png("res://captures/clean-room/"+name+".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
var a=g.architecture;var w=g.workshop;var station=w.add_station(0,Vector3(3,0,0))
check(g.get_meta("dressing_parts")==0 and a.growth.wall_dressing.is_empty(),"tables shelves pipes and miscellaneous dressing removed")
check(a.braziers.size()==6,"exactly six grouped room braziers")
DirAccess.make_dir_recursive_absolute("res://captures/clean-room")
for rank in range(4):
w.expansion_level=rank;a.growth.set_level(rank);w.make_grid()
var left=-7.95;var right=a.growth.right_edge();var center=(left+right)*.5
var positions=a.braziers.map(func(b):return b.position)
for b in a.braziers:
check(positions.any(func(p):return p.distance_to(Vector3(left+right-b.position.x,0,b.position.z))<.001),"left/right symmetry rank %d"%rank)
check(positions.any(func(p):return p.distance_to(Vector3(b.position.x,0,-b.position.z))<.001),"front/back symmetry rank %d"%rank)
check(not Rect2(w.ORIGIN,w.grid_area()).grow(.4).has_point(Vector2(b.position.x,b.position.z)),"brazier clears construction cells")
var lights=b.find_children("*","OmniLight3D",true,false)
check(lights.size()==1 and lights[0].global_position.distance_to(b.position+Vector3(0,1.45,0))<.001,"light follows brazier on growth")
check(b.find_children("*","GPUParticles3D",true,false).all(func(p):return p.local_coords),"embers stay attached during growth")
check(positions.filter(func(p):return absf(p.x-center)<.001).size()==2,"two central wall braziers")
check(is_instance_valid(station.device) and station.device.position==Vector3(3,0,0),"purchased apparatus unaffected")
g.camera.position=Vector3(20,26,32);g.camera.look_at(Vector3(center,0,0));g.camera.size=29+rank*2;a.update(g.camera);g.hud.hide();g.player.hide()
for imp in g.life.imps:imp.root.hide()
await shot(g,"rank-%d"%rank)
print("ROOM DECOR QA ","PASSED" if failures==0 else "FAILED",": no clutter, six braziers, four growth ranks, mirrored corners and wall centers, moving lights and clear placement zone")
g.get_tree().quit(1 if failures else 0)