Interactions

This commit is contained in:
Rendo 2025-12-26 01:31:21 +05:00
commit 4f6c151e25
31 changed files with 498 additions and 12 deletions

View file

@ -1,8 +1,11 @@
[gd_scene load_steps=8 format=4 uid="uid://bjxjcx2qu16q5"]
[gd_scene load_steps=15 format=4 uid="uid://bjxjcx2qu16q5"]
[ext_resource type="Script" uid="uid://bjnv2g1ni0525" path="res://src/drag/draggable_object.gd" id="1_0xufn"]
[ext_resource type="Material" uid="uid://64m17act0kwu" path="res://assets/materials/mat_glass.tres" id="2_dbm1u"]
[ext_resource type="Script" uid="uid://dig825r70a0sn" path="res://src/substance_display.gd" id="3_0xufn"]
[ext_resource type="Script" uid="uid://bl0ojhc0thk1p" path="res://src/interactible/interactible.gd" id="4_dbm1u"]
[ext_resource type="Texture2D" uid="uid://cw3jw8qbvj3fv" path="res://assets/textures/solid.png" id="4_h7awq"]
[ext_resource type="Script" uid="uid://duirfi4j26g2i" path="res://src/interactible/flask_interaction.gd" id="5_pmegg"]
[ext_resource type="Script" uid="uid://82ettbegollp" path="res://src/inventory.gd" id="7_h7awq"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_vcwhe"]
@ -43,6 +46,28 @@ _surfaces = [{
blend_shape_mode = 0
shadow_mesh = SubResource("ArrayMesh_1ouf4")
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ailwx"]
resource_local_to_scene = true
transparency = 1
[sub_resource type="CylinderMesh" id="CylinderMesh_h7awq"]
top_radius = 0.772
bottom_radius = 0.772
height = 8.0
radial_segments = 16
rings = 0
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_kkw7a"]
resource_local_to_scene = true
albedo_texture = ExtResource("4_h7awq")
uv1_scale = Vector3(1, 3.07, 1)
[sub_resource type="CylinderMesh" id="CylinderMesh_pmegg"]
top_radius = 0.772
bottom_radius = 0.772
radial_segments = 16
rings = 0
[node name="Flask" type="Area3D" node_paths=PackedStringArray("interactible") groups=["flask"]]
collision_layer = 5
script = ExtResource("1_0xufn")
@ -58,6 +83,23 @@ transform = Transform3D(0.1, 0, 0, 0, 0.1, 0, 0, 0, 0.1, 0, 0.1, 0)
mesh = SubResource("ArrayMesh_nvewc")
skeleton = NodePath("")
[node name="FillLiquid" type="MeshInstance3D" parent="Flash"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3.8061247, 0)
visible = false
material_override = SubResource("StandardMaterial3D_ailwx")
mesh = SubResource("CylinderMesh_h7awq")
skeleton = NodePath("")
script = ExtResource("3_0xufn")
[node name="FillSolid" type="MeshInstance3D" parent="Flash"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8061155, 0)
visible = false
material_override = SubResource("StandardMaterial3D_kkw7a")
mesh = SubResource("CylinderMesh_pmegg")
skeleton = NodePath("")
script = ExtResource("3_0xufn")
display_type = 1
[node name="Inventory" type="Node" parent="."]
unique_name_in_owner = true
script = ExtResource("7_h7awq")
@ -65,5 +107,35 @@ open_on_top = true
metadata/_custom_type_script = "uid://82ettbegollp"
[node name="Interactible" type="ConfirmationDialog" parent="."]
cancel_button_text = "I WANNA MAKE YOU HATE ME"
oversampling_override = 1.0
title = "Перелить вещество в колбе?"
position = Vector2i(0, 36)
size = Vector2i(301, 100)
ok_button_text = "Перелить"
cancel_button_text = "Нет"
script = ExtResource("4_dbm1u")
[node name="HBoxContainer" type="HBoxContainer" parent="Interactible"]
offset_left = 8.0
offset_top = 8.0
offset_right = 293.0
offset_bottom = 51.0
[node name="Label" type="Label" parent="Interactible/HBoxContainer"]
layout_mode = 2
text = "000%"
[node name="HSlider" type="HSlider" parent="Interactible/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
max_value = 1.0
step = 0.01
value = 1.0
[node name="Interaction" type="Node" parent="Interactible"]
script = ExtResource("5_pmegg")
[connection signal="inventory_changed" from="Inventory" to="Flash/FillLiquid" method="update_material_unfiltered"]
[connection signal="inventory_changed" from="Inventory" to="Flash/FillSolid" method="update_material_unfiltered"]
[connection signal="interacted" from="Interactible" to="Interactible/Interaction" method="_on_interactible_interacted"]
[connection signal="value_changed" from="Interactible/HBoxContainer/HSlider" to="Interactible/Interaction" method="_on_h_slider_value_changed"]

View file

@ -29,11 +29,11 @@ size_flags_vertical = 3
[node name="Label" type="Label" parent="."]
layout_mode = 1
anchors_preset = -1
anchor_left = 1.0
anchor_left = 0.97900003
anchor_top = 0.0014401659
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -25.0
offset_left = -0.28308105
offset_top = 647.0668
offset_right = 622.0668
offset_bottom = 49.0

51
scenes/spoon.tscn Normal file
View file

@ -0,0 +1,51 @@
[gd_scene load_steps=10 format=3 uid="uid://emm545mj0kba"]
[ext_resource type="ArrayMesh" uid="uid://cdvben7q8oxgf" path="res://assets/meshes/spoon.res" id="1_l12hh"]
[ext_resource type="Script" uid="uid://bjnv2g1ni0525" path="res://src/drag/draggable_object.gd" id="1_r8mox"]
[ext_resource type="Texture2D" uid="uid://cw3jw8qbvj3fv" path="res://assets/textures/solid.png" id="3_ckduo"]
[ext_resource type="Script" uid="uid://bl0ojhc0thk1p" path="res://src/interactible/interactible.gd" id="3_r8ydw"]
[ext_resource type="ArrayMesh" uid="uid://n4ibk6y8t7h3" path="res://assets/meshes/spoon_fill.res" id="4_5mau7"]
[ext_resource type="Script" uid="uid://cefmx4p018028" path="res://src/interactible/spoon_interaction.gd" id="4_fyayl"]
[ext_resource type="Script" uid="uid://dig825r70a0sn" path="res://src/substance_display.gd" id="5_33jiv"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_1r65c"]
albedo_texture = ExtResource("3_ckduo")
[sub_resource type="BoxShape3D" id="BoxShape3D_r8mox"]
size = Vector3(0.26538086, 0.1484375, 1.6950684)
[node name="Spoon" type="Area3D" node_paths=PackedStringArray("interactible")]
collision_layer = 6
script = ExtResource("1_r8mox")
interactible = NodePath("Interactible")
mask = PackedStringArray("flask", "solid_source")
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
transform = Transform3D(0.1, 0, 0, 0, 0.1, 0, 0, 0, 0.1, 0, 0.07224345, 0)
mesh = ExtResource("1_l12hh")
[node name="SpoonFill" type="MeshInstance3D" parent="."]
transform = Transform3D(0.1, 0, 0, 0, 0.1, 0, 0, 0, 0.1, 0, 0.07224345, -0.66295564)
visible = false
material_override = SubResource("StandardMaterial3D_1r65c")
mesh = ExtResource("4_5mau7")
script = ExtResource("5_33jiv")
display_type = 1
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.07224345, 0)
shape = SubResource("BoxShape3D_r8mox")
[node name="Interactible" type="ConfirmationDialog" parent="."]
title = ""
ok_button_text = "Подтвердить"
cancel_button_text = "Отменить"
script = ExtResource("3_r8ydw")
instant = true
metadata/_custom_type_script = "uid://bl0ojhc0thk1p"
[node name="Interaction" type="Node" parent="Interactible"]
script = ExtResource("4_fyayl")
[connection signal="interacted" from="Interactible" to="Interactible/Interaction" method="_on_interactible_interacted"]
[connection signal="inventory_updated" from="Interactible/Interaction" to="SpoonFill" method="update_material_unfiltered"]

View file

@ -1,13 +1,15 @@
[gd_scene load_steps=8 format=3 uid="uid://cw6v8kbi76qak"]
[gd_scene load_steps=9 format=3 uid="uid://cw6v8kbi76qak"]
[ext_resource type="Script" uid="uid://bjnv2g1ni0525" path="res://src/drag/draggable_object.gd" id="1_o7vug"]
[ext_resource type="ArrayMesh" uid="uid://dddqboph2ygmw" path="res://assets/meshes/jar.res" id="2_o7vug"]
[ext_resource type="Script" uid="uid://bl0ojhc0thk1p" path="res://src/interactible/interactible.gd" id="5_o7vug"]
[ext_resource type="Script" uid="uid://bhnptwotw5bs8" path="res://src/interactible/substance_jar_interaction.gd" id="6_00jpx"]
[ext_resource type="ArrayMesh" uid="uid://dxeseuqcwne1m" path="res://assets/meshes/jar_fill.res" id="6_kfk5m"]
[ext_resource type="Script" uid="uid://c8epd7gguvyop" path="res://src/substance_holder.gd" id="7_ymvgp"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_pcpcb"]
resource_local_to_scene = true
transparency = 1
[sub_resource type="CylinderShape3D" id="CylinderShape3D_kfk5m"]
height = 0.5024414
@ -17,6 +19,7 @@ radius = 0.22460938
collision_layer = 5
script = ExtResource("1_o7vug")
interactible = NodePath("Interaction")
mask = PackedStringArray("flask")
[node name="Jar" type="MeshInstance3D" parent="."]
transform = Transform3D(0.2, 0, 0, 0, 0.2, 0, 0, 0, 0.2, 0, 0, 0)
@ -35,4 +38,28 @@ shape = SubResource("CylinderShape3D_kfk5m")
script = ExtResource("7_ymvgp")
[node name="Interaction" type="ConfirmationDialog" parent="."]
title = "Добавить вещество?"
ok_button_text = "Добавить"
cancel_button_text = "Не добавлять"
script = ExtResource("5_o7vug")
[node name="HBoxContainer" type="HBoxContainer" parent="Interaction"]
offset_right = 40.0
offset_bottom = 40.0
[node name="ProgressBar" type="HSlider" parent="Interaction/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
allow_greater = true
[node name="SpinBox" type="SpinBox" parent="Interaction/HBoxContainer"]
layout_mode = 2
allow_greater = true
suffix = "мг."
[node name="Interaction" type="Node" parent="Interaction"]
script = ExtResource("6_00jpx")
[connection signal="interacted" from="Interaction" to="Interaction/Interaction" method="_on_interaction_interacted"]
[connection signal="value_changed" from="Interaction/HBoxContainer/ProgressBar" to="Interaction/Interaction" method="_on_progress_bar_value_changed"]
[connection signal="value_changed" from="Interaction/HBoxContainer/SpinBox" to="Interaction/Interaction" method="_on_spin_box_value_changed"]

View file

@ -1,9 +1,10 @@
[gd_scene load_steps=5 format=3 uid="uid://dfxlr4svnsdyx"]
[gd_scene load_steps=6 format=3 uid="uid://dfxlr4svnsdyx"]
[ext_resource type="PackedScene" uid="uid://bcj0mesdlfsfj" path="res://scenes/popup_container.tscn" id="1_nt7q6"]
[ext_resource type="Script" uid="uid://c5pv2idedy1oy" path="res://src/ui/reagents_gen.gd" id="2_x4jx1"]
[ext_resource type="PackedScene" uid="uid://vhn8h4mhb6nh" path="res://scenes/drag_and_drop.tscn" id="3_yev5y"]
[ext_resource type="Resource" uid="uid://cay05wpketmny" path="res://assets/draggables/test_draggable.tres" id="4_gdt2y"]
[ext_resource type="Resource" uid="uid://cay05wpketmny" path="res://assets/draggables/flask.tres" id="4_gdt2y"]
[ext_resource type="Resource" uid="uid://6vpr6n7yruie" path="res://assets/draggables/spoon.tres" id="5_wm3ai"]
[node name="UserInterface" type="Control"]
layout_mode = 3
@ -49,9 +50,14 @@ anchor_right = 0.0
text = "Инструменты"
metadata/_edit_use_anchors_ = true
[node name="DragAndDrop" parent="Intruments/ScrollContainer/VBoxContainer" index="0" instance=ExtResource("3_yev5y")]
[node name="Flask" parent="Intruments/ScrollContainer/VBoxContainer" index="0" instance=ExtResource("3_yev5y")]
layout_mode = 2
text = "Пробирка"
draggable = ExtResource("4_gdt2y")
[node name="Spoon" parent="Intruments/ScrollContainer/VBoxContainer" index="1" instance=ExtResource("3_yev5y")]
layout_mode = 2
text = "Ложка"
draggable = ExtResource("5_wm3ai")
[editable path="Intruments"]