extends SceneTree var results: Array=[] var failures:=0 func _initialize() -> void:call_deferred("run") func check(name: String,ok: bool,detail: Dictionary={}) -> void: results.append({"name":name,"passed":ok,"detail":detail.duplicate(true)}) if not ok:failures+=1 print(("PASS " if ok else "FAIL ")+name+" "+JSON.stringify(detail)) func click_screen(screen: Vector2) -> void: var event:=InputEventMouseButton.new() event.button_index=MOUSE_BUTTON_LEFT;event.button_mask=MOUSE_BUTTON_MASK_LEFT;event.pressed=true;event.position=screen root.push_input(event,true) await process_frame event=InputEventMouseButton.new();event.button_index=MOUSE_BUTTON_LEFT;event.pressed=false;event.position=screen root.push_input(event,true) await process_frame func click_world(app,point: Vector3) -> void: await click_screen(app.camera.unproject_position(point)) func click_control(control: Control) -> void: await click_screen(control.get_global_rect().get_center()) func settle() -> void: await physics_frame await physics_frame func has_bottom(app,at: Vector3,kind: String="wall") -> bool: return app.records.any(func(r):return r.kind==kind and app.placement.bottom_of(r).is_equal_approx(at)) func run() -> void: var app=load("res://designer/scenes/workshop.tscn").instantiate();root.add_child(app) await settle() root.notify_mouse_entered() check("visible_ground_is_y_zero",is_zero_approx(app.ground_view.get_aabb().position.y) and is_zero_approx(app.ground_view.get_aabb().end.y)) app.select_category("nonInteractive");app.kind="wall";app.refresh_selection() app.position_fields[0].value=-5;app.position_fields[2].value=1;await click_control(app.place_button) var first_id: String=app.last_placed_id app.position_fields[2].value=2;await click_control(app.place_button) var second_id: String=app.last_placed_id check("two_ground_walls_reproduce_user_layout",app.records.size()==2 and has_bottom(app,Vector3(-5,0,1)) and has_bottom(app,Vector3(-5,0,2))) # The exact troublesome operation: no deselection, just Y=1 then Place. app.position_fields[1].value=1;await click_control(app.place_button) check("coordinate_stacking_adds_without_moving_base",app.records.size()==3 and has_bottom(app,Vector3(-5,0,1)) and has_bottom(app,Vector3(-5,0,2)) and has_bottom(app,Vector3(-5,1,2)) and app.records[app.index_for(first_id)].position.y==0 and app.records[app.index_for(second_id)].position.y==0) await click_control(app.place_button) check("repeat_placement_rejects_duplicate",app.records.size()==3) app.position_fields[1].value=.5;await click_control(app.place_button) check("partial_overlap_rejected_without_overwrite",app.records.size()==3 and has_bottom(app,Vector3(-5,0,2))) app.frame_level();await settle() await click_world(app,Vector3(-4.8,2.001,2.2)) check("top_face_click_targets_next_layer",app.block_mode=="place" and app.selected_id.is_empty() and app.cursor.is_equal_approx(Vector3(-5,2,2)),{"cursor":app.codec.array_from(app.cursor)}) await click_control(app.place_button);await settle() check("mouse_stacks_third_layer",app.records.size()==4 and has_bottom(app,Vector3(-5,2,2))) app.select_category("chutes");app.kind="gentle";app.refresh_selection() await click_world(app,Vector3(-4.8,3.001,2.2)) check("surface_pick_keeps_chosen_chute",app.kind=="gentle" and app.cursor.y==3) await click_control(app.place_button);await settle() check("chute_can_stack_on_wall",has_bottom(app,Vector3(-5,3,2),"gentle") and app.records.size()==5) check("grid_does_not_follow_placement_height",app.grid.get_children().all(func(node):return is_equal_approx(node.position.y,.004))) # Click the visible side of the original wall and add an adjacent wall. app.select_category("nonInteractive");app.kind="wall";app.refresh_selection() await click_world(app,Vector3(-4.499,.45,2.1)) check("side_face_targets_adjacent_cell",app.cursor.is_equal_approx(Vector3(-4,0,2)),{"cursor":app.codec.array_from(app.cursor)}) await click_control(app.place_button);await settle() check("side_attachment_preserves_stack",has_bottom(app,Vector3(-4,0,2)) and has_bottom(app,Vector3(-5,2,2))) var before_count: int=app.records.size() await click_control(app.mode_buttons.edit) await click_world(app,Vector3(-3.499,.45,2.1)) var moving_id: String=app.selected_id check("edit_mode_selects_existing_wall",app.block_mode=="edit" and not moving_id.is_empty() and app.cursor==Vector3(-4,0,2)) app.position_fields[0].value=-2;app.position_fields[1].value=1 check("coordinate_fields_only_preview_move",has_bottom(app,Vector3(-4,0,2))) await click_control(app.apply_button) check("explicit_apply_moves_only_selected_wall",app.records.size()==before_count and has_bottom(app,Vector3(-2,1,2)) and has_bottom(app,Vector3(-5,0,2))) app.undo();check("undo_move_preserves_stack",has_bottom(app,Vector3(-4,0,2)) and has_bottom(app,Vector3(-5,2,2))) app.redo();check("redo_move_preserves_stack",has_bottom(app,Vector3(-2,1,2)) and has_bottom(app,Vector3(-5,2,2))) # New-placement button remains additive even after deliberately selecting a block. app.select_record(second_id);app.position_fields[0].value=-7;await click_control(app.place_button) check("place_button_never_reuses_selected_id",app.records.size()==before_count+1 and has_bottom(app,Vector3(-5,0,2)) and has_bottom(app,Vector3(-7,0,2))) app.kind="wall";app.cursor=Vector3(2,0,0);app.place_current();var support: String=app.last_placed_id app.kind="y_merge";app.cursor=Vector3(2,1,0);app.place_current() check("multi_cell_chute_can_stack",has_bottom(app,Vector3(2,1,0),"y_merge") and app.index_for(support)>=0) app.kind="wall";app.cursor=Vector3(3,1,1);var count: int=app.records.size();app.place_current() check("multi_cell_stack_occupancy_rejected",app.records.size()==count) # Shared bottom-face coordinates also cover an asset whose mesh origin is its rim. app.kind="goal_hole";app.cursor=Vector3(5,0,0);app.place_current() var goal_id: String=app.last_placed_id check("goal_y_zero_means_bottom_on_ground",app.records[app.index_for(goal_id)].position.y==1 and has_bottom(app,Vector3(5,0,0),"goal_hole")) app.select_record(goal_id) check("select_goal_shows_bottom_height",app.position_fields[1].value==0) check("ground_reserves_goal_outlet",app.ground_holes.any(func(rect):return rect.has_point(Vector2(5,0)))) var snapshot: Dictionary=app.encode() var file: String="res://playtest/artifacts/styled/stacked_level.json" app.save_level(file);app.clear_level() check("stacked_layout_roundtrip",app.load_level(file).is_empty() and JSON.stringify(app.encode())==JSON.stringify(snapshot) and has_bottom(app,Vector3(-5,2,2))) # Ground clicks always return to Y=0, even after working at an elevated layer. app.cursor=Vector3(0,7,0);app.set_block_mode("place");app.target=Vector3(0,1,0);app.camera_size=12;app.update_camera() await settle();await click_world(app,Vector3(0,0,3)) check("empty_ground_pick_returns_y_zero",app.cursor.y==0) app.clear_level() var supported:=true var types: Array=app.IDS.duplicate() for group in app.entity_registry.values(): for entry in group:types.append(entry.id) for i in range(types.size()): app.kind="wall";app.cursor=Vector3(i*4,0,0);app.place_current() app.kind=types[i];app.cursor=Vector3(i*4,1,0);app.place_current() supported=supported and has_bottom(app,Vector3(i*4,1,0),types[i]) check("all_registered_block_types_stack_on_wall",supported and app.records.size()==types.size()*2,{"types":types,"records":app.records.size()}) var f=FileAccess.open("res://playtest/artifacts/styled/stacking_report.json",FileAccess.WRITE) f.store_string(JSON.stringify({"passed":results.size()-failures,"failed":failures,"results":results}," "));f.close() quit(1 if failures else 0)