From cb07298c8afa5b6fc0407430a0fe3b1c167dba38 Mon Sep 17 00:00:00 2001 From: veclavtalica Date: Wed, 12 Feb 2025 08:37:29 +0300 Subject: [PATCH] sprout picking --- src/ingame/sprout.gd | 20 ++++++++++++++++++++ src/ingame/sprout.tscn | 10 ++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/ingame/sprout.gd b/src/ingame/sprout.gd index 00fd08a..459b6a2 100644 --- a/src/ingame/sprout.gd +++ b/src/ingame/sprout.gd @@ -3,6 +3,7 @@ extends Node3D @export var _need_water_drop: Sprite3D @export var _production_timer: Timer @export var _mesh: MeshInstance3D +@export var _area: Area3D var needs_water := true var stage: int = 1 @@ -27,6 +28,8 @@ func _water_shared(sender_id: int) -> void: _mesh.material_override.set("shader_parameter/albedo_texture", load("res://assets/sprout%s.png" % stage)) if sender_id != 0: GameState.fetch().player_data[sender_id].chain_water_combo(1) + if stage == final_stage: + _area.collision_layer |= 1 << 4 @rpc("any_peer", "call_local", "reliable") @@ -38,3 +41,20 @@ func water(sender_id: int) -> void: if stage != final_stage: needs_water = false _production_timer.start() + + +@rpc("any_peer", "call_local", "reliable") +func get_picked_up() -> void: + stage = 1 + _mesh.material_override.set("shader_parameter/albedo_texture", load("res://assets/sprout%s.png" % stage)) + _area.collision_layer ^= 1 << 4 + needs_water = true + _need_water_drop.show() + + +func mark_interactive() -> void: + _mesh.material_override.set("shader_parameter/outline_color", Color.WHITE) + + +func mark_non_interactive() -> void: + _mesh.material_override.set("shader_parameter/outline_color", Color.BLACK) diff --git a/src/ingame/sprout.tscn b/src/ingame/sprout.tscn index b76e4a7..48548ce 100644 --- a/src/ingame/sprout.tscn +++ b/src/ingame/sprout.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=9 format=3 uid="uid://bysgtksvovyur"] +[gd_scene load_steps=10 format=3 uid="uid://bysgtksvovyur"] [ext_resource type="Script" path="res://src/ingame/sprout.gd" id="1_snma1"] [ext_resource type="Texture2D" uid="uid://d35y5ckne72qe" path="res://assets/sprout1.png" id="2_ipgad"] [ext_resource type="Shader" path="res://scenes/interactivity_outline2.gdshader" id="2_oa2it"] [ext_resource type="Texture2D" uid="uid://cwbl0r1e26eja" path="res://assets/drop.png" id="3_kghdv"] +[ext_resource type="Script" path="res://src/lib/item_component.gd" id="4_w5b5s"] [sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_rs2qp"] properties/0/path = NodePath(".:needs_water") @@ -28,12 +29,13 @@ size = Vector2(0.5, 1) radius = 0.3 height = 0.8 -[node name="Sprout" type="Node3D" node_paths=PackedStringArray("_need_water_drop", "_production_timer", "_mesh")] +[node name="Sprout" type="Node3D" node_paths=PackedStringArray("_need_water_drop", "_production_timer", "_mesh", "_area")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00401986, -0.00383317, 0.00119042) script = ExtResource("1_snma1") _need_water_drop = NodePath("NeedWaterDrop") _production_timer = NodePath("ProductionTimer") _mesh = NodePath("Mesh") +_area = NodePath("Area3D") [node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."] replication_config = SubResource("SceneReplicationConfig_rs2qp") @@ -63,4 +65,8 @@ shape = SubResource("CapsuleShape3D_cwbye") wait_time = 5.0 one_shot = true +[node name="Harvest" type="Node" parent="."] +script = ExtResource("4_w5b5s") +id = "sprout" + [connection signal="timeout" from="ProductionTimer" to="." method="_on_production_timer_timeout"]