114 lines
4.2 KiB
GDScript
114 lines
4.2 KiB
GDScript
extends SceneTree
|
|
## WEGWERF-Renderprobe (Karte t_aaff5dcc, T3 Komfort im Testlauf) —
|
|
## (a) Vogelperspektive per God-Mode: Fliegen an, 80 m über der Kartenmitte,
|
|
## Blick nach unten, Achsen-Linien an (X-Rot/Z-Blau, Karte M1)
|
|
## (b) Sprung zum Spawnpunkt: Taste 2 (Team Rot) — HUD zeigt Pos/Blick/Höhe
|
|
## (c) Hilfe-Overlay (F1): alle Tasten im Klartext
|
|
## Ausführen:
|
|
## xvfb-run -a godot4 --path . --rendering-driver opengl3 -s res://tests/probe_playtest_comfort.gd
|
|
## Beweise nach /opt/data/scopedvr/work/taaff5dcc_beweise/.
|
|
|
|
var main: Control
|
|
var subvp: SubViewport
|
|
|
|
func _initialize() -> void:
|
|
_run.call_deferred()
|
|
|
|
func _png(name: String) -> String:
|
|
return "/opt/data/scopedvr/work/taaff5dcc_beweise/" + name
|
|
|
|
func _shot(name: String) -> void:
|
|
await process_frame
|
|
await process_frame
|
|
var img := subvp.get_texture().get_image()
|
|
img.save_png(_png(name))
|
|
print("PROBE_PNG=%s (%dx%d)" % [_png(name), img.get_width(), img.get_height()])
|
|
|
|
func _find_subvp(node: Node) -> SubViewport:
|
|
if node is SubViewport:
|
|
return node as SubViewport
|
|
for c in node.get_children():
|
|
var f := _find_subvp(c)
|
|
if f != null:
|
|
return f
|
|
return null
|
|
|
|
func _run() -> void:
|
|
DirAccess.make_dir_recursive_absolute("/opt/data/scopedvr/work/taaff5dcc_beweise")
|
|
var scene: PackedScene = load("res://core/scenes/main.tscn")
|
|
main = scene.instantiate()
|
|
root.add_child(main)
|
|
await process_frame
|
|
await process_frame
|
|
subvp = _find_subvp(main)
|
|
var container: SubViewportContainer = subvp.get_parent()
|
|
container.stretch = false
|
|
subvp.size = Vector2i(1600, 900)
|
|
await process_frame
|
|
|
|
# Test-Karte mit ein paar Kisten als Landmarken.
|
|
var doc: Dictionary = SvmapDocument.create_new("T3-Komfort-Probe", 512.0, "mittag")
|
|
doc["objects"] = [
|
|
{"id": "box_001", "pos": [30.0, 0.0, -40.0], "scale": 1.0, "rot_y_deg": 0.0},
|
|
{"id": "box_001", "pos": [-60.0, 0.0, 20.0], "scale": 1.0, "rot_y_deg": 0.0},
|
|
]
|
|
main.set("doc", doc)
|
|
main.call("_refresh_all")
|
|
await process_frame
|
|
await process_frame
|
|
|
|
main.call("_on_test_run")
|
|
await process_frame
|
|
await process_frame
|
|
var pt: Node = main.get("playtest")
|
|
var body: Node3D = pt.get("body")
|
|
print("ZAHLEN start: body=", body.position, " fly=", body.get("fly_mode"))
|
|
|
|
# --- (a) God-Mode: hoch über die Kartenmitte, Blick nach unten ------------
|
|
pt.call("toggle_fly")
|
|
pt.call("toggle_axis") # Kartenmitte/Achsen sichtbar (X-Rot/Z-Blau/Grün)
|
|
var bounds: Dictionary = doc.get("bounds", {})
|
|
var mn: Array = bounds.get("min", [-256.0, -10.0, -256.0])
|
|
var mx: Array = bounds.get("max", [256.0, 80.0, 256.0])
|
|
var cx := (float(mn[0]) + float(mx[0])) * 0.5
|
|
var cz := (float(mn[2]) + float(mx[2])) * 0.5
|
|
body.set("position", Vector3(cx, 80.0, cz))
|
|
body.set("yaw_deg", 45.0)
|
|
body.set("pitch_deg", -80.0)
|
|
print("ZAHLEN (a) fly=", body.get("fly_mode"), " pos=", body.position,
|
|
" axis_an=", pt.call("toggle_axis") == false)
|
|
await _shot("t3_a_vogelperspektive_godmode.png")
|
|
|
|
# --- (b) Sprung zum Spawnpunkt Team Rot (Taste 2) -------------------------
|
|
pt.call("toggle_fly") # God-Mode AUS — dann zeigt die Meldung den Sprung
|
|
var ok2 := bool(pt.call("jump_to_spawn", 2))
|
|
print("ZAHLEN (b) jump_to_spawn(2)=", ok2, " pos=", body.position,
|
|
" terrain_dort=", body.terrain_height(body.position.x, body.position.z))
|
|
body.set("yaw_deg", 127.0) # Blick Richtung Kartenmitte
|
|
body.set("pitch_deg", 3.0)
|
|
print("ZAHLEN (b) fly=", body.get("fly_mode"),
|
|
" HUD pos='", (pt.get("hud_pos") as Label).text, "' dir='",
|
|
(pt.get("hud_dir") as Label).text, "' msg='",
|
|
(pt.get("hud_msg") as Label).text, "'")
|
|
await _shot("t3_b_spawnpunkt_team_rot.png")
|
|
|
|
# --- (c) Hilfe-Overlay (F1) -----------------------------------------------
|
|
var help_vor := bool(pt.call("toggle_help"))
|
|
print("ZAHLEN (c) F1 hilfe_an=", help_vor)
|
|
await _shot("t3_c_hilfe_f1.png")
|
|
|
|
# --- Aufräumen: zurück in den Editor --------------------------------------
|
|
main._unhandled_key_input(_make_key(KEY_ESCAPE))
|
|
await process_frame
|
|
await process_frame
|
|
print("ZAHLEN (d) playtest null=", main.get("playtest") == null,
|
|
" panels=", main.get("ui_top_bar").visible)
|
|
print("PROBE_FERTIG")
|
|
quit(0)
|
|
|
|
func _make_key(code: Key) -> InputEventKey:
|
|
var evt := InputEventKey.new()
|
|
evt.keycode = code
|
|
evt.physical_keycode = code
|
|
evt.pressed = true
|
|
return evt
|