interaction base
This commit is contained in:
parent
3a6da57079
commit
2f559639fb
21 changed files with 134 additions and 49 deletions
|
|
@ -1,7 +0,0 @@
|
||||||
[gd_resource type="ORMMaterial3D" format=3 uid="uid://glk2rfkn4vcu"]
|
|
||||||
|
|
||||||
[resource]
|
|
||||||
transparency = 4
|
|
||||||
cull_mode = 2
|
|
||||||
albedo_color = Color(1, 1, 1, 0.3882353)
|
|
||||||
clearcoat_enabled = true
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
[gd_resource type="StandardMaterial3D" format=3 uid="uid://be2l68by8md8t"]
|
|
||||||
|
|
||||||
[resource]
|
|
||||||
transparency = 4
|
|
||||||
cull_mode = 2
|
|
||||||
albedo_color = Color(1, 1, 1, 0.2784314)
|
|
||||||
clearcoat_enabled = true
|
|
||||||
8
assets/materials/mat_glass.tres
Normal file
8
assets/materials/mat_glass.tres
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
[gd_resource type="StandardMaterial3D" format=3 uid="uid://64m17act0kwu"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
resource_name = "mat_glass"
|
||||||
|
transparency = 4
|
||||||
|
cull_mode = 2
|
||||||
|
albedo_color = Color(0.9063318, 0.9063318, 0.9063318, 0.25)
|
||||||
|
roughness = 0.0
|
||||||
Binary file not shown.
|
|
@ -3,13 +3,13 @@
|
||||||
importer="scene"
|
importer="scene"
|
||||||
importer_version=1
|
importer_version=1
|
||||||
type="PackedScene"
|
type="PackedScene"
|
||||||
uid="uid://cybcaqajfr5jx"
|
uid="uid://b6ydpkle2ol20"
|
||||||
path="res://.godot/imported/flask.glb-2126b3646c073a6ae7a51eae46cf2a4b.scn"
|
path="res://.godot/imported/FlaskNew.glb-8b6f6d6281f698dfdf4a2cc330807ea4.scn"
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://assets/models/flask.glb"
|
source_file="res://assets/models/FlaskNew.glb"
|
||||||
dest_files=["res://.godot/imported/flask.glb-2126b3646c073a6ae7a51eae46cf2a4b.scn"]
|
dest_files=["res://.godot/imported/FlaskNew.glb-8b6f6d6281f698dfdf4a2cc330807ea4.scn"]
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
||||||
|
|
@ -39,9 +39,10 @@ materials/extract_format=0
|
||||||
materials/extract_path=""
|
materials/extract_path=""
|
||||||
_subresources={
|
_subresources={
|
||||||
"materials": {
|
"materials": {
|
||||||
"@MATERIAL:0": {
|
"mat_glass": {
|
||||||
"use_external/enabled": true,
|
"use_external/enabled": true,
|
||||||
"use_external/path": "uid://glk2rfkn4vcu"
|
"use_external/fallback_path": "res://assets/materials/mat_glass.tres",
|
||||||
|
"use_external/path": "uid://64m17act0kwu"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -15,6 +15,10 @@ run/main_scene="uid://c7r4rhgj3ucao"
|
||||||
config/features=PackedStringArray("4.5", "Mobile")
|
config/features=PackedStringArray("4.5", "Mobile")
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
|
[autoload]
|
||||||
|
|
||||||
|
GuiSignalBus="*res://src/gui_signal_bus.gd"
|
||||||
|
|
||||||
[input]
|
[input]
|
||||||
|
|
||||||
drag_camera={
|
drag_camera={
|
||||||
|
|
|
||||||
|
|
@ -1,44 +1,77 @@
|
||||||
[gd_scene load_steps=7 format=3 uid="uid://bjxjcx2qu16q5"]
|
[gd_scene load_steps=9 format=3 uid="uid://bjxjcx2qu16q5"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://bjnv2g1ni0525" path="res://src/drag/draggable_object.gd" id="1_vcwhe"]
|
[ext_resource type="Script" uid="uid://bjnv2g1ni0525" path="res://src/drag/draggable_object.gd" id="1_vcwhe"]
|
||||||
[ext_resource type="Script" uid="uid://ctu7escah5lo1" path="res://src/interactible/interaction_source.gd" id="2_627mb"]
|
[ext_resource type="Script" uid="uid://ctu7escah5lo1" path="res://src/interactible/interaction_source.gd" id="2_627mb"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://b6ydpkle2ol20" path="res://assets/models/FlaskNew.glb" id="2_qf1og"]
|
||||||
[ext_resource type="Script" uid="uid://e8xu57ewvb5a" path="res://src/interactible/proximity_rotator.gd" id="3_00eeh"]
|
[ext_resource type="Script" uid="uid://e8xu57ewvb5a" path="res://src/interactible/proximity_rotator.gd" id="3_00eeh"]
|
||||||
|
[ext_resource type="Script" uid="uid://b1gv6dt8bwj2p" path="res://src/interactible/returner.gd" id="5_bqclg"]
|
||||||
[sub_resource type="SphereShape3D" id="SphereShape3D_vcwhe"]
|
[ext_resource type="Script" uid="uid://dteb2xxl8gixp" path="res://src/ui/slider_display.gd" id="5_qb0nw"]
|
||||||
radius = 0.49570328
|
|
||||||
|
|
||||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_vcwhe"]
|
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_vcwhe"]
|
||||||
radius = 0.1
|
radius = 0.1
|
||||||
height = 0.7
|
height = 0.9921875
|
||||||
|
|
||||||
[sub_resource type="CylinderMesh" id="CylinderMesh_627mb"]
|
[sub_resource type="SphereShape3D" id="SphereShape3D_vcwhe"]
|
||||||
top_radius = 0.1
|
radius = 0.49649125
|
||||||
bottom_radius = 0.08
|
|
||||||
height = 0.5
|
|
||||||
|
|
||||||
[node name="DraggableObject" type="Area3D"]
|
[node name="DraggableObject" type="Area3D"]
|
||||||
script = ExtResource("1_vcwhe")
|
script = ExtResource("1_vcwhe")
|
||||||
|
|
||||||
[node name="DragShape" type="CollisionShape3D" parent="."]
|
[node name="DragArea" type="CollisionShape3D" parent="."]
|
||||||
shape = SubResource("SphereShape3D_vcwhe")
|
shape = SubResource("CapsuleShape3D_vcwhe")
|
||||||
|
|
||||||
[node name="InteractionArea" type="Area3D" parent="."]
|
[node name="FlaskNew" parent="." instance=ExtResource("2_qf1og")]
|
||||||
|
transform = Transform3D(0.1, 0, 0, 0, 0.1, 0, 0, 0, 0.1, 0, -0.38859487, 0)
|
||||||
|
|
||||||
|
[node name="InteractionArea" type="Area3D" parent="." node_paths=PackedStringArray("interaction_dialog")]
|
||||||
collision_layer = 2
|
collision_layer = 2
|
||||||
collision_mask = 2
|
collision_mask = 2
|
||||||
input_ray_pickable = false
|
input_ray_pickable = false
|
||||||
script = ExtResource("2_627mb")
|
script = ExtResource("2_627mb")
|
||||||
|
interaction_dialog = NodePath("../InteractionDialog")
|
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="InteractionArea"]
|
[node name="InteractionArea" type="CollisionShape3D" parent="InteractionArea"]
|
||||||
shape = SubResource("CapsuleShape3D_vcwhe")
|
shape = SubResource("SphereShape3D_vcwhe")
|
||||||
|
|
||||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
|
||||||
mesh = SubResource("CylinderMesh_627mb")
|
|
||||||
|
|
||||||
[node name="ProximityRotator" type="Node" parent="." node_paths=PackedStringArray("rotated")]
|
[node name="ProximityRotator" type="Node" parent="." node_paths=PackedStringArray("rotated")]
|
||||||
script = ExtResource("3_00eeh")
|
script = ExtResource("3_00eeh")
|
||||||
rotated = NodePath("../MeshInstance3D")
|
rotated = NodePath("..")
|
||||||
proximity_radius = 0.496
|
proximity_radius = 0.746
|
||||||
|
|
||||||
|
[node name="Returner" type="Node" parent="." node_paths=PackedStringArray("node")]
|
||||||
|
script = ExtResource("5_bqclg")
|
||||||
|
node = NodePath("..")
|
||||||
|
|
||||||
|
[node name="InteractionDialog" type="ConfirmationDialog" parent="."]
|
||||||
|
oversampling_override = 1.0
|
||||||
|
position = Vector2i(0, 36)
|
||||||
|
size = Vector2i(200, 131)
|
||||||
|
borderless = true
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="InteractionDialog"]
|
||||||
|
offset_left = 8.0
|
||||||
|
offset_top = 8.0
|
||||||
|
offset_right = 192.0
|
||||||
|
offset_bottom = 82.0
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="InteractionDialog/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Введите объём"
|
||||||
|
|
||||||
|
[node name="HBoxContainer" type="HBoxContainer" parent="InteractionDialog/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="AmountLabel" type="Label" parent="InteractionDialog/VBoxContainer/HBoxContainer" node_paths=PackedStringArray("slider")]
|
||||||
|
layout_mode = 2
|
||||||
|
script = ExtResource("5_qb0nw")
|
||||||
|
slider = NodePath("../HSlider")
|
||||||
|
suffix = "%"
|
||||||
|
|
||||||
|
[node name="HSlider" type="HSlider" parent="InteractionDialog/VBoxContainer/HBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
[connection signal="drag_ended" from="." to="InteractionArea" method="request_interaction"]
|
[connection signal="drag_ended" from="." to="InteractionArea" method="request_interaction"]
|
||||||
|
[connection signal="interaction_closed" from="InteractionArea" to="Returner" method="return_to_start"]
|
||||||
[connection signal="interaction_reciever_entered" from="InteractionArea" to="ProximityRotator" method="_on_interaction_area_interaction_reciever_entered"]
|
[connection signal="interaction_reciever_entered" from="InteractionArea" to="ProximityRotator" method="_on_interaction_area_interaction_reciever_entered"]
|
||||||
[connection signal="interaction_reciever_exited" from="InteractionArea" to="ProximityRotator" method="_on_interaction_area_interaction_reciever_exited"]
|
[connection signal="interaction_reciever_exited" from="InteractionArea" to="ProximityRotator" method="_on_interaction_area_interaction_reciever_exited"]
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,16 @@
|
||||||
[gd_scene load_steps=4 format=3 uid="uid://q1y0r2rn0qb4"]
|
[gd_scene load_steps=5 format=3 uid="uid://q1y0r2rn0qb4"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://mjx50qh1bwv3" path="res://src/interactible/interaction_reciever.gd" id="1_auicg"]
|
[ext_resource type="Script" uid="uid://mjx50qh1bwv3" path="res://src/interactible/interaction_reciever.gd" id="1_auicg"]
|
||||||
|
[ext_resource type="Material" uid="uid://64m17act0kwu" path="res://assets/materials/mat_glass.tres" id="2_mqqtq"]
|
||||||
|
|
||||||
[sub_resource type="CylinderMesh" id="CylinderMesh_nql6a"]
|
[sub_resource type="CylinderMesh" id="CylinderMesh_nql6a"]
|
||||||
|
material = ExtResource("2_mqqtq")
|
||||||
height = 0.75
|
height = 0.75
|
||||||
|
rings = 0
|
||||||
|
cap_top = false
|
||||||
|
|
||||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_auicg"]
|
[sub_resource type="CylinderShape3D" id="CylinderShape3D_auicg"]
|
||||||
height = 1.0
|
height = 0.7128906
|
||||||
radius = 0.75
|
radius = 0.75
|
||||||
|
|
||||||
[node name="InteractibleObject" type="Area3D"]
|
[node name="InteractibleObject" type="Area3D"]
|
||||||
|
|
@ -19,5 +23,5 @@ script = ExtResource("1_auicg")
|
||||||
mesh = SubResource("CylinderMesh_nql6a")
|
mesh = SubResource("CylinderMesh_nql6a")
|
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5867026, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.7302573, 0)
|
||||||
shape = SubResource("CylinderShape3D_auicg")
|
shape = SubResource("CylinderShape3D_auicg")
|
||||||
|
|
|
||||||
|
|
@ -18,15 +18,16 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.236948, 0.9448395, 1.82942
|
||||||
script = ExtResource("1_hem3r")
|
script = ExtResource("1_hem3r")
|
||||||
|
|
||||||
[node name="DraggableObject" parent="." instance=ExtResource("1_bb6uc")]
|
[node name="DraggableObject" parent="." instance=ExtResource("1_bb6uc")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.236948, 0.9448395, 0.0039073825)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.7153518, 0.9448395, 0.0039073825)
|
||||||
|
|
||||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 0.8403207, 0.5420896, 0, -0.5420896, 0.8403207, 0, 1.9293891, 0)
|
transform = Transform3D(1, 0, 0, 0, 0.8403207, 0.5420896, 0, -0.5420896, 0.8403207, 0, 1.9293891, 0)
|
||||||
|
shadow_enabled = true
|
||||||
|
|
||||||
|
[node name="InteractibleObject" parent="." instance=ExtResource("4_f680m")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.11957906, 0.87858754, -0.0035084486)
|
||||||
|
|
||||||
[node name="UI" type="CanvasLayer" parent="."]
|
[node name="UI" type="CanvasLayer" parent="."]
|
||||||
layer = 100
|
layer = 100
|
||||||
|
|
||||||
[node name="UserInterface" parent="UI" instance=ExtResource("3_hflkp")]
|
[node name="UserInterface" parent="UI" instance=ExtResource("3_hflkp")]
|
||||||
|
|
||||||
[node name="InteractibleObject" parent="." instance=ExtResource("4_f680m")]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.11957906, 0.7987209, 0.07669878)
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
extends Area3D
|
extends Area3D
|
||||||
|
|
||||||
|
class_name DraggableObject
|
||||||
|
|
||||||
signal drag_started
|
signal drag_started
|
||||||
signal drag_ended
|
signal drag_ended
|
||||||
|
|
||||||
|
|
|
||||||
5
src/gui_signal_bus.gd
Normal file
5
src/gui_signal_bus.gd
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
@warning_ignore_start("unused_signal")
|
||||||
|
|
||||||
|
signal interaction_confirmed(data: Dictionary)
|
||||||
1
src/gui_signal_bus.gd.uid
Normal file
1
src/gui_signal_bus.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://5o7igp3yxx6o
|
||||||
|
|
@ -2,7 +2,7 @@ extends Area3D
|
||||||
|
|
||||||
class_name InteractionReciever
|
class_name InteractionReciever
|
||||||
|
|
||||||
signal interacted(source: InteractionSource)
|
signal interaction_start(source: InteractionSource)
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
area_entered.connect(on_area_entered)
|
area_entered.connect(on_area_entered)
|
||||||
|
|
@ -10,8 +10,8 @@ func _ready() -> void:
|
||||||
|
|
||||||
func on_area_entered(area: Area3D):
|
func on_area_entered(area: Area3D):
|
||||||
if area is InteractionSource:
|
if area is InteractionSource:
|
||||||
area.interaction_requested.connect(interacted.emit)
|
area.interaction_requested.connect(interaction_start.emit)
|
||||||
|
|
||||||
func on_area_exited(area: Area3D):
|
func on_area_exited(area: Area3D):
|
||||||
if area is InteractionSource:
|
if area is InteractionSource:
|
||||||
area.interaction_requested.disconnect(interacted.emit)
|
area.interaction_requested.disconnect(interaction_start.emit)
|
||||||
|
|
|
||||||
|
|
@ -2,21 +2,33 @@ extends Area3D
|
||||||
|
|
||||||
class_name InteractionSource
|
class_name InteractionSource
|
||||||
|
|
||||||
|
@export var interaction_dialog: ConfirmationDialog
|
||||||
|
var recievers: int = 0
|
||||||
|
|
||||||
signal interaction_requested
|
signal interaction_requested
|
||||||
|
signal interaction_closed
|
||||||
signal interaction_reciever_entered(reicever: InteractionReciever)
|
signal interaction_reciever_entered(reicever: InteractionReciever)
|
||||||
signal interaction_reciever_exited(reicever: InteractionReciever)
|
signal interaction_reciever_exited(reicever: InteractionReciever)
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
area_entered.connect(on_area_entered)
|
area_entered.connect(on_area_entered)
|
||||||
area_exited.connect(on_area_exited)
|
area_exited.connect(on_area_exited)
|
||||||
|
interaction_dialog.canceled.connect(interaction_closed.emit)
|
||||||
|
interaction_dialog.confirmed.connect(interaction_closed.emit)
|
||||||
|
|
||||||
func on_area_entered(area: Area3D):
|
func on_area_entered(area: Area3D):
|
||||||
if area is InteractionReciever:
|
if area is InteractionReciever:
|
||||||
interaction_reciever_entered.emit(area)
|
interaction_reciever_entered.emit(area)
|
||||||
|
recievers += 1
|
||||||
|
|
||||||
func on_area_exited(area: Area3D):
|
func on_area_exited(area: Area3D):
|
||||||
if area is InteractionReciever:
|
if area is InteractionReciever:
|
||||||
interaction_reciever_exited.emit(area)
|
interaction_reciever_exited.emit(area)
|
||||||
|
recievers -= 1
|
||||||
|
|
||||||
func request_interaction() -> void:
|
func request_interaction() -> void:
|
||||||
|
if recievers == 0:
|
||||||
|
interaction_closed.emit()
|
||||||
|
return
|
||||||
interaction_requested.emit()
|
interaction_requested.emit()
|
||||||
|
interaction_dialog.popup_centered()
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ func _on_interaction_area_interaction_reciever_entered(rec: InteractionReciever)
|
||||||
func _on_interaction_area_interaction_reciever_exited(rec: InteractionReciever) -> void:
|
func _on_interaction_area_interaction_reciever_exited(rec: InteractionReciever) -> void:
|
||||||
if reciever == rec:
|
if reciever == rec:
|
||||||
reciever = null
|
reciever = null
|
||||||
|
rotated.quaternion = start_rotation
|
||||||
|
|
||||||
func _process(_delta: float) -> void:
|
func _process(_delta: float) -> void:
|
||||||
if reciever == null:
|
if reciever == null:
|
||||||
|
|
|
||||||
7
src/interactible/returner.gd
Normal file
7
src/interactible/returner.gd
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
@export var node: Node3D
|
||||||
|
@onready var start_position: Vector3 = node.global_position
|
||||||
|
|
||||||
|
func return_to_start() -> void:
|
||||||
|
node.global_position = start_position
|
||||||
1
src/interactible/returner.gd.uid
Normal file
1
src/interactible/returner.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://b1gv6dt8bwj2p
|
||||||
6
src/inventory.gd
Normal file
6
src/inventory.gd
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
@export var open_on_top: bool
|
||||||
|
var liquids
|
||||||
|
var solids
|
||||||
|
var gasses
|
||||||
1
src/inventory.gd.uid
Normal file
1
src/inventory.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://82ettbegollp
|
||||||
11
src/ui/slider_display.gd
Normal file
11
src/ui/slider_display.gd
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
extends Label
|
||||||
|
|
||||||
|
@export var slider: Slider
|
||||||
|
@export var suffix: String
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
slider.value_changed.connect(_on_slider_value_changed)
|
||||||
|
text = str(slider.value).lpad(len(str(slider.max_value)),"0") + " " + suffix
|
||||||
|
|
||||||
|
func _on_slider_value_changed(value: float):
|
||||||
|
text = str(value).lpad(len(str(slider.max_value)),"0") + " " + suffix
|
||||||
1
src/ui/slider_display.gd.uid
Normal file
1
src/ui/slider_display.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://dteb2xxl8gixp
|
||||||
Loading…
Add table
Add a link
Reference in a new issue