UX: Variant-Inferenz-Warnungen as Error vermeiden (interaction.gd)

This commit is contained in:
Hermes (godot-vr) 2026-10-15 09:49:14 +00:00
parent 1f2ca0179a
commit d628e766ab

View file

@ -70,7 +70,7 @@ func _terrain_half() -> Vector2:
func _pick_object(viewport_pos: Vector2) -> int:
var origin := camera.project_ray_origin(viewport_pos)
var dir := camera.project_ray_normal(viewport_pos)
var ground := _ground_point(viewport_pos)
var ground: Variant = _ground_point(viewport_pos)
var ground_t := INF
if ground != null:
ground_t = (ground as Vector3).distance_to(origin)
@ -149,7 +149,7 @@ func _ensure_ghost_visible() -> void:
func _ghost_update(viewport_pos: Vector2) -> void:
var p := _ground_point(viewport_pos)
var p: Variant = _ground_point(viewport_pos)
if p == null:
_ghost_active = false
_ghost.visible = false
@ -165,7 +165,7 @@ func _ghost_update(viewport_pos: Vector2) -> void:
func _place_object(viewport_pos: Vector2) -> void:
var p := _ground_point(viewport_pos)
var p: Variant = _ground_point(viewport_pos)
if p == null:
main.call("_set_status", "Da war kein Boden unter dem Mauszeiger — klicke IN die Karte (die grüne Fläche).", true)
return
@ -269,10 +269,10 @@ func _unhandled_input(event: InputEvent) -> void:
if placing:
_ghost_update(mm.position)
if _dragging and not placing and selected_index >= 0:
var p := _ground_point(mm.position)
var p: Variant = _ground_point(mm.position)
if p == null:
return
var new_pos := p as Vector3 + _grab_offset
var new_pos: Vector3 = (p as Vector3) + _grab_offset
var half := _terrain_half()
new_pos.x = clampf(new_pos.x, -half.x, half.x)
new_pos.z = clampf(new_pos.z, -half.y, half.y)
@ -326,7 +326,7 @@ func _on_left_press(mb: InputEventMouseButton) -> void:
select_object(hit)
_dragging = true
_drag_moved = false
var p := _ground_point(mb.position)
var p: Variant = _ground_point(mb.position)
var marker: Node3D = view_builder.object_markers[selected_index]
if p != null and marker != null and is_instance_valid(marker):
_grab_offset = marker.position - (p as Vector3)