rhetorical
This commit is contained in:
parent
aa4046e7dc
commit
4525ab50ff
12 changed files with 138 additions and 2 deletions
|
|
@ -1,5 +1,7 @@
|
|||
extends Area3D
|
||||
|
||||
signal drag_started
|
||||
signal drag_ended
|
||||
|
||||
var mouse_in: bool = false
|
||||
var dragged: bool = false
|
||||
|
|
@ -21,5 +23,7 @@ func _input(event: InputEvent) -> void:
|
|||
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
|
||||
if mouse_in and event.pressed:
|
||||
dragged = true
|
||||
drag_started.emit()
|
||||
if event.pressed == false:
|
||||
dragged = false
|
||||
drag_ended.emit()
|
||||
|
|
|
|||
17
src/interactible/interaction_reciever.gd
Normal file
17
src/interactible/interaction_reciever.gd
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
extends Area3D
|
||||
|
||||
class_name InteractionReciever
|
||||
|
||||
signal interacted(source: InteractionSource)
|
||||
|
||||
func _ready() -> void:
|
||||
area_entered.connect(on_area_entered)
|
||||
area_exited.connect(on_area_exited)
|
||||
|
||||
func on_area_entered(area: Area3D):
|
||||
if area is InteractionSource:
|
||||
area.interaction_requested.connect(interacted.emit)
|
||||
|
||||
func on_area_exited(area: Area3D):
|
||||
if area is InteractionSource:
|
||||
area.interaction_requested.disconnect(interacted.emit)
|
||||
1
src/interactible/interaction_reciever.gd.uid
Normal file
1
src/interactible/interaction_reciever.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://mjx50qh1bwv3
|
||||
22
src/interactible/interaction_source.gd
Normal file
22
src/interactible/interaction_source.gd
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
extends Area3D
|
||||
|
||||
class_name InteractionSource
|
||||
|
||||
signal interaction_requested
|
||||
signal interaction_reciever_entered(reicever: InteractionReciever)
|
||||
signal interaction_reciever_exited(reicever: InteractionReciever)
|
||||
|
||||
func _ready() -> void:
|
||||
area_entered.connect(on_area_entered)
|
||||
area_exited.connect(on_area_exited)
|
||||
|
||||
func on_area_entered(area: Area3D):
|
||||
if area is InteractionReciever:
|
||||
interaction_reciever_entered.emit(area)
|
||||
|
||||
func on_area_exited(area: Area3D):
|
||||
if area is InteractionReciever:
|
||||
interaction_reciever_exited.emit(area)
|
||||
|
||||
func request_interaction() -> void:
|
||||
interaction_requested.emit()
|
||||
1
src/interactible/interaction_source.gd.uid
Normal file
1
src/interactible/interaction_source.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://ctu7escah5lo1
|
||||
23
src/interactible/proximity_rotator.gd
Normal file
23
src/interactible/proximity_rotator.gd
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
extends Node
|
||||
|
||||
@export var rotated: Node3D
|
||||
@onready var start_rotation = rotated.quaternion
|
||||
var reiciever: InteractionReciever
|
||||
|
||||
func _on_interaction_area_interaction_reciever_entered(reicever: InteractionReciever) -> void:
|
||||
if self.reicever == null:
|
||||
self.reciever = reicever
|
||||
|
||||
|
||||
func _on_interaction_area_interaction_reciever_exited(reicever: InteractionReciever) -> void:
|
||||
if self.reicever == reicever:
|
||||
self.reciever = null
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if reiciever == null:
|
||||
rotated.quaternion = start_rotation
|
||||
|
||||
var camera: Camera3D = get_viewport().get_camera_3d()
|
||||
var angle_to: Quaternion = Quaternion(-camera.basis.z,1.5707963267948966)
|
||||
var calculated_angle: Quaternion = start_rotation.slerp()
|
||||
rotated.quaternion = calculated_angle
|
||||
1
src/interactible/proximity_rotator.gd.uid
Normal file
1
src/interactible/proximity_rotator.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://e8xu57ewvb5a
|
||||
Loading…
Add table
Add a link
Reference in a new issue