diff --git a/assets/materials/glass.tres b/assets/materials/glass.tres deleted file mode 100644 index 36e5646..0000000 --- a/assets/materials/glass.tres +++ /dev/null @@ -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 diff --git a/assets/materials/glass_std.tres b/assets/materials/glass_std.tres deleted file mode 100644 index cf4e45e..0000000 --- a/assets/materials/glass_std.tres +++ /dev/null @@ -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 diff --git a/assets/materials/mat_glass.tres b/assets/materials/mat_glass.tres new file mode 100644 index 0000000..ee614fd --- /dev/null +++ b/assets/materials/mat_glass.tres @@ -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 diff --git a/assets/models/flask.glb b/assets/models/FlaskNew.glb similarity index 54% rename from assets/models/flask.glb rename to assets/models/FlaskNew.glb index 9ef369c..46e8f88 100644 Binary files a/assets/models/flask.glb and b/assets/models/FlaskNew.glb differ diff --git a/assets/models/flask.glb.import b/assets/models/FlaskNew.glb.import similarity index 69% rename from assets/models/flask.glb.import rename to assets/models/FlaskNew.glb.import index acc6504..ddad0f9 100644 --- a/assets/models/flask.glb.import +++ b/assets/models/FlaskNew.glb.import @@ -3,13 +3,13 @@ importer="scene" importer_version=1 type="PackedScene" -uid="uid://cybcaqajfr5jx" -path="res://.godot/imported/flask.glb-2126b3646c073a6ae7a51eae46cf2a4b.scn" +uid="uid://b6ydpkle2ol20" +path="res://.godot/imported/FlaskNew.glb-8b6f6d6281f698dfdf4a2cc330807ea4.scn" [deps] -source_file="res://assets/models/flask.glb" -dest_files=["res://.godot/imported/flask.glb-2126b3646c073a6ae7a51eae46cf2a4b.scn"] +source_file="res://assets/models/FlaskNew.glb" +dest_files=["res://.godot/imported/FlaskNew.glb-8b6f6d6281f698dfdf4a2cc330807ea4.scn"] [params] @@ -39,9 +39,10 @@ materials/extract_format=0 materials/extract_path="" _subresources={ "materials": { -"@MATERIAL:0": { +"mat_glass": { "use_external/enabled": true, -"use_external/path": "uid://glk2rfkn4vcu" +"use_external/fallback_path": "res://assets/materials/mat_glass.tres", +"use_external/path": "uid://64m17act0kwu" } } } diff --git a/project.godot b/project.godot index 1b860d7..7b834a6 100644 --- a/project.godot +++ b/project.godot @@ -15,6 +15,10 @@ run/main_scene="uid://c7r4rhgj3ucao" config/features=PackedStringArray("4.5", "Mobile") config/icon="res://icon.svg" +[autoload] + +GuiSignalBus="*res://src/gui_signal_bus.gd" + [input] drag_camera={ diff --git a/scenes/draggable_object.tscn b/scenes/draggable_object.tscn index b310b2f..c8ba9c7 100644 --- a/scenes/draggable_object.tscn +++ b/scenes/draggable_object.tscn @@ -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://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"] - -[sub_resource type="SphereShape3D" id="SphereShape3D_vcwhe"] -radius = 0.49570328 +[ext_resource type="Script" uid="uid://b1gv6dt8bwj2p" path="res://src/interactible/returner.gd" id="5_bqclg"] +[ext_resource type="Script" uid="uid://dteb2xxl8gixp" path="res://src/ui/slider_display.gd" id="5_qb0nw"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_vcwhe"] radius = 0.1 -height = 0.7 +height = 0.9921875 -[sub_resource type="CylinderMesh" id="CylinderMesh_627mb"] -top_radius = 0.1 -bottom_radius = 0.08 -height = 0.5 +[sub_resource type="SphereShape3D" id="SphereShape3D_vcwhe"] +radius = 0.49649125 [node name="DraggableObject" type="Area3D"] script = ExtResource("1_vcwhe") -[node name="DragShape" type="CollisionShape3D" parent="."] -shape = SubResource("SphereShape3D_vcwhe") +[node name="DragArea" type="CollisionShape3D" parent="."] +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_mask = 2 input_ray_pickable = false script = ExtResource("2_627mb") +interaction_dialog = NodePath("../InteractionDialog") -[node name="CollisionShape3D" type="CollisionShape3D" parent="InteractionArea"] -shape = SubResource("CapsuleShape3D_vcwhe") - -[node name="MeshInstance3D" type="MeshInstance3D" parent="."] -mesh = SubResource("CylinderMesh_627mb") +[node name="InteractionArea" type="CollisionShape3D" parent="InteractionArea"] +shape = SubResource("SphereShape3D_vcwhe") [node name="ProximityRotator" type="Node" parent="." node_paths=PackedStringArray("rotated")] script = ExtResource("3_00eeh") -rotated = NodePath("../MeshInstance3D") -proximity_radius = 0.496 +rotated = NodePath("..") +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="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_exited" from="InteractionArea" to="ProximityRotator" method="_on_interaction_area_interaction_reciever_exited"] diff --git a/scenes/interactible_object.tscn b/scenes/interactible_object.tscn index 82b7080..d88bab7 100644 --- a/scenes/interactible_object.tscn +++ b/scenes/interactible_object.tscn @@ -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="Material" uid="uid://64m17act0kwu" path="res://assets/materials/mat_glass.tres" id="2_mqqtq"] [sub_resource type="CylinderMesh" id="CylinderMesh_nql6a"] +material = ExtResource("2_mqqtq") height = 0.75 +rings = 0 +cap_top = false [sub_resource type="CylinderShape3D" id="CylinderShape3D_auicg"] -height = 1.0 +height = 0.7128906 radius = 0.75 [node name="InteractibleObject" type="Area3D"] @@ -19,5 +23,5 @@ script = ExtResource("1_auicg") mesh = SubResource("CylinderMesh_nql6a") [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") diff --git a/scenes/lab.tscn b/scenes/lab.tscn index 6c192dd..59a6ff3 100644 --- a/scenes/lab.tscn +++ b/scenes/lab.tscn @@ -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") [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="."] 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="."] layer = 100 [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) diff --git a/src/drag/draggable_object.gd b/src/drag/draggable_object.gd index 407e48d..b35b208 100644 --- a/src/drag/draggable_object.gd +++ b/src/drag/draggable_object.gd @@ -1,5 +1,7 @@ extends Area3D +class_name DraggableObject + signal drag_started signal drag_ended diff --git a/src/gui_signal_bus.gd b/src/gui_signal_bus.gd new file mode 100644 index 0000000..9740802 --- /dev/null +++ b/src/gui_signal_bus.gd @@ -0,0 +1,5 @@ +extends Node + +@warning_ignore_start("unused_signal") + +signal interaction_confirmed(data: Dictionary) diff --git a/src/gui_signal_bus.gd.uid b/src/gui_signal_bus.gd.uid new file mode 100644 index 0000000..c984f94 --- /dev/null +++ b/src/gui_signal_bus.gd.uid @@ -0,0 +1 @@ +uid://5o7igp3yxx6o diff --git a/src/interactible/interaction_reciever.gd b/src/interactible/interaction_reciever.gd index 3b1ed8d..79e3fc9 100644 --- a/src/interactible/interaction_reciever.gd +++ b/src/interactible/interaction_reciever.gd @@ -2,7 +2,7 @@ extends Area3D class_name InteractionReciever -signal interacted(source: InteractionSource) +signal interaction_start(source: InteractionSource) func _ready() -> void: area_entered.connect(on_area_entered) @@ -10,8 +10,8 @@ func _ready() -> void: func on_area_entered(area: Area3D): if area is InteractionSource: - area.interaction_requested.connect(interacted.emit) + area.interaction_requested.connect(interaction_start.emit) func on_area_exited(area: Area3D): if area is InteractionSource: - area.interaction_requested.disconnect(interacted.emit) + area.interaction_requested.disconnect(interaction_start.emit) diff --git a/src/interactible/interaction_source.gd b/src/interactible/interaction_source.gd index a6ca8c1..cdb842f 100644 --- a/src/interactible/interaction_source.gd +++ b/src/interactible/interaction_source.gd @@ -2,21 +2,33 @@ extends Area3D class_name InteractionSource +@export var interaction_dialog: ConfirmationDialog +var recievers: int = 0 + signal interaction_requested +signal interaction_closed signal interaction_reciever_entered(reicever: InteractionReciever) signal interaction_reciever_exited(reicever: InteractionReciever) func _ready() -> void: area_entered.connect(on_area_entered) 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): if area is InteractionReciever: interaction_reciever_entered.emit(area) + recievers += 1 func on_area_exited(area: Area3D): if area is InteractionReciever: interaction_reciever_exited.emit(area) + recievers -= 1 func request_interaction() -> void: + if recievers == 0: + interaction_closed.emit() + return interaction_requested.emit() + interaction_dialog.popup_centered() diff --git a/src/interactible/proximity_rotator.gd b/src/interactible/proximity_rotator.gd index c2b888c..222e380 100644 --- a/src/interactible/proximity_rotator.gd +++ b/src/interactible/proximity_rotator.gd @@ -13,6 +13,7 @@ func _on_interaction_area_interaction_reciever_entered(rec: InteractionReciever) func _on_interaction_area_interaction_reciever_exited(rec: InteractionReciever) -> void: if reciever == rec: reciever = null + rotated.quaternion = start_rotation func _process(_delta: float) -> void: if reciever == null: diff --git a/src/interactible/returner.gd b/src/interactible/returner.gd new file mode 100644 index 0000000..1a87ba3 --- /dev/null +++ b/src/interactible/returner.gd @@ -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 diff --git a/src/interactible/returner.gd.uid b/src/interactible/returner.gd.uid new file mode 100644 index 0000000..d4eee65 --- /dev/null +++ b/src/interactible/returner.gd.uid @@ -0,0 +1 @@ +uid://b1gv6dt8bwj2p diff --git a/src/inventory.gd b/src/inventory.gd new file mode 100644 index 0000000..3f0798a --- /dev/null +++ b/src/inventory.gd @@ -0,0 +1,6 @@ +extends Node + +@export var open_on_top: bool +var liquids +var solids +var gasses diff --git a/src/inventory.gd.uid b/src/inventory.gd.uid new file mode 100644 index 0000000..12d4224 --- /dev/null +++ b/src/inventory.gd.uid @@ -0,0 +1 @@ +uid://82ettbegollp diff --git a/src/ui/slider_display.gd b/src/ui/slider_display.gd new file mode 100644 index 0000000..c8de1b7 --- /dev/null +++ b/src/ui/slider_display.gd @@ -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 diff --git a/src/ui/slider_display.gd.uid b/src/ui/slider_display.gd.uid new file mode 100644 index 0000000..cd47e3f --- /dev/null +++ b/src/ui/slider_display.gd.uid @@ -0,0 +1 @@ +uid://dteb2xxl8gixp