diff --git a/.~lock.Работы по химии TODO.docx# b/.~lock.Работы по химии TODO.docx# index 083cc6b..1d8047d 100644 --- a/.~lock.Работы по химии TODO.docx# +++ b/.~lock.Работы по химии TODO.docx# @@ -1 +1 @@ -,rendo,kompikrendo,29.05.2026 16:54,file:///home/rendo/.config/libreoffice/4; \ No newline at end of file +,rendo,kompikrendo,29.06.2026 00:21,file:///home/rendo/.config/libreoffice/4; \ No newline at end of file diff --git a/assets/meshes/Drip_Cylinder.res b/assets/meshes/Drip_Cylinder.res new file mode 100644 index 0000000..e651f8f Binary files /dev/null and b/assets/meshes/Drip_Cylinder.res differ diff --git a/assets/meshes/Drip_Cylinder_001.res b/assets/meshes/Drip_Cylinder_001.res new file mode 100644 index 0000000..176806e Binary files /dev/null and b/assets/meshes/Drip_Cylinder_001.res differ diff --git a/assets/meshes/Drip_Cylinder_004.res b/assets/meshes/Drip_Cylinder_004.res new file mode 100644 index 0000000..4ab9655 Binary files /dev/null and b/assets/meshes/Drip_Cylinder_004.res differ diff --git a/assets/models/Drip.glb.import b/assets/models/Drip.glb.import index e6a5589..561c7cf 100644 --- a/assets/models/Drip.glb.import +++ b/assets/models/Drip.glb.import @@ -16,6 +16,8 @@ dest_files=["res://.godot/imported/Drip.glb-91c932019939c0c57a2bbeb7aa92f14a.scn nodes/root_type="" nodes/root_name="" nodes/root_script=null +mesh_library/use_node_names_as_mesh_names=false +array_mesh/deduplicate_surfaces=true nodes/apply_root_scale=true nodes/root_scale=1.0 nodes/import_as_skeleton_bones=false @@ -44,7 +46,37 @@ _subresources={ "use_external/fallback_path": "res://assets/materials/mat_glass.tres", "use_external/path": "uid://64m17act0kwu" } +}, +"meshes": { +"Drip_Cylinder": { +"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/Drip_Cylinder.res", +"save_to_file/path": "uid://bca7m12sa3g48" +}, +"Drip_Cylinder_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/Drip_Cylinder_001.res", +"save_to_file/path": "uid://dv7q66xtqi55t" +}, +"Drip_Cylinder_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/Drip_Cylinder_004.res", +"save_to_file/path": "uid://dwg7r8hor517p" +} } } gltf/naming_version=2 gltf/embedded_image_handling=1 +gltf/texture_map_mode=1 diff --git a/assets/reactions/hcl_p_naoh.tres b/assets/reactions/hcl_p_naoh.tres index 8f785d7..84a1f46 100644 --- a/assets/reactions/hcl_p_naoh.tres +++ b/assets/reactions/hcl_p_naoh.tres @@ -1,4 +1,4 @@ -[gd_resource type="Resource" script_class="Reaction" load_steps=11 format=3 uid="uid://17oljvqj8f33"] +[gd_resource type="Resource" script_class="Reaction" format=3 uid="uid://17oljvqj8f33"] [ext_resource type="Script" uid="uid://bb8o8l6u6fiai" path="res://src/resources/reaction_substance.gd" id="1_bffrj"] [ext_resource type="Resource" uid="uid://30ym4xb0uu3y" path="res://assets/substances/NaOH.tres" id="2_1nb8s"] diff --git a/assets/reagents/Phenolphtalein.tres b/assets/reagents/Phenolphtalein.tres index fdea53b..f9e3730 100644 --- a/assets/reagents/Phenolphtalein.tres +++ b/assets/reagents/Phenolphtalein.tres @@ -1,9 +1,11 @@ -[gd_resource type="Resource" script_class="Reagent" load_steps=3 format=3 uid="uid://dia0grmva8062"] +[gd_resource type="Resource" script_class="Reagent" format=3 uid="uid://dia0grmva8062"] [ext_resource type="Script" uid="uid://bditqax8ibmxw" path="res://src/resources/reagent.gd" id="1_v8ev6"] [ext_resource type="Resource" uid="uid://brih4gryc1acx" path="res://assets/substances/Phenolphtalein.tres" id="2_ikqma"] +[ext_resource type="PackedScene" uid="uid://t432slq7xiyg" path="res://scenes/substance_jar_alt.tscn" id="2_ta4t0"] [resource] script = ExtResource("1_v8ev6") substance = ExtResource("2_ikqma") +storage = ExtResource("2_ta4t0") metadata/_custom_type_script = "uid://b8q5buwgvppyh" diff --git a/assets/textures/bubble.png.import b/assets/textures/bubble.png.import index 07769dc..46d3ca3 100644 --- a/assets/textures/bubble.png.import +++ b/assets/textures/bubble.png.import @@ -3,19 +3,20 @@ importer="texture" type="CompressedTexture2D" uid="uid://bkuxwtxum1r4x" -path="res://.godot/imported/bubble.png-a4e9df5e78917cd4475ee7b84b1534f0.ctex" +path.s3tc="res://.godot/imported/bubble.png-a4e9df5e78917cd4475ee7b84b1534f0.s3tc.ctex" metadata={ -"vram_texture": false +"imported_formats": ["s3tc_bptc"], +"vram_texture": true } [deps] source_file="res://assets/textures/bubble.png" -dest_files=["res://.godot/imported/bubble.png-a4e9df5e78917cd4475ee7b84b1534f0.ctex"] +dest_files=["res://.godot/imported/bubble.png-a4e9df5e78917cd4475ee7b84b1534f0.s3tc.ctex"] [params] -compress/mode=0 +compress/mode=2 compress/high_quality=false compress/lossy_quality=0.7 compress/uastc_level=0 @@ -23,7 +24,7 @@ compress/rdo_quality_loss=0.0 compress/hdr_compression=1 compress/normal_map=0 compress/channel_pack=0 -mipmaps/generate=false +mipmaps/generate=true mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" @@ -37,4 +38,4 @@ process/normal_map_invert_y=false process/hdr_as_srgb=false process/hdr_clamp_exposure=false process/size_limit=0 -detect_3d/compress_to=1 +detect_3d/compress_to=0 diff --git a/project.godot b/project.godot index 78618d2..fcca46e 100644 --- a/project.godot +++ b/project.godot @@ -16,7 +16,7 @@ compatibility/default_parent_skeleton_in_mesh_instance_3d=true config/name="lab-electrolyte" run/main_scene="uid://c2ciwyjf7au6l" -config/features=PackedStringArray("4.6", "Mobile") +config/features=PackedStringArray("4.7", "Mobile") config/icon="res://icon.svg" [autoload] diff --git a/scenes/bubbles.gd b/scenes/bubbles.gd new file mode 100644 index 0000000..227b91f --- /dev/null +++ b/scenes/bubbles.gd @@ -0,0 +1,18 @@ +extends GPUParticles3D + + +@export var inventory: Inventory +@export var particles: GPUParticles3D +var tween: Tween + +func _on_inventory_reacted_with_gasses(gasses: Array[RuntimeSubstanceData]) -> void: + if tween: + tween.kill() + tween = create_tween() + particles.emitting = true + tween.tween_interval(2.) + tween.tween_callback(func(): + particles.emitting = false + for gas in gasses: + inventory.extract_substance(gas.substance.get_formula(),gas.amount) + ) diff --git a/scenes/bubbles.gd.uid b/scenes/bubbles.gd.uid new file mode 100644 index 0000000..1e475bc --- /dev/null +++ b/scenes/bubbles.gd.uid @@ -0,0 +1 @@ +uid://8jd32taaq5yy diff --git a/scenes/flask.tscn b/scenes/flask.tscn index 19c3a85..d04cc86 100644 --- a/scenes/flask.tscn +++ b/scenes/flask.tscn @@ -7,7 +7,9 @@ [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="Texture2D" uid="uid://bkuxwtxum1r4x" path="res://assets/textures/bubble.png" id="6_rqua0"] [ext_resource type="Script" uid="uid://82ettbegollp" path="res://src/inventory.gd" id="7_h7awq"] +[ext_resource type="Script" uid="uid://8jd32taaq5yy" path="res://scenes/bubbles.gd" id="7_wadb5"] [ext_resource type="Script" uid="uid://mqch4ruivbg8" path="res://src/position_resetter.gd" id="9_kkw7a"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_vcwhe"] @@ -74,6 +76,24 @@ bottom_radius = 0.772 radial_segments = 16 rings = 0 +[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_u7u8q"] +emission_shape_scale = Vector3(0.755, 0.93, 0.755) +emission_shape = 1 +emission_sphere_radius = 1.0 +gravity = Vector3(0, 1, 0) +collision_mode = 1 +collision_friction = 0.0 +collision_bounce = 0.0 + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_t5c10"] +transparency = 1 +albedo_texture = ExtResource("6_rqua0") +billboard_mode = 1 + +[sub_resource type="QuadMesh" id="QuadMesh_iuc1c"] +material = SubResource("StandardMaterial3D_t5c10") +size = Vector2(0.05, 0.05) + [node name="Flask" type="Area3D" unique_id=516093165 node_paths=PackedStringArray("interactible") groups=["flask"]] collision_layer = 5 script = ExtResource("1_0xufn") @@ -89,12 +109,13 @@ 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" unique_id=439339804] +[node name="FillLiquid" type="MeshInstance3D" parent="Flash" unique_id=439339804 node_paths=PackedStringArray("particle_collision")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3.8061247, 0) material_override = SubResource("ShaderMaterial_ailwx") mesh = SubResource("CylinderMesh_h7awq") skeleton = NodePath("") script = ExtResource("3_0xufn") +particle_collision = NodePath("../GPUParticlesCollisionBox3D") [node name="FillSolid" type="MeshInstance3D" parent="Flash" unique_id=390551675] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8061155, 0) @@ -105,6 +126,18 @@ skeleton = NodePath("") script = ExtResource("3_0xufn") display_type = 1 +[node name="GPUParticlesCollisionBox3D" type="GPUParticlesCollisionBox3D" parent="Flash" unique_id=330053589] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5932534, 0) +size = Vector3(2.7734375, 1.1738281, 3.2333984) + +[node name="GPUParticles3D" type="GPUParticles3D" parent="Flash" unique_id=2054685714] +emitting = false +lifetime = 3.0 +local_coords = true +process_material = SubResource("ParticleProcessMaterial_u7u8q") +draw_pass_1 = SubResource("QuadMesh_iuc1c") +script = ExtResource("7_wadb5") + [node name="Inventory" type="Node" parent="." unique_id=1748297338] unique_name_in_owner = true script = ExtResource("7_h7awq") @@ -147,5 +180,6 @@ script = ExtResource("9_kkw7a") [connection signal="drag_started" from="." to="PositionResetter" method="_on_flask_drag_started"] [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="reacted_with_gasses" from="Inventory" to="Flash/GPUParticles3D" method="_on_inventory_reacted_with_gasses"] [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"] diff --git a/scenes/substance_jar_alt.tscn b/scenes/substance_jar_alt.tscn new file mode 100644 index 0000000..fd6bc18 --- /dev/null +++ b/scenes/substance_jar_alt.tscn @@ -0,0 +1,65 @@ +[gd_scene format=3 uid="uid://t432slq7xiyg"] + +[ext_resource type="Script" uid="uid://bjnv2g1ni0525" path="res://src/drag/draggable_object.gd" id="1_ojiag"] +[ext_resource type="ArrayMesh" uid="uid://b5bxc1qinl3gw" path="res://assets/meshes/Drip_Cylinder.res" id="2_ojiag"] +[ext_resource type="ArrayMesh" uid="uid://5aw6ifbhbmu4" path="res://assets/meshes/Drip_Cylinder_001.res" id="3_kbrga"] +[ext_resource type="Script" uid="uid://c8epd7gguvyop" path="res://src/substance_holder.gd" id="4_bxvcb"] +[ext_resource type="Script" uid="uid://bl0ojhc0thk1p" path="res://src/interactible/interactible.gd" id="5_mhyp3"] +[ext_resource type="Script" uid="uid://bhnptwotw5bs8" path="res://src/interactible/substance_jar_interaction.gd" id="6_p0fvg"] + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_pcpcb"] +resource_local_to_scene = true +transparency = 1 + +[sub_resource type="CylinderShape3D" id="CylinderShape3D_kfk5m"] +height = 0.6569824 +radius = 0.32421875 + +[node name="SubstanceJar" type="Area3D" unique_id=904812958 node_paths=PackedStringArray("interactible")] +collision_layer = 5 +script = ExtResource("1_ojiag") +interactible = NodePath("Interaction") +mask = PackedStringArray("flask") + +[node name="Jar" type="MeshInstance3D" parent="." unique_id=985146813] +transform = Transform3D(0.14479385, 0.13796644, 0, -0.13796644, 0.14479385, 0, 0, 0, 0.2, 0.022179853, 0.41104287, 0) +mesh = ExtResource("2_ojiag") + +[node name="JarFill" type="MeshInstance3D" parent="." unique_id=1364277535] +transform = Transform3D(0.14479385, 0.13796644, 0, -0.13796644, 0.14479385, 0, 0, 0, 0.2, 0.050798316, 0.33528638, 0) +material_override = SubResource("StandardMaterial3D_pcpcb") +mesh = ExtResource("3_kbrga") + +[node name="DragArea" type="CollisionShape3D" parent="." unique_id=960002167] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.3272705, 0) +shape = SubResource("CylinderShape3D_kfk5m") + +[node name="SubstanceData" type="Node" parent="." unique_id=1379108671] +script = ExtResource("4_bxvcb") + +[node name="Interaction" type="ConfirmationDialog" parent="." unique_id=1225848265] +title = "Добавить вещество?" +ok_button_text = "Добавить" +cancel_button_text = "Не добавлять" +script = ExtResource("5_mhyp3") + +[node name="HBoxContainer" type="HBoxContainer" parent="Interaction" unique_id=1504866588] +offset_right = 40.0 +offset_bottom = 40.0 + +[node name="ProgressBar" type="HSlider" parent="Interaction/HBoxContainer" unique_id=1037338095] +layout_mode = 2 +size_flags_horizontal = 3 +allow_greater = true + +[node name="SpinBox" type="SpinBox" parent="Interaction/HBoxContainer" unique_id=194740698] +layout_mode = 2 +allow_greater = true +suffix = "мл." + +[node name="Interaction" type="Node" parent="Interaction" unique_id=729724369] +script = ExtResource("6_p0fvg") + +[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"] diff --git a/src/inventory.gd b/src/inventory.gd index 897c283..5a95666 100644 --- a/src/inventory.gd +++ b/src/inventory.gd @@ -23,6 +23,7 @@ var total_amount: float: return result signal inventory_changed(substances: Array[RuntimeSubstanceData], capacity: float) +signal reacted_with_gasses(gasses: Array[RuntimeSubstanceData]) signal temperature_changed(to: float) func _ready() -> void: @@ -179,15 +180,23 @@ func check_for_reactions() -> void: add_substance_no_callback(data) check_for_reactions() recalculate_temperature() + + var gasses = find_gases() + if gasses != []: + reacted_with_gasses.emit(gasses) + update_solutions() inventory_changed.emit(inventory.values(),capacity) GuiSignalBus.push("Произошла реакция") if len(find_odor()) > 0: GuiSignalBus.push("Появился запах") -#func find_gases() -> Array[RuntimeSubstanceData]: -# for key in inventory: -# if inventory[key].substance in [preload("H")] +func find_gases() -> Array[RuntimeSubstanceData]: + var gasses: Array[RuntimeSubstanceData] = [] + for key in inventory: + if inventory[key].substance.boiling_point < mean_temperature: + gasses.append(inventory[key]) + return gasses func find_odor() -> Array[RuntimeSubstanceData]: var result = [] diff --git a/src/substance_display.gd b/src/substance_display.gd index 51805bc..a9f3b60 100644 --- a/src/substance_display.gd +++ b/src/substance_display.gd @@ -11,6 +11,7 @@ enum DisplayType{ var tween = create_tween() material_override.set_shader_parameter("wave_intensity",1.) tween.tween_property(material_override,"shader_parameter/wave_intensity",0.0,2.0) +@export var particle_collision: GPUParticlesCollisionBox3D func update_fluid_material(substances: Array[RuntimeSubstanceData],capacity: float) -> void: var mat: ShaderMaterial = material_override @@ -53,6 +54,7 @@ func update_fluid_material(substances: Array[RuntimeSubstanceData],capacity: flo mat.set_shader_parameter("albedo_color", color / total_color) mat.set_shader_parameter("fill",total_weight/capacity) + particle_collision.position.y = + particle_collision.size.y/2 + position.y - 4 + 8 * total_weight/capacity func update_solid_material(substances: Array[RuntimeSubstanceData]) -> void: var mat: StandardMaterial3D = material_override diff --git a/Работы по химии TODO.docx b/Работы по химии TODO.docx index d22917c..dab894c 100644 Binary files a/Работы по химии TODO.docx and b/Работы по химии TODO.docx differ