Restructure into core/ and content/official/
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
extends Camera3D
|
||||
|
||||
## Owns dart input. The camera does the raycast because the raycast IS a
|
||||
## camera operation — projecting a screen point into the world.
|
||||
##
|
||||
## The dart exposes begin_drag / update_drag / release_drag and never looks
|
||||
## for the camera itself. This script decides who to call them on.
|
||||
|
||||
const RAY_LENGTH := 1000.0
|
||||
|
||||
var _held_dart: Dart = null
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseButton:
|
||||
var mb := event as InputEventMouseButton
|
||||
if mb.button_index != MOUSE_BUTTON_LEFT:
|
||||
return
|
||||
if mb.pressed:
|
||||
_try_grab(mb.position)
|
||||
else:
|
||||
_release()
|
||||
|
||||
elif event is InputEventMouseMotion and _held_dart != null:
|
||||
_held_dart.update_drag(self, (event as InputEventMouseMotion).position)
|
||||
|
||||
|
||||
func _try_grab(screen_pos: Vector2) -> void:
|
||||
var hit := _raycast(screen_pos)
|
||||
if hit.is_empty():
|
||||
return
|
||||
|
||||
var body = hit.get("collider")
|
||||
if body is Dart:
|
||||
_held_dart = body as Dart
|
||||
# NOTE: two args, not three. The old start_drag(camera, mouse_pos, point)
|
||||
# passed mouse_pos but never used it — begin_drag only needs the hit point.
|
||||
_held_dart.begin_drag(self, hit["position"])
|
||||
|
||||
|
||||
func _release() -> void:
|
||||
if _held_dart == null:
|
||||
return
|
||||
_held_dart.release_drag()
|
||||
_held_dart = null
|
||||
|
||||
|
||||
func _raycast(screen_pos: Vector2) -> Dictionary:
|
||||
var params := PhysicsRayQueryParameters3D.create(
|
||||
project_ray_origin(screen_pos),
|
||||
project_ray_origin(screen_pos) + project_ray_normal(screen_pos) * RAY_LENGTH
|
||||
)
|
||||
if _held_dart != null:
|
||||
params.exclude = [_held_dart.get_rid()]
|
||||
|
||||
return get_world_3d().direct_space_state.intersect_ray(params)
|
||||
@@ -0,0 +1 @@
|
||||
uid://ds3uiri3oc05v
|
||||
@@ -0,0 +1,12 @@
|
||||
extends Node3D
|
||||
|
||||
## Scene root. Deliberately tiny.
|
||||
##
|
||||
## Dart input lives in camera_3d.gd (the raycast is a camera operation).
|
||||
## Board behaviour lives in dartboard.gd. Modifier UI lives in core/ui/.
|
||||
## This script wires nothing and owns nothing — it's just the tree root.
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed(&"restart"):
|
||||
get_tree().reload_current_scene()
|
||||
@@ -0,0 +1 @@
|
||||
uid://geqmah8kbko0
|
||||
@@ -0,0 +1,43 @@
|
||||
[gd_scene format=3 uid="uid://doh7p84eej78c"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://geqmah8kbko0" path="res://scenes/main.gd" id="1_sugp2"]
|
||||
[ext_resource type="Script" uid="uid://ds3uiri3oc05v" path="res://scenes/camera_3d.gd" id="2_jyhfs"]
|
||||
[ext_resource type="PackedScene" uid="uid://fshohiewm7et" path="res://core/dart/dart.tscn" id="3_tbgi4"]
|
||||
[ext_resource type="PackedScene" uid="uid://dojbd5wl7ntp0" path="res://core/board/dartboard.tscn" id="3_tefeu"]
|
||||
[ext_resource type="Script" uid="uid://x5kcjofb5pek" path="res://core/ui/drop_catcher.gd" id="5_o6xl0"]
|
||||
[ext_resource type="Script" uid="uid://dnek55fao0l72" path="res://core/ui/modifier_tray.gd" id="6_tipki"]
|
||||
|
||||
[node name="Main" type="Node3D" unique_id=819165214]
|
||||
script = ExtResource("1_sugp2")
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="." unique_id=1570426839]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.3, 2.37)
|
||||
fov = 30.0
|
||||
script = ExtResource("2_jyhfs")
|
||||
|
||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="." unique_id=1891469178]
|
||||
transform = Transform3D(-0.789482, 0.24223976, -0.56394875, -0.56595325, 0.06825608, 0.821607, 0.23751883, 0.9678125, 0.08320943, -46.816067, 15.942318, -50.370865)
|
||||
|
||||
[node name="Dartboard" parent="." unique_id=408060787 instance=ExtResource("3_tefeu")]
|
||||
|
||||
[node name="Dart" parent="." unique_id=367982453 instance=ExtResource("3_tbgi4")]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.83676445, 0.5475633, 0, -0.54756325, 0.8367645, 0, -0.43, 1.8)
|
||||
|
||||
[node name="UI" type="CanvasLayer" parent="." unique_id=1068293458]
|
||||
|
||||
[node name="DropCatcher" type="Control" parent="UI" unique_id=1874461265 node_paths=PackedStringArray("camera", "dartboard")]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
script = ExtResource("5_o6xl0")
|
||||
camera = NodePath("../../Camera3D")
|
||||
dartboard = NodePath("../../Dartboard")
|
||||
|
||||
[node name="ModifierTray" type="Control" parent="UI" unique_id=1639987503 node_paths=PackedStringArray("drop_catcher")]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
script = ExtResource("6_tipki")
|
||||
drop_catcher = NodePath("../DropCatcher")
|
||||
Reference in New Issue
Block a user