Interactions
This commit is contained in:
parent
22cdc782f9
commit
4f6c151e25
31 changed files with 498 additions and 12 deletions
11
assets/draggables/spoon.tres
Normal file
11
assets/draggables/spoon.tres
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
[gd_resource type="Resource" script_class="Draggable" load_steps=4 format=3 uid="uid://6vpr6n7yruie"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://bdyc1cwthn845" path="res://icon.svg" id="1_d0umj"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://emm545mj0kba" path="res://scenes/spoon.tscn" id="2_d0umj"]
|
||||||
|
[ext_resource type="Script" uid="uid://b3i73cilpra74" path="res://src/resources/draggable.gd" id="3_bov6l"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("3_bov6l")
|
||||||
|
scene_to_spawn = ExtResource("2_d0umj")
|
||||||
|
icon = ExtResource("1_d0umj")
|
||||||
|
metadata/_custom_type_script = "uid://b3i73cilpra74"
|
||||||
BIN
assets/meshes/big_flask.res
Normal file
BIN
assets/meshes/big_flask.res
Normal file
Binary file not shown.
BIN
assets/meshes/big_flask_fill.res
Normal file
BIN
assets/meshes/big_flask_fill.res
Normal file
Binary file not shown.
Binary file not shown.
BIN
assets/meshes/spoon.res
Normal file
BIN
assets/meshes/spoon.res
Normal file
Binary file not shown.
BIN
assets/meshes/spoon_fill.res
Normal file
BIN
assets/meshes/spoon_fill.res
Normal file
Binary file not shown.
|
|
@ -67,6 +67,42 @@ _subresources={
|
||||||
"save_to_file/enabled": true,
|
"save_to_file/enabled": true,
|
||||||
"save_to_file/fallback_path": "res://assets/meshes/jar.res",
|
"save_to_file/fallback_path": "res://assets/meshes/jar.res",
|
||||||
"save_to_file/path": "uid://dddqboph2ygmw"
|
"save_to_file/path": "uid://dddqboph2ygmw"
|
||||||
|
},
|
||||||
|
"Chemistry_Sphere_001": {
|
||||||
|
"generate/lightmap_uv": 0,
|
||||||
|
"generate/lods": 0,
|
||||||
|
"generate/shadow_meshes": 0,
|
||||||
|
"lods/normal_merge_angle": 20.0,
|
||||||
|
"save_to_file/enabled": true,
|
||||||
|
"save_to_file/fallback_path": "res://assets/meshes/spoon.res",
|
||||||
|
"save_to_file/path": "uid://cdvben7q8oxgf"
|
||||||
|
},
|
||||||
|
"Chemistry_Sphere_003": {
|
||||||
|
"generate/lightmap_uv": 0,
|
||||||
|
"generate/lods": 0,
|
||||||
|
"generate/shadow_meshes": 0,
|
||||||
|
"lods/normal_merge_angle": 20.0,
|
||||||
|
"save_to_file/enabled": true,
|
||||||
|
"save_to_file/fallback_path": "res://assets/meshes/Chemistry_Sphere_003.res",
|
||||||
|
"save_to_file/path": "uid://q71x8vx4dkis"
|
||||||
|
},
|
||||||
|
"Chemistry_Sphere_004": {
|
||||||
|
"generate/lightmap_uv": 0,
|
||||||
|
"generate/lods": 0,
|
||||||
|
"generate/shadow_meshes": 0,
|
||||||
|
"lods/normal_merge_angle": 20.0,
|
||||||
|
"save_to_file/enabled": true,
|
||||||
|
"save_to_file/fallback_path": "res://assets/meshes/Chemistry_Sphere_004.res",
|
||||||
|
"save_to_file/path": "uid://bsigmbc20m6pn"
|
||||||
|
},
|
||||||
|
"Chemistry_Sphere_005": {
|
||||||
|
"generate/lightmap_uv": 0,
|
||||||
|
"generate/lods": 0,
|
||||||
|
"generate/shadow_meshes": 0,
|
||||||
|
"lods/normal_merge_angle": 20.0,
|
||||||
|
"save_to_file/enabled": true,
|
||||||
|
"save_to_file/fallback_path": "res://assets/meshes/Chemistry_Sphere_005.res",
|
||||||
|
"save_to_file/path": "uid://n4ibk6y8t7h3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
38
assets/reactions/ch3oona_p_hcl.tres
Normal file
38
assets/reactions/ch3oona_p_hcl.tres
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
[gd_resource type="Resource" script_class="Reaction" load_steps=11 format=3 uid="uid://norc8wahican"]
|
||||||
|
|
||||||
|
[ext_resource type="Resource" uid="uid://dr65qbkum4emy" path="res://assets/substances/CH3COONa.tres" id="2_8tq4d"]
|
||||||
|
[ext_resource type="Script" uid="uid://dwks86y6383p4" path="res://src/resources/reaction.gd" id="2_fmr2g"]
|
||||||
|
[ext_resource type="Script" uid="uid://bb8o8l6u6fiai" path="res://src/resources/reaction_substance.gd" id="2_mw1oh"]
|
||||||
|
[ext_resource type="Resource" uid="uid://bj3cdfwvgksee" path="res://assets/substances/HCl.tres" id="3_kro01"]
|
||||||
|
[ext_resource type="Resource" uid="uid://dn10p6rbdd7qb" path="res://assets/substances/CH3COOH.tres" id="4_2pq7p"]
|
||||||
|
[ext_resource type="Resource" uid="uid://chdrv5i45chwe" path="res://assets/substances/NaCl.tres" id="5_2dv8g"]
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_ad7jh"]
|
||||||
|
script = ExtResource("2_mw1oh")
|
||||||
|
coefficient = 1
|
||||||
|
substance = ExtResource("2_8tq4d")
|
||||||
|
metadata/_custom_type_script = "uid://bb8o8l6u6fiai"
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_ohxs7"]
|
||||||
|
script = ExtResource("2_mw1oh")
|
||||||
|
coefficient = 1
|
||||||
|
substance = ExtResource("3_kro01")
|
||||||
|
metadata/_custom_type_script = "uid://bb8o8l6u6fiai"
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_6x1ca"]
|
||||||
|
script = ExtResource("2_mw1oh")
|
||||||
|
coefficient = 1
|
||||||
|
substance = ExtResource("4_2pq7p")
|
||||||
|
metadata/_custom_type_script = "uid://bb8o8l6u6fiai"
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_h3tvm"]
|
||||||
|
script = ExtResource("2_mw1oh")
|
||||||
|
coefficient = 1
|
||||||
|
substance = ExtResource("5_2dv8g")
|
||||||
|
metadata/_custom_type_script = "uid://bb8o8l6u6fiai"
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("2_fmr2g")
|
||||||
|
input_substances = Array[ExtResource("2_mw1oh")]([SubResource("Resource_ad7jh"), SubResource("Resource_ohxs7")])
|
||||||
|
output_substances = Array[ExtResource("2_mw1oh")]([SubResource("Resource_6x1ca"), SubResource("Resource_h3tvm")])
|
||||||
|
metadata/_custom_type_script = "uid://dwks86y6383p4"
|
||||||
11
assets/substances/H2O.tres
Normal file
11
assets/substances/H2O.tres
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
[gd_resource type="Resource" script_class="Substance" load_steps=2 format=3 uid="uid://dp0e62nxlnaeg"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://b8q5buwgvppyh" path="res://src/resources/substance.gd" id="1_nb8j3"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_nb8j3")
|
||||||
|
formula = &"H_2O"
|
||||||
|
scientific_name = &"Вода"
|
||||||
|
boiling_point = 100.0
|
||||||
|
color = Color(1, 1, 1, 1)
|
||||||
|
metadata/_custom_type_script = "uid://b8q5buwgvppyh"
|
||||||
|
|
@ -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="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="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="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"]
|
[ext_resource type="Script" uid="uid://82ettbegollp" path="res://src/inventory.gd" id="7_h7awq"]
|
||||||
|
|
||||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_vcwhe"]
|
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_vcwhe"]
|
||||||
|
|
@ -43,6 +46,28 @@ _surfaces = [{
|
||||||
blend_shape_mode = 0
|
blend_shape_mode = 0
|
||||||
shadow_mesh = SubResource("ArrayMesh_1ouf4")
|
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"]]
|
[node name="Flask" type="Area3D" node_paths=PackedStringArray("interactible") groups=["flask"]]
|
||||||
collision_layer = 5
|
collision_layer = 5
|
||||||
script = ExtResource("1_0xufn")
|
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")
|
mesh = SubResource("ArrayMesh_nvewc")
|
||||||
skeleton = NodePath("")
|
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="."]
|
[node name="Inventory" type="Node" parent="."]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
script = ExtResource("7_h7awq")
|
script = ExtResource("7_h7awq")
|
||||||
|
|
@ -65,5 +107,35 @@ open_on_top = true
|
||||||
metadata/_custom_type_script = "uid://82ettbegollp"
|
metadata/_custom_type_script = "uid://82ettbegollp"
|
||||||
|
|
||||||
[node name="Interactible" type="ConfirmationDialog" parent="."]
|
[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")
|
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"]
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,11 @@ size_flags_vertical = 3
|
||||||
[node name="Label" type="Label" parent="."]
|
[node name="Label" type="Label" parent="."]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = -1
|
anchors_preset = -1
|
||||||
anchor_left = 1.0
|
anchor_left = 0.97900003
|
||||||
anchor_top = 0.0014401659
|
anchor_top = 0.0014401659
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
offset_left = -25.0
|
offset_left = -0.28308105
|
||||||
offset_top = 647.0668
|
offset_top = 647.0668
|
||||||
offset_right = 622.0668
|
offset_right = 622.0668
|
||||||
offset_bottom = 49.0
|
offset_bottom = 49.0
|
||||||
|
|
|
||||||
51
scenes/spoon.tscn
Normal file
51
scenes/spoon.tscn
Normal 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"]
|
||||||
|
|
@ -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="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="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://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="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"]
|
[ext_resource type="Script" uid="uid://c8epd7gguvyop" path="res://src/substance_holder.gd" id="7_ymvgp"]
|
||||||
|
|
||||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_pcpcb"]
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_pcpcb"]
|
||||||
resource_local_to_scene = true
|
resource_local_to_scene = true
|
||||||
|
transparency = 1
|
||||||
|
|
||||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_kfk5m"]
|
[sub_resource type="CylinderShape3D" id="CylinderShape3D_kfk5m"]
|
||||||
height = 0.5024414
|
height = 0.5024414
|
||||||
|
|
@ -17,6 +19,7 @@ radius = 0.22460938
|
||||||
collision_layer = 5
|
collision_layer = 5
|
||||||
script = ExtResource("1_o7vug")
|
script = ExtResource("1_o7vug")
|
||||||
interactible = NodePath("Interaction")
|
interactible = NodePath("Interaction")
|
||||||
|
mask = PackedStringArray("flask")
|
||||||
|
|
||||||
[node name="Jar" type="MeshInstance3D" parent="."]
|
[node name="Jar" type="MeshInstance3D" parent="."]
|
||||||
transform = Transform3D(0.2, 0, 0, 0, 0.2, 0, 0, 0, 0.2, 0, 0, 0)
|
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")
|
script = ExtResource("7_ymvgp")
|
||||||
|
|
||||||
[node name="Interaction" type="ConfirmationDialog" parent="."]
|
[node name="Interaction" type="ConfirmationDialog" parent="."]
|
||||||
|
title = "Добавить вещество?"
|
||||||
|
ok_button_text = "Добавить"
|
||||||
|
cancel_button_text = "Не добавлять"
|
||||||
script = ExtResource("5_o7vug")
|
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"]
|
||||||
|
|
|
||||||
|
|
@ -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="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="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="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"]
|
[node name="UserInterface" type="Control"]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
|
|
@ -49,9 +50,14 @@ anchor_right = 0.0
|
||||||
text = "Инструменты"
|
text = "Инструменты"
|
||||||
metadata/_edit_use_anchors_ = true
|
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
|
layout_mode = 2
|
||||||
text = "Пробирка"
|
text = "Пробирка"
|
||||||
draggable = ExtResource("4_gdt2y")
|
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"]
|
[editable path="Intruments"]
|
||||||
|
|
|
||||||
12
src/interactible/flask_interaction.gd
Normal file
12
src/interactible/flask_interaction.gd
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
var amount: float = 1.0
|
||||||
|
|
||||||
|
func _on_interactible_interacted(with: DraggableObject) -> void:
|
||||||
|
if with.is_in_group("flask"):
|
||||||
|
with.get_node("%Inventory").add_inventory(%Inventory.extract(%Inventory.total_amount * amount))
|
||||||
|
|
||||||
|
|
||||||
|
func _on_h_slider_value_changed(value: float) -> void:
|
||||||
|
amount = value
|
||||||
|
$"../HBoxContainer/Label".text = str(int(value*100.0)).pad_zeros(3) + "%"
|
||||||
1
src/interactible/flask_interaction.gd.uid
Normal file
1
src/interactible/flask_interaction.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://duirfi4j26g2i
|
||||||
|
|
@ -7,6 +7,7 @@ class_name Interactible
|
||||||
var current_draggable: DraggableObject
|
var current_draggable: DraggableObject
|
||||||
var current_interaction: Interactible
|
var current_interaction: Interactible
|
||||||
|
|
||||||
|
signal begin_interaction(with: DraggableObject)
|
||||||
signal interacted(with: DraggableObject)
|
signal interacted(with: DraggableObject)
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
|
@ -16,6 +17,8 @@ func _ready() -> void:
|
||||||
|
|
||||||
func try_interact(draggable: DraggableObject) -> bool:
|
func try_interact(draggable: DraggableObject) -> bool:
|
||||||
if draggable.interactible != null and visible == false:
|
if draggable.interactible != null and visible == false:
|
||||||
|
current_draggable = draggable
|
||||||
|
begin_interaction.emit(current_draggable)
|
||||||
if instant:
|
if instant:
|
||||||
interact()
|
interact()
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
20
src/interactible/spoon_interaction.gd
Normal file
20
src/interactible/spoon_interaction.gd
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
var mini_inventory: Array[RuntimeSubstanceData] = []
|
||||||
|
signal inventory_updated(substances: Array[RuntimeSubstanceData])
|
||||||
|
|
||||||
|
func _on_interactible_interacted(with: DraggableObject) -> void:
|
||||||
|
if with.is_in_group("solid_source") and mini_inventory == []:
|
||||||
|
mini_inventory = [RuntimeSubstanceData.new()]
|
||||||
|
mini_inventory[0].substance = with.get_node("SubstanceData").substance
|
||||||
|
mini_inventory[0].amount = 5
|
||||||
|
mini_inventory[0].temperature = 20
|
||||||
|
elif with.is_in_group("solid_source") and mini_inventory != []:
|
||||||
|
mini_inventory = []
|
||||||
|
elif with.is_in_group("flask") and mini_inventory != []:
|
||||||
|
with.get_node("%Inventory").add_inventory(mini_inventory)
|
||||||
|
mini_inventory = []
|
||||||
|
|
||||||
|
elif with.is_in_group("flask") and mini_inventory == []:
|
||||||
|
mini_inventory = with.get_node("%Inventory").extract_solid(5)
|
||||||
|
inventory_updated.emit(mini_inventory)
|
||||||
1
src/interactible/spoon_interaction.gd.uid
Normal file
1
src/interactible/spoon_interaction.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://cefmx4p018028
|
||||||
22
src/interactible/substance_jar_interaction.gd
Normal file
22
src/interactible/substance_jar_interaction.gd
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
var add_amount: float
|
||||||
|
|
||||||
|
func _on_interaction_interacted(with: DraggableObject) -> void:
|
||||||
|
if with.is_in_group("flask"):
|
||||||
|
var subs: RuntimeSubstanceData = RuntimeSubstanceData.new()
|
||||||
|
subs.amount = add_amount
|
||||||
|
subs.substance = $"../../SubstanceData".substance
|
||||||
|
subs.temperature = 20
|
||||||
|
with.get_node("%Inventory").add_substance(subs)
|
||||||
|
$"../HBoxContainer/SpinBox".value = 0
|
||||||
|
|
||||||
|
|
||||||
|
func _on_progress_bar_value_changed(value: float) -> void:
|
||||||
|
$"../HBoxContainer/SpinBox".set_value_no_signal(value)
|
||||||
|
add_amount = value
|
||||||
|
|
||||||
|
|
||||||
|
func _on_spin_box_value_changed(value: float) -> void:
|
||||||
|
$"../HBoxContainer/ProgressBar".set_value_no_signal(value)
|
||||||
|
add_amount = value
|
||||||
1
src/interactible/substance_jar_interaction.gd.uid
Normal file
1
src/interactible/substance_jar_interaction.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://bhnptwotw5bs8
|
||||||
107
src/inventory.gd
107
src/inventory.gd
|
|
@ -3,4 +3,109 @@ extends Node
|
||||||
class_name Inventory
|
class_name Inventory
|
||||||
|
|
||||||
@export var open_on_top: bool
|
@export var open_on_top: bool
|
||||||
var inventory: Array[RuntimeSubstanceData]
|
var inventory: Dictionary[StringName,RuntimeSubstanceData]
|
||||||
|
|
||||||
|
var mean_temperature: float:
|
||||||
|
set(new_temperature):
|
||||||
|
mean_temperature = new_temperature
|
||||||
|
temperature_changed.emit(new_temperature)
|
||||||
|
update_temperature()
|
||||||
|
|
||||||
|
var total_amount: float:
|
||||||
|
set(value):
|
||||||
|
pass
|
||||||
|
get:
|
||||||
|
var result: float = 0
|
||||||
|
for sub in inventory:
|
||||||
|
result += inventory[sub].amount
|
||||||
|
return result
|
||||||
|
|
||||||
|
signal inventory_changed(substances: Array[RuntimeSubstanceData])
|
||||||
|
signal temperature_changed(to: float)
|
||||||
|
|
||||||
|
func add_substance(data: RuntimeSubstanceData) -> void:
|
||||||
|
if data.substance.scientific_name in inventory:
|
||||||
|
inventory[data.substance.scientific_name].add(data)
|
||||||
|
else:
|
||||||
|
inventory[data.substance.scientific_name] = data
|
||||||
|
check_for_reactions()
|
||||||
|
recalculate_temperature()
|
||||||
|
inventory_changed.emit(inventory.values())
|
||||||
|
|
||||||
|
func add_inventory(substances: Array[RuntimeSubstanceData]) -> void:
|
||||||
|
for sub in substances:
|
||||||
|
add_substance(sub)
|
||||||
|
|
||||||
|
func extract(amount: float) -> Array[RuntimeSubstanceData]:
|
||||||
|
if len(inventory) == 0:
|
||||||
|
return []
|
||||||
|
var result: Array[RuntimeSubstanceData] = []
|
||||||
|
var extract_amount = amount/len(inventory)
|
||||||
|
var sorted_by_amount: Array[RuntimeSubstanceData] = inventory.values()
|
||||||
|
sorted_by_amount.sort_custom(sort_by_amount)
|
||||||
|
|
||||||
|
for substance: RuntimeSubstanceData in sorted_by_amount:
|
||||||
|
var result_substance: RuntimeSubstanceData = substance.duplicate()
|
||||||
|
if substance.amount >= extract_amount:
|
||||||
|
result_substance.amount = extract_amount
|
||||||
|
inventory[result_substance.substance.scientific_name].amount -= extract_amount
|
||||||
|
else:
|
||||||
|
extract_amount += (extract_amount - result_substance.amount)/len(sorted_by_amount)
|
||||||
|
inventory[result_substance.substance.scientific_name].amount = 0
|
||||||
|
result.append(result_substance)
|
||||||
|
if inventory[result_substance.substance.scientific_name].amount == 0:
|
||||||
|
inventory.erase(result_substance.substance.scientific_name)
|
||||||
|
|
||||||
|
inventory_changed.emit(inventory.values())
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
func extract_solid(amount: float) -> Array[RuntimeSubstanceData]:
|
||||||
|
if len(inventory) == 0:
|
||||||
|
return []
|
||||||
|
var result: Array[RuntimeSubstanceData] = []
|
||||||
|
var extract_amount = amount/len(inventory)
|
||||||
|
var sorted_by_amount: Array[RuntimeSubstanceData] = inventory.values()
|
||||||
|
sorted_by_amount.sort_custom(sort_by_amount)
|
||||||
|
sorted_by_amount = sorted_by_amount.filter(filter_solids)
|
||||||
|
|
||||||
|
for substance: RuntimeSubstanceData in sorted_by_amount:
|
||||||
|
var result_substance: RuntimeSubstanceData = substance.duplicate()
|
||||||
|
if substance.amount >= extract_amount:
|
||||||
|
result_substance.amount = extract_amount
|
||||||
|
inventory[result_substance.substance.scientific_name].amount -= extract_amount
|
||||||
|
else:
|
||||||
|
extract_amount += (extract_amount - result_substance.amount)/len(sorted_by_amount)
|
||||||
|
inventory[result_substance.substance.scientific_name].amount = 0
|
||||||
|
result.append(result_substance)
|
||||||
|
if inventory[result_substance.substance.scientific_name].amount == 0:
|
||||||
|
inventory.erase(result_substance.substance.scientific_name)
|
||||||
|
|
||||||
|
inventory_changed.emit(inventory.values())
|
||||||
|
return result
|
||||||
|
|
||||||
|
func sort_by_amount(a: RuntimeSubstanceData, b: RuntimeSubstanceData) -> bool:
|
||||||
|
return a.amount < b.amount
|
||||||
|
|
||||||
|
func filter_solids(a: RuntimeSubstanceData) -> bool:
|
||||||
|
return a.substance.melting_point > a.temperature
|
||||||
|
|
||||||
|
func update_temperature() -> void:
|
||||||
|
if len(inventory) == 0:
|
||||||
|
mean_temperature = 0
|
||||||
|
return
|
||||||
|
for sub in inventory:
|
||||||
|
inventory[sub].temperature = mean_temperature
|
||||||
|
check_for_reactions()
|
||||||
|
|
||||||
|
func recalculate_temperature() -> void:
|
||||||
|
if len(inventory) == 0:
|
||||||
|
mean_temperature = 0
|
||||||
|
return
|
||||||
|
var temperature_sum: float = 0
|
||||||
|
for sub in inventory:
|
||||||
|
temperature_sum += inventory[sub].temperature
|
||||||
|
mean_temperature = temperature_sum / len(inventory)
|
||||||
|
|
||||||
|
func check_for_reactions() -> void:
|
||||||
|
pass
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,6 @@ extends Resource
|
||||||
|
|
||||||
class_name Reaction
|
class_name Reaction
|
||||||
|
|
||||||
@export var input_substances: Array[Substance]
|
@export var input_substances: Array[ReactionSubstance]
|
||||||
@export var output_substances: Array[Substance]
|
@export var output_substances: Array[ReactionSubstance]
|
||||||
@export var reaction_temperature: float = -1
|
@export var reaction_temperature: float = -1
|
||||||
|
|
|
||||||
6
src/resources/reaction_substance.gd
Normal file
6
src/resources/reaction_substance.gd
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
extends Resource
|
||||||
|
|
||||||
|
class_name ReactionSubstance
|
||||||
|
|
||||||
|
@export var coefficient: int
|
||||||
|
@export var substance: Substance
|
||||||
1
src/resources/reaction_substance.gd.uid
Normal file
1
src/resources/reaction_substance.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://bb8o8l6u6fiai
|
||||||
|
|
@ -6,6 +6,7 @@ class_name Substance
|
||||||
@export var scientific_name: StringName
|
@export var scientific_name: StringName
|
||||||
@export var melting_point: float
|
@export var melting_point: float
|
||||||
@export var boiling_point: float
|
@export var boiling_point: float
|
||||||
|
@export var liquid_transparency: float = 0.5
|
||||||
@export var color: Color
|
@export var color: Color
|
||||||
@export var prefer_scientific_name: bool
|
@export var prefer_scientific_name: bool
|
||||||
@export var is_solution: bool
|
@export var is_solution: bool
|
||||||
|
|
|
||||||
|
|
@ -5,3 +5,15 @@ class_name RuntimeSubstanceData
|
||||||
var substance: Substance
|
var substance: Substance
|
||||||
var amount: float
|
var amount: float
|
||||||
var temperature: float = 20.0
|
var temperature: float = 20.0
|
||||||
|
|
||||||
|
func add(data: RuntimeSubstanceData) -> void:
|
||||||
|
temperature = (temperature + data.temperature)/2.0
|
||||||
|
amount += data.amount
|
||||||
|
|
||||||
|
func duplicate() -> RuntimeSubstanceData:
|
||||||
|
var new_substance = RuntimeSubstanceData.new()
|
||||||
|
new_substance.substance = substance
|
||||||
|
new_substance.amount = amount
|
||||||
|
new_substance.temperature = temperature
|
||||||
|
|
||||||
|
return new_substance
|
||||||
|
|
|
||||||
46
src/substance_display.gd
Normal file
46
src/substance_display.gd
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
extends MeshInstance3D
|
||||||
|
|
||||||
|
enum DisplayType{
|
||||||
|
Fluid,
|
||||||
|
Solid,
|
||||||
|
}
|
||||||
|
|
||||||
|
@export var display_type: DisplayType
|
||||||
|
|
||||||
|
func update_material(substances: Array[RuntimeSubstanceData]) -> void:
|
||||||
|
var mat: StandardMaterial3D = material_override
|
||||||
|
if len(substances) == 0:
|
||||||
|
visible = false
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
visible = true
|
||||||
|
|
||||||
|
var total_weight = 0
|
||||||
|
|
||||||
|
for sub in substances:
|
||||||
|
total_weight += sub.amount
|
||||||
|
|
||||||
|
var alpha: float = 0
|
||||||
|
var color: Color = Color.WHITE
|
||||||
|
|
||||||
|
for sub in substances:
|
||||||
|
if display_type == DisplayType.Fluid:
|
||||||
|
alpha += sub.substance.liquid_transparency
|
||||||
|
color = color.lerp(sub.substance.color,sub.amount/total_weight)
|
||||||
|
if display_type == DisplayType.Fluid:
|
||||||
|
alpha /= len(substances)
|
||||||
|
color.a = alpha
|
||||||
|
|
||||||
|
mat.albedo_color = color
|
||||||
|
|
||||||
|
func update_material_unfiltered(substances: Array[RuntimeSubstanceData]):
|
||||||
|
match display_type:
|
||||||
|
DisplayType.Fluid:
|
||||||
|
var fluids = substances.filter(filter_liquids)
|
||||||
|
update_material(fluids)
|
||||||
|
DisplayType.Solid:
|
||||||
|
var solids = substances.filter(filter_solids)
|
||||||
|
update_material(solids)
|
||||||
|
|
||||||
|
func filter_liquids(sub: RuntimeSubstanceData): return sub.substance.melting_point < sub.temperature or sub.substance.is_solution
|
||||||
|
func filter_solids(sub: RuntimeSubstanceData): return sub.substance.melting_point > sub.temperature and not sub.substance.is_solution
|
||||||
1
src/substance_display.gd.uid
Normal file
1
src/substance_display.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://dig825r70a0sn
|
||||||
|
|
@ -9,6 +9,8 @@ func _ready() -> void:
|
||||||
jar_fill_material.albedo_color = substance.color
|
jar_fill_material.albedo_color = substance.color
|
||||||
if substance.melting_point > 20 and not substance.is_solution:
|
if substance.melting_point > 20 and not substance.is_solution:
|
||||||
jar_fill_material.albedo_texture = preload("res://assets/textures/solid.png")
|
jar_fill_material.albedo_texture = preload("res://assets/textures/solid.png")
|
||||||
|
|
||||||
get_parent().add_to_group("solid_source")
|
get_parent().add_to_group("solid_source")
|
||||||
else:
|
else:
|
||||||
|
jar_fill_material.albedo_color.a = substance.liquid_transparency
|
||||||
get_parent().add_to_group("fluid_source")
|
get_parent().add_to_group("fluid_source")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue