This commit is contained in:
rendo 2026-04-24 12:07:46 +05:00
commit 21a4adf229
16 changed files with 136 additions and 24 deletions

View file

@ -1,4 +1,4 @@
[gd_resource type="Resource" script_class="Reaction" load_steps=11 format=3 uid="uid://b84essimpfmee"]
[gd_resource type="Resource" script_class="Reaction" format=3 uid="uid://b84essimpfmee"]
[ext_resource type="Script" uid="uid://bb8o8l6u6fiai" path="res://src/resources/reaction_substance.gd" id="1_rvq0y"]
[ext_resource type="Script" uid="uid://dwks86y6383p4" path="res://src/resources/reaction.gd" id="2_oqih4"]

View file

@ -1,6 +1,7 @@
[gd_resource type="Resource" script_class="Reagent" load_steps=3 format=3 uid="uid://cxpovcqviqurr"]
[gd_resource type="Resource" script_class="Reagent" format=3 uid="uid://cxpovcqviqurr"]
[ext_resource type="Script" uid="uid://bditqax8ibmxw" path="res://src/resources/reagent.gd" id="1_5si53"]
[ext_resource type="PackedScene" uid="uid://cw6v8kbi76qak" path="res://scenes/substance_jar.tscn" id="2_dby88"]
[ext_resource type="Resource" uid="uid://bj3cdfwvgksee" path="res://assets/substances/HCl.tres" id="2_no7s4"]
[resource]

View file

@ -24,6 +24,7 @@ config/icon="res://icon.svg"
GuiSignalBus="*res://src/gui_signal_bus.gd"
ReactionRegistry="*res://src/reaction_registry.gd"
LabRuntime="*uid://b00hrs2a68cpp"
Tooltip="*uid://dtpy85f2ycbur"
[global_group]

View file

@ -51,6 +51,7 @@ shadow_mesh = SubResource("ArrayMesh_1ouf4")
resource_local_to_scene = true
render_priority = 0
shader = ExtResource("4_ailwx")
shader_parameter/albedo_color = Color(0, 0, 0, 1)
shader_parameter/fill = 0.8999999798832
shader_parameter/wave_intensity = 0.0

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=10 format=3 uid="uid://emm545mj0kba"]
[gd_scene 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"]
@ -14,17 +14,17 @@ 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")]
[node name="Spoon" type="Area3D" unique_id=926622416 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="."]
[node name="MeshInstance3D" type="MeshInstance3D" parent="." unique_id=608330635]
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="."]
[node name="SpoonFill" type="MeshInstance3D" parent="." unique_id=209337706]
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")
@ -32,11 +32,11 @@ mesh = ExtResource("4_5mau7")
script = ExtResource("5_33jiv")
display_type = 1
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
[node name="CollisionShape3D" type="CollisionShape3D" parent="." unique_id=537844857]
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="."]
[node name="Interactible" type="ConfirmationDialog" parent="." unique_id=706618502]
title = ""
ok_button_text = "Подтвердить"
cancel_button_text = "Отменить"
@ -44,7 +44,7 @@ script = ExtResource("3_r8ydw")
instant = true
metadata/_custom_type_script = "uid://bl0ojhc0thk1p"
[node name="Interaction" type="Node" parent="Interactible"]
[node name="Interaction" type="Node" parent="Interactible" unique_id=463123349]
script = ExtResource("4_fyayl")
[connection signal="interacted" from="Interactible" to="Interactible/Interaction" method="_on_interactible_interacted"]

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=9 format=3 uid="uid://cw6v8kbi76qak"]
[gd_scene 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"]
@ -15,49 +15,49 @@ transparency = 1
height = 0.5024414
radius = 0.22460938
[node name="SubstanceJar" type="Area3D" node_paths=PackedStringArray("interactible")]
[node name="SubstanceJar" type="Area3D" unique_id=904812958 node_paths=PackedStringArray("interactible")]
collision_layer = 5
script = ExtResource("1_o7vug")
interactible = NodePath("Interaction")
mask = PackedStringArray("flask")
[node name="Jar" type="MeshInstance3D" parent="."]
[node name="Jar" type="MeshInstance3D" parent="." unique_id=985146813]
transform = Transform3D(0.2, 0, 0, 0, 0.2, 0, 0, 0, 0.2, 0, 0, 0)
mesh = ExtResource("2_o7vug")
[node name="JarFill" type="MeshInstance3D" parent="."]
[node name="JarFill" type="MeshInstance3D" parent="." unique_id=1364277535]
transform = Transform3D(0.2, 0, 0, 0, 0.2, 0, 0, 0, 0.2, 0, 0, 0)
material_override = SubResource("StandardMaterial3D_pcpcb")
mesh = ExtResource("6_kfk5m")
[node name="DragArea" type="CollisionShape3D" parent="."]
[node name="DragArea" type="CollisionShape3D" parent="." unique_id=960002167]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.25, 0)
shape = SubResource("CylinderShape3D_kfk5m")
[node name="SubstanceData" type="Node" parent="."]
[node name="SubstanceData" type="Node" parent="." unique_id=1379108671]
script = ExtResource("7_ymvgp")
[node name="Interaction" type="ConfirmationDialog" parent="."]
[node name="Interaction" type="ConfirmationDialog" parent="." unique_id=1225848265]
title = "Добавить вещество?"
ok_button_text = "Добавить"
cancel_button_text = "Не добавлять"
script = ExtResource("5_o7vug")
[node name="HBoxContainer" type="HBoxContainer" parent="Interaction"]
[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"]
[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"]
[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"]
[node name="Interaction" type="Node" parent="Interaction" unique_id=729724369]
script = ExtResource("6_00jpx")
[connection signal="interacted" from="Interaction" to="Interaction/Interaction" method="_on_interaction_interacted"]

View file

@ -2,6 +2,7 @@ shader_type spatial;
render_mode cull_back, blend_mix;
uniform vec4 albedo_color: source_color;
uniform float fill: hint_range(0.0, 1.0, 0.01) = 0.;
uniform float wave_intensity: hint_range(0.0, 1.0, 0.01) = 0.;
@ -17,6 +18,8 @@ void vertex() {
void fragment() {
// Called for every pixel the material is visible on.
ALBEDO = albedo_color.rgb;
ALPHA = albedo_color.a;
}
//void light() {

View file

@ -26,6 +26,8 @@ var dragged: bool = false:
@export var interactible: Interactible
@export var button_generator: ButtonGenerator
@export var display_text: String
@export var mask: PackedStringArray
var contacted_draggables: Array[DraggableObject]
var filtered_draggables: Array[DraggableObject]
@ -37,9 +39,18 @@ func _ready() -> void:
func _mouse_enter() -> void:
mouse_in = true
var text: String
if has_node("Inventory") and len($Inventory.inventory) != 0:
text = $Inventory.get_text()
else:
text = display_text
if text == "":
return
Tooltip.set_text(text)
func _mouse_exit() -> void:
mouse_in = false
Tooltip.clear()
func set_mask(new_mask: PackedStringArray) -> void:
mask.clear()

View file

@ -29,3 +29,9 @@ func _on_interactible_interacted(with: DraggableObject) -> void:
log_message += "%s мг. %s, " % [str(sub.amount),sub.substance.get_formula()]
GuiSignalBus.push(log_message)
inventory_updated.emit(mini_inventory)
func _process(_delta: float) -> void:
var result = ""
for key in mini_inventory:
result += key.substance.scientific_name + "+"
$"../..".display_text = result.left(len(result)-1)

View file

@ -3,7 +3,7 @@ extends Node
var add_amount: float
func _on_interaction_interacted(with: DraggableObject) -> void:
if with.is_in_group("flask"):
if with.is_in_group("flask") and add_amount > 0:
var subs: RuntimeSubstanceData = RuntimeSubstanceData.new()
subs.amount = add_amount
subs.substance = $"../../SubstanceData".substance

View file

@ -179,3 +179,22 @@ func check_for_reactions() -> void:
update_solutions()
inventory_changed.emit(inventory.values())
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_odor() -> Array[RuntimeSubstanceData]:
var result = []
for key in inventory:
if inventory[key].substance in [preload("res://assets/substances/CH3COOH.tres")]:
result.push_back(inventory[key])
return result
func get_text() -> String:
var result = ""
for key in inventory:
result += key + "+"
return result.left(len(result)-1)

View file

@ -12,7 +12,48 @@ enum DisplayType{
material_override.set_shader_parameter("wave_intensity",1.)
tween.tween_property(material_override,"shader_parameter/wave_intensity",0.0,2.0)
func update_material(substances: Array[RuntimeSubstanceData]) -> void:
func update_fluid_material(substances: Array[RuntimeSubstanceData]) -> void:
var mat: ShaderMaterial = material_override
if len(substances) == 0:
visible = false
return
else:
visible = true
var total_weight = 0
var total_color = 0
for sub in substances:
total_weight += sub.amount
total_color += sub.substance.color_influence
var pH: float = 0
var color: Color = Color(0,0,0,0)
for sub: RuntimeSubstanceData in substances:
var weight: float = sub.amount/total_weight
pH += sub.substance.get_ph_runtime(substances) * weight
for sub: RuntimeSubstanceData in substances:
var color_to_add: Color
if sub.substance.pHColor != null:
color_to_add = sub.substance.pHColor.sample(pH/14.0)
else:
color_to_add = sub.substance.color
if display_type == DisplayType.Fluid and sub.is_solution:
color_to_add.a = 0.5
#if color == Color(0,0,0,0):
# color = color_to_add
#else:
# color = color.lerp(color_to_add,sub.substance.color_influence)
color += color_to_add * sub.substance.color_influence
mat.set_shader_parameter("albedo_color", color / total_color)
func update_solid_material(substances: Array[RuntimeSubstanceData]) -> void:
var mat: StandardMaterial3D = material_override
if len(substances) == 0:
visible = false
@ -57,10 +98,10 @@ func update_material_unfiltered(substances: Array[RuntimeSubstanceData]):
match display_type:
DisplayType.Fluid:
var fluids = substances.filter(filter_liquids)
update_material(fluids)
update_fluid_material(fluids)
DisplayType.Solid:
var solids = substances.filter(filter_solids)
update_material(solids)
update_solid_material(solids)
func filter_liquids(sub: RuntimeSubstanceData): return sub.substance.melting_point < sub.temperature or sub.is_solution
func filter_solids(sub: RuntimeSubstanceData): return sub.substance.melting_point > sub.temperature and not sub.is_solution

View file

@ -15,3 +15,4 @@ func _ready() -> void:
if substance.is_solution:
jar_fill_material.albedo_color.a = 0.5
get_parent().add_to_group("fluid_source")
get_parent().display_text = substance.scientific_name

12
ui/tooltip.gd Normal file
View file

@ -0,0 +1,12 @@
extends Control
func _process(delta: float) -> void:
global_position = get_global_mouse_position()
func set_text(text: String):
$Label.text = text
visible = true
func clear():
$Label.text = ""
visible = false

1
ui/tooltip.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://bu3exvpul8jhk

15
ui/tooltip.tscn Normal file
View file

@ -0,0 +1,15 @@
[gd_scene format=3 uid="uid://dtpy85f2ycbur"]
[ext_resource type="Script" uid="uid://bu3exvpul8jhk" path="res://ui/tooltip.gd" id="1_np3dp"]
[node name="Tooltip" type="PanelContainer" unique_id=246590363]
visible = false
offset_right = 1.0
offset_bottom = 23.0
size_flags_horizontal = 0
size_flags_vertical = 0
script = ExtResource("1_np3dp")
[node name="Label" type="Label" parent="." unique_id=1174493236]
layout_mode = 2
size_flags_horizontal = 0